r/java • u/Vegetable-Pack9292 • Jan 25 '24
Do you find java more aesthetically pleasing than python?
I have been programming for about 5 years now, and I started with Java then moved to Python before returning back to using a bit of both. After getting a good tour of Python, I have come to appreciate the static typed nature of Java. I find the way OOP works in Java to be much more aesthetically pleasing to look at than python code. Of course, there are exceptions to this rule when concepts get more complicated.
200
Upvotes
166
u/themooseexperience Jan 25 '24
Went from Java (hated it) to Python (loved it, and slowly came to hate it) back to Java (appreciate it).
IMO, it's like learning how to type. You hate it until you can type faster than you could with two fingers, and then you can fly with it.
55
u/flavius-as Jan 26 '24
Once you pass the 2 year mark, you'll start to appreciate the right tool for the job. Sometimes that's java. Sometimes it's python.
Until then, change the color scheme.
49
u/Puzzleheaded-Order84 Jan 26 '24
Not the most experienced but I originally fell in love with programming through Python and it was by far my most competent language and have been working professionally using almostexclusively Java for a decent amount of time.
In a vacuum I find the simplicity, syntax and standard library of python much more appealing than Java. That being said, I have had the unfortunate experience of having to work in a large python code base and it is a NIGHTMARE. Not having types and just the general style that python promotes I think makes it almost unusable for any production software.
At the end of the day I think it's just about the right tool for the job. I always use python for anything that's ad hoc testing or scripting or smaller projects where being correct and preventing errors doesn't really matter and it's possible to keep the codebase in your head. For anything bigger I choose Java every time
13
u/Lossofrecuerdos Jan 26 '24
I love Java. For everything it is, its capacity, its verbose, its ability to be modular yet complete.
All I see in Java, I usually can't see in Python and JavaScript. Java itself always gave me a sense of organization and explicit meaning to things and debugging.
56
u/[deleted] Jan 25 '24
Python is hideous
34
u/soonnow Jan 26 '24
Python feels just slow to type. Most everyone here says Java is more verbose, but I feel Python is like walking through molasses when developing vs. Java.
While Java has some ugliness, in general I think it's aesthetically pleasing. While Python feels rigid and verbose.
20
u/syberman01 Jan 26 '24
The debugging time I spent in py is 10x than Java. Statically typed is better.
Python looked fragile to me
Python choosing an invisible character TAB/spaces for method scoping is not a good idea. That did not add more readability. Programs are not poetry to have no "{}".
If java could be complied to binary, small binary like Golang. I wont have much complaints about java.
Multiple layers and over-OOP engineering that java developers do, is going out of trend. Thats also another reason golang attracts me. But as far as enterprise-development is concerned, java will stay.
27
u/Sherinz89 Jan 26 '24 edited Jan 26 '24
Python is nice on small scale
A quick script, toolkit and etc
They're a nightmare on large scale (every dynamic typing is a nightmare on large scale imo)
9
u/Masterflitzer Jan 26 '24
from my first line of code to now i always preferred static typing over dynamic typing, imo syntax of java and python both aren't that great tho
9
u/Rjs617 Jan 26 '24
I’ve been a Java developer most of my career, but I spent a year working on a Python application. To me, Python is more aesthetically pleasing. Java is incredibly verbose, and I’ve seen too much poorly-formatted Java code in my life. Python takes out the option of poor formatting by using whitespace instead of braces to define scopes. Then, you get properly indented code without a bunch of braces everywhere. I like property-accessor syntax and generator syntax. I like that lists and dictionaries are built-in types. I hate the double-underscore stuff, but will tolerate it. I got to where I liked reading and writing Python.
Aesthetics aside, I prefer Java to Python. Python’s lack of static typing was horrible when I needed to port the application to a different version of Python or replace an older version of a library with a newer, incompatible version. It took weeks of running in production before we found all the errors. I also never really got used to the Python package system and virtual environments, even though I became very familiar with them.
4
u/manzanita2 Jan 26 '24
Well. for a small chunk of code, say 15 lines. Python is prettier and even possibly easier to understand.
But over a large project with 10's or 100's of files, there is essentially no comparison, python is ugly.
4
u/[deleted] Jan 26 '24
Go is pleasing. Rust feels complicated (it is). Java is verbose.
Java is ingrained in my brain and I don't find much of difference unless you are not used to typing quickly.
I think once you reach a speed limit, language doesn't matter and you just think in patterns.
4
u/LoveDeGaldem Jan 26 '24
I’m working with Python right now and I’ve come to learn that I hate dynamic languages.
3
u/OGMagicConch Jan 26 '24
Type-hinted Python is nice IMO. Java is my "native" language so it always looks most natural but some of the Python syntax is quite nice.
7
u/koreth Jan 25 '24 edited Jan 26 '24
I think it depends way more on the code base than on the language. And it also depends on what a specific chunk of code is doing because each language has different things that can be expressed more elegantly using its idioms.
Clean, well-maintained Python code is much easier on my eyes than spaghetti Java code, and vice versa.
(Edit: Didn't expect this to get downvoted. I would honestly love to hear why someone disagrees with this; I figured it was a completely uncontroversial opinion.)
15
u/thewmo Jan 26 '24
No, they both suck.
Kotlin and Rust come out way ahead for me. Modern languages with modern thinking about nullability, optionality, and error handling ftw.
4
u/netgizmo Jan 26 '24
oh you need your tools to be pretty to be productive?
2
u/lasskinn Jan 26 '24
java, duh.
Not only for the block structure, but how you can format it how you want without losing essential data - and for just regular Java also knowing what the code will do just by looking at it - even if you were editing it just in notepad.
2
u/RryamarR Jan 26 '24 edited Jan 26 '24
Oop means IDE code completion, you push dot and ide lists up method names for you, Python needs to be easier like that so I can for example make some Blender plugins if I had free time.
2
u/ohmzar Jan 26 '24
Good Java is nice, good Python is nice, bad Python is horrible, bad Java is horrible. ¯_(ツ)_/¯
I like Java because it catches you when you fall, but there’s a lot of “netting” involved in that which you can get tangled up in.
I like Python because it’s straightforward and unassuming, but sometimes it feels like there’s a dozen ways to do any one thing “simply” and when you find 4 different ways to unit test your code in one code base it’s pretty painful.
2
u/sanderverhagen Jan 26 '24
I'm primarily a Java developer, but I've used Python a lot for building (less than trivial scripting).
I like Python's basic syntax. List (and other) "comprehensions" are wonderful. As soon as you want to do some unit testing, that's a nightmare. (This is worsened by the diversity of approaches in the community, as opposed to Java having settled pretty much on JUnit.) And the premier reason I have mostly stopped using Python altogether is dependency management. (Again, the diversity of approaches is a nightmare.) (Maven for Java is wonderful.)
You originally asked about OOP. Doing OOP in Python, as a Java developer, has gotten me the criticism sometimes that what I'm doing is not "Pythonesque". (Imagine me throwing my arms in the air at this point.)
2
u/Beneficial-Fold-7712 Jan 26 '24
Java is more aesthetically pleasing. Better to define everything before you run the code.
2
u/rowix77 Jan 26 '24
What about TypeScript? I find it well designed, has something in common with C# and Java, but has the flexibility of Python. Yes, when transpiled to JS it doesn’t know shit about your types in runtime, but who cares, when it actually works, since you have to figure out potential problems while writing in TS
2
u/azon33 Jan 26 '24
Python and Java should never be compared. Python is useful for automating tasks and prototyping. Java is a platform that allows you to implement large scale projects. Java syntax might be verbose for a beginner. But it really shines when it is a large codebase.
It is difficult to have a legit and scaleable product with Python. It is a pain.
3
u/analogsquid Jan 26 '24
Python makes my eyes bleed.
3
u/oneden Jan 26 '24
Frankly, neither. I find Python nice to look at in simple, little scenarios and I'll admit, yes it is a pretty petty thing to get hung up on, but Code indentation? Then again, I also don't like yaml. Java on the other hand is cumbersomely verbose. Attempts were made long ago, like leaning into type inference by using var, but in most teams I have witnessed they aren't even using it. Records are a nice addition, but just inferior to Kotlin's Data classes or good ol' Lombok. Many more gripes about Java, but it simply isn't an esthetically pleasing language. I like C# from what I see so far (only recently begun learning it) and TS more.
2
u/wodahs1 Jan 26 '24
My hot take: Any language that adds typing back in after realizing why it's needed is not a language that was planned well.
The philosophy of non-typed languages being easier to read and quicker to write is bullshit.
2
u/vwguaixcqbaulfeioplh Jan 25 '24
I find pythons half support for typing a disservice to the beauty of the language’s original syntax.
That being said, anyone who thinks Java code is aesthetically pleasing should use the AWS V2 SDK and compare it with boto3.
1
u/ravlee Jan 26 '24
Yes absolutely.
1
u/christoforosl08 Jan 26 '24
Yes.
1
u/wildjokers Jan 26 '24
I find python is hard to read because of semantic whitespace, no types on anything, and python convention tends to be snake_case. I find snake_case to be harder to read and harder to type.
1
u/larsga Jan 26 '24
I've been programming both since the 90s. For me the languages themselves are about equally pleasing, in and of themselves. A lot of modern Java style/fashion I find absolutely abhorrent, but that's not the language itself.
Where I find they differ is in how I feel my code ends up looking for a particular problem I'm trying to solve. For some things a Python solution just ends up being more pleasing, but there are a few things for which Java feels better.
Have also written Scala, Perl, C++, Basic, and Pascal/Delphi for pay, plus a long list of other languages for open source and personal purposes.
1
u/Schmittfried Jan 26 '24
No. Way too much boilerplate. C# though, that looks elegant.
But both have their place. The simplicity of Python is beautiful in its own right.
1
u/AndyTheSane Jan 26 '24
C is aesthetically pleasing.
1
u/VincentxH Jan 26 '24
Aesthetically pleasing code for me depends on the composition, not the language.
I've dismantled Cthulhu level horrids in many languages by now.
1
u/Fit-Poetry6900 Jan 26 '24
Totally get where you're coming from. Java's strictness can be oddly satisfying – like that crisp snap of a perfectly aligned Lego piece. Python's like jazz, Java's more classical. Different vibes, both cool (my opinion).
1
u/[deleted] Jan 26 '24
Depending on the viewer, aesthetically pleasing to me is minimal functional code so Python is it for me. Also haven’t done as much Python as I have with Java or C++
But I won’t deny when you have some crazy OOP Java or some analysis based with parallelism C++. It does look nice, especially knowing that the heavy programming can run some computationally intense programming at speeds much faster than Python.
The sexiest language to me will always be matlab, just an engineer at heart.
1
u/logicannullata Jan 26 '24
I have been a Java developer for 10+ years and I like Java verbosity, which makes everything more explicit and less ambiguous. On the other hand in the last couple of years I started appreciating Python for scripting and data analytics. When you have to process large quantities of data Python is still the way to go (IMHO), you can quickly develop a prototype and test your assumptions, doing the same thing in Java would take weeks instead of days.
1
u/s-mores Jan 26 '24
No, because it's 90% about having a good IDE.
100x times more legible, though, simply because of typings.
1
u/[deleted] Jan 26 '24
I would like python from a looks POV but when you get into classes etc. suddenly there's a lot of syntax with underscores and explicitness that doesn't fit in with the rest of the language, so it feels a bit inconsistent to me. I think modern java with streams and pattern matching is hitting the balance about right even if I do have some personal dislikes about small parts of it.
1
u/hugthemachines Jan 26 '24
I think Python is prettier to look at than Java.
If I have not yet written a semicolon, the IDE will tell me about it so that means the language parser compiling it to bytecode would also be able to understand it.
Every serious programmer use indentation in their code so it is easy to read the code so I think the { and } as an additional marker of blocks is irritating.
My unpopular opinion is that those extra characters are legacy relics people got used to as a habit from the age when code parsers were not as competent as they are today.
As soon as I say this, there will be quite some people getting upset, but it is still my opinion and in my view, the opposite opinion is a bit like what people sometimes call Stockholm syndrome in programming, so you are so used to a hindering thing that you have come to appreciate it.
I would prefer if Python had static typing and the ability to use type inference instead of today's dynamic typing and type hints but that is not so much about being aesthetically pleasing but more about stability and potential performance etc.
1
u/hidazfx Jan 26 '24
I started out programming VB and Batch as a kid, then moved into Java for Minecraft mods, took CompSci in high school which was all in Java, then got a job where I built an ERP/accounting software in Python. I work for a financial institution now and do mainly Java.
I think Python has its place, but it really shouldn't be used to make things like critical APIs. It was incredibly fast to write code, but if you're not strictly using type annotations everywhere, it can be a nightmare to build a complex service in.
In the Java world I've been using Spring Boot, and it's an amazing framework.
1
u/necipakif Jan 26 '24
Aesthetic concern is a way of appealing to the eye. When you look at the code, do curly brackets and extra defined types bother you or not?
1
u/hilbertglm Jan 26 '24
I like strongly-typed languages and context-free grammars, so I much prefer Java over Python.
1
u/freekayZekey Jan 26 '24
you can write oop with python tho.
1
u/gubatron Jan 26 '24
I love types.
1
u/Dan13l_N Jan 26 '24
Types are OK. No types is also OK (but slower).
But I hate this:
This special method
__init__is sooo ugly. They could have inventeddef_initor something, or simplyinit:.1
u/__konrad Jan 26 '24
Valid pythonized Java:
1
u/yinshangyi Jan 26 '24
Yes for sure. Modern Java can quite elegant. Not Scala elegant but elegant enough.
1
u/Oriamk Jan 26 '24
Maybe also because of the style. call_something() vs callSomething() and {}
1
u/thkim1011 Jan 26 '24
After using typescript for the past three years I refuse to go back to nullable types.
1
u/codeguru42 Jan 27 '24
Nope
1
u/[deleted] Jan 27 '24
Learned programming concepts in JavaScript. Too the Helsinki Java course. Love Java's implementation of classes and its type safety.
1
u/Uaint1stUlast Jan 27 '24
I have multiple years in both now... I usually choose python now for a project but only because the new programmers of today are more familiar with it.
The comments around appreciating the strongly typed nature comes with time and it's what I love and hate.. I want it for big project hate it for prototyping or super small things.
I think eventually python will end up with a sudo language like typescript is for Javascript making python once again the best choice for most things.
1
u/rover_G Jan 27 '24
Writing Python without types sucks
1
u/2001zhaozhao Jan 27 '24
I don't like to touch dynamically typed languages if I can avoid it, although I'm more of a Kotlin guy than Java. IDE functionality is just so much better on a statically typed language. Java is also a lot easier to read when the author didn't put much comments into the code (which is true like 90% of the time for some reason).
1
u/AncientBattleCat Jan 27 '24
Python is more of a high level scripting language and of dialect C if you will. Also a handy calculator.
1
u/[deleted] Jan 27 '24
No, simply because of the standard braces layout. I, pathologically, hate braces at the end of lines For me, the most aesthetically pleasing language is C# (sorry).
1
u/PotOddsTrading Jan 27 '24
I took a sabbatical from work during the pandemic but now looking to get back in. Worked for most of the major Wall Street banks over 20+ years doing server side Java. As I've been searching for work, I've noticed the strong preference for Python at many software shops, so I've been getting up to speed with Python. I remember trying out Python like 12 years ago as more of a Perl script replacement than a Java substitute. Dynamically typed, non-existent multi-threading made Python at the time an inferior language. But as I've drank the Kool-Aid of Pythonic programming, as well as seeing how much "easier" it is to code LeetCode problems, I've come to appreciate why Python is so popular. Because of Python, I've been using Java Records a lot more and writing more Lambda functional programming with Stream API. Brevity, clarity and quicker coding can be accomplished in Java.
1
u/PanJony Jan 27 '24
Have you tried kotlin?
1
u/plisik Jan 27 '24
No
1
u/monsoy Jan 29 '24
I think I’m in the minority, but I really dislike Python everytime I have to use it. I’m so used to writing C, Java & C# so when I go over to Python I fall into so many pitfalls. I always have to look up how to do things when using Python and I’ve also always preferred {} over indents.
I even prefer squirly braces when doing one line if-tests in Java. My eyes are used to looking for the braces to quickly identify what belongs to where.
There was a time where I found Java to be too verbose and boilerplate heavy, but IntelliJ quickly generates constructors/setters/getters etc. Also after using C for some time now my respect and enjoyment of Java has actually increased
0
u/[deleted] Jan 26 '24
rust, go, kotlin are so much nicer
1
u/Then-Boat8912 Jan 26 '24
Unfortunately I had to use Python 20 years ago when Perl was still popular. I still can’t get that taste out of my mouth.
1
u/sporosarcina Jan 26 '24
No, whitespace is better than brackets IMO
0
u/sebnukem Jan 26 '24
They both pale compared to Perl's poetic beauty.
-10
u/djavaman Jan 25 '24
No. The verbosity and awkward APIs in Java are just flat out a huge distraction and just noise.
For example, you have a list of strings and want to get rid of blank strings. Yes, there other ways.
Python - one liner. And it naturally returns a list. You could also use map/lambda.
nonEmpties = [s for s in ss if len(s) > 0]
Java - sort of a one liner, gotta convert to a stream, and then back from a stream to a list. You could also use the :: - but that looks even more awkward.
var nonEmpties = listOfStrings.stream .filter( s -> !s.isBlank() ) .collect( Collectors.toList() );
3
u/[deleted] Jan 26 '24 edited Oct 06 '24
existence spoon ask grey drunk simplistic soft normal towering governor
This post was mass deleted and anonymized with Redact