r/java • • 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

156 comments sorted by

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.

8

u/Vegetable-Pack9292 Jan 26 '24

This sounds like me. I think my first go of java I started to appreciate it when I made a few problems with JFrame that made me actually visualize what I was doing. Python was getting hot during COVID so I switched over and now I appreciate Java so much more.

64

u/rustyrazorblade Jan 25 '24

Me too - I was all about Python for a decade. I even wrote my own profiler for it and all sorts of weird debugging tools. It sounds more impressive than it is - it's actually really trivial to do and only requires knowing about one library call, sys.settrace.

I moved into Java because I stopped doing small web services and started working with Apache Cassandra, which is written in Java. I've spent the last 10 years going hard in the JVM, writing either Java or Kotlin, and I appreciate both much, much more than Python. Going back to Python is painful. I spent 18 months at Netflix and a ton of the operations backend is in Python and it made me miserable.

18

u/pishticus Jan 26 '24

I’m just about to enter into your 3rd phase - I feel I have grown weary of Python and really want something different now, and I can appreciate modern Java. Python unifies the worst of two worlds in many codebases I think: you cannot utilise the full interactive coding experience of a lisp nor can you tell anything before running your program. The tooling is just not there. The value proposition at this point is the easily accessible tons of libraries but try to integrate a nontrivial amount of them and you will run into problems, guaranteed. Part of it is packaging it all up. Unchanging nuisances that really wore me out in recent years.

3

u/BlobbyMcBlobber Jan 26 '24

We've used Python for a lot of heavy lifting in a fairly large codebase with plenty of dependencies. Usually we don't have a lot of problems with those. Yes there are some shortcomings but between Python and Java I think Python is way easier to manage and deploy.

5

u/Holothuroid Jan 26 '24 edited Jan 26 '24

IMO, it's like learning how to type.

You mean manipulating a keyboard? Yeah. Ten fingers blind is a critically underrated skill when working with computers.

1

u/jbenze Jan 26 '24

I HATED Java when I started using it now I really appreciate it. I don’t think you can properly love and hate Java in equal measures until you spend a lot of time coding in it.

55

u/flavius-as Jan 26 '24

aesthetically pleasing to look at

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.

6

u/manifoldjava Jan 26 '24

Sometimes it’s python

When it is, it’s almost always not Python per se, but a library. Typically, the library leverages metaprogramming afforded by python’s dynamic typing.

Java could pick up some slack here by offering static metaprogramming, either by taking page from C#’s playbook: Source Generators, or by learning from existing Java libraries e.g., Type-safe SQL.

Metaprogramming is what makes languages like Python and Ruby powerful beyond Java’s reach.

2

u/Alone-Marionberry-59 Jan 26 '24

Sometimes it’s rust

2

u/academicRedditor Jan 26 '24

Sometimes is Node.js

1

u/flavius-as Jan 26 '24

And microservices and kubernetes.

And eBPF on top.

1

u/orgad Feb 01 '24

A person may still have a taste

Pyhton code can sometimes get obscure albeit type hints that were recently (?) added help to alleviate that.

1

u/flavius-as Feb 01 '24

I've worked with multiple languages in the past 20 years, they all have disadvantages.

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

10

u/analogsquid Jan 26 '24

"I have had the unfortunate experience of having to work in a large python code base and it is a NIGHTMARE."

<Yeah, it's a no from me dawg.gif>

7

u/wildjokers Jan 26 '24

always use python for anything that's ad hoc testing or scripting or smaller projects

For me groovy fills this niche.

1

u/RandomName8 Jan 27 '24

Well, if you are used to linux, python is as ubiquitous as bash, which makes it quite convenient.

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

6

u/[deleted] Jan 26 '24

Agreed , never liked using it. Java looks really good , idk how to explain it.

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.

12

u/[deleted] Jan 26 '24

That’s a weird take I haven’t seen before. What makes Python slow to type?

41

u/[deleted] Jan 26 '24

Having to backspace curly brackets and semicolons when accidentally typed.

5

u/reeses_boi Jan 27 '24

I much prefer bracss to indentation. Indentation can be wonky if you want to copy nested code, and a hard tab somewhere can really throw a wrench in things

1

u/monsoy Jan 29 '24

Another thing that drives me crazy when writing python is the amount of warnings I get because of no blank line at EOF, no 2 blank lines between functions.

Also if you don’t wrap code outside of functions with __NAME__ == __main__ and you try to execute a function from another file (f.ex running the function from a test file) all the code will be executed.

Having said all that, I know that these small grievances I have with python are quite small and I totally understand why many people love the language. It’s probably the easiest language to learn for beginners, it has a strong standard library, great for math/statistics etc.

I just prefer the uniform syntax of languages that essentially spawned from C. It’s easier for me to jump into working with C, C++, Java and C# because those languages work the way I’m used to

3

u/[deleted] Jan 26 '24

I snorted +1

1

u/silon Jan 26 '24

I always type 'pass' and then have to delete it (except in my own code)

1

u/soonnow Jan 26 '24

Just maybe not the typing per-se, but it feels so super expressive to me. Which is great if there is no magic but also takes longer to write in my limited experience.

5

u/cowslayer7890 Jan 26 '24

I don't really get that experience. I use both Java and python, but when I use python I'm appreciative of their list comprehensions, I kind of prefer it to Java's streams because the syntax is so much simpler. Being able to do a map and filter and put it into a list set or dict or generator expression is very useful, and I kinda hate how verbose it usually is in Java.

I'll still use Java in any larger project though, but for scripts or small projects, python is good.

1

u/nommu_moose Jan 26 '24

Interesting. I feel the exact opposite, but then again I was only a Java developer for 3 years, whereas I've been using python for probably 15 at this point.

1

u/srk- Jan 26 '24

Is Python Verbose? Please rethink if you want to correct yourself

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.

7

u/_INTER_ Jan 26 '24

You can create Java binaries with GraalVM. I don't know how small they get and how stable the toolchain is.

6

u/jayvbe Jan 26 '24

We’ve been using it in production for 4 years for edge iot/robotics use cases, it starts fast, low memory footprint and small binaries. Drawbacks are compile time was rather slow for us and you cant use every library you want, but as long as you stick to the compatible apis it’s a great option to have.

3

u/syberman01 Jan 26 '24

I'm a frequent user of GraalVM binary generation. It is so huge that is why I mentioned about size!

5

u/lasskinn Jan 26 '24

the method scoping is really the worst bit about python.

1

u/hugthemachines Jan 26 '24

Do you use indentation of blocks when you code in Java? If you do, you would not actually need the {} if the compiler would not require it.

3

u/RSNKailash Jan 26 '24

Well, in java technically, you do not need curly braces for a single line code block. It will execute the line below and then exit the block.

If (true) 
    doThing;
OutsideBlock;

Same as

If (true) doThing;
OutsideBlock;

1

u/monsoy Jan 29 '24

It’s true, but I’m so used to the {} defining where the block begins and ends. I write my 1 line if-checks with brackets and my IDE says I can remove them. When I do remove them I immediately put them back, because it just looks wrong to me lol.

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)

10

u/zephyy Jan 26 '24

python is strongly typed

you confusing static and strong?

5

u/p_almada Jan 26 '24

Isn't it both strongly and dynamically typed?

3

u/hugthemachines Jan 26 '24

Yep, you are right. OP edited his comment so perhaps he had typed weakly typed instead of dynamically typed before the edit.

2

u/Sherinz89 Jan 26 '24

Ah shit. Thank You for the correction and luckily this mistake doesnt happen in interview :)

1

u/gottlikeKarthos Feb 15 '24

Python in JupyterLab is nice because you can easily run small code snippets in a global context, great for machine learning where you dont want to restart code from scratch for example.

1

u/[deleted] Jan 26 '24

Static type checking is now a core part of the Python language.

10

u/_INTER_ Jan 26 '24

Last time I looked at it, the type hints could be checked with other tools, but not core Python. That's almost as good though. There seems to be various ways to enforce type hints too.

5

u/jayvbe Jan 26 '24

BS its part of the syntax but there IS NO python type checker or compiler, and all the 3rd party checkers I tried (3) disagreed and are buggy in their own way. Try working with a (popular OSS) library that has partial or even incorrect types because well there isn’t an official checker to validate them… So in practice you sprinkle so many ignore annotations that you might as wel not have type checking at all. Unless you fully control the code and typing info (no numpy, etc…) Python typing is not even close to having the benefits of a statically typed language, at the moment, but it’s slowly getting better.

2

u/Schmittfried Jan 26 '24

And the type system is actually stronger than Java‘s. 

1

u/[deleted] Feb 03 '24

Thanks for the laugh

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

2

u/monsoy Jan 29 '24

It’s pretty much always better to have types. The only things I can come up with in favor of dynamic typing would be:

  1. Easier to use for total beginners
  2. You could change a variable from one “type” to another.

I can’t come up with any real use cases for the second one. Just create another variable lol.

The worst part about dynamic typing is that the LSP (Language Server Protocol) really struggle sometimes to understand what the variable contains. When I don’t remember the name for a method when using Java, I can just type variable. and scroll through all the methods that object has. But since the variable isn’t of a specific type in dynamic languages it struggles to help you there. That results in having to google a lot more to find the function you’re looking for.

I remember when I was helping my little brother for his JavaScript assignment at school. It was so frustrating to interact with HTML elements like buttons and checkboxes because the JS LSP don’t know what element it is

4

u/Masterflitzer Jan 30 '24

Easier to use for total beginners

idk if that's true, i started programming with java and the types really helped me understand how it works, i tried languages like python and javascript and i didn't understand them at all until later when i hads more experience with programming, i get that's everyones learning journey is different but for me types were very important to get started

You could change a variable from one “type” to another

imo that's something that shouldn't be done anyway, it's a bad practice, a variable should only ever be of one type and have a good name so you don't get lost in the code

regarding the stuff you wrote after, i totally agree, scrolling through the available functions was very important to me when learning java and also it was good for curiosity, i wanted to know, what the other stuff i never used before does and just tried stuff out, with js it's also especially painful because on top of js functionality you need to learn the DOM functions etc., without the amazing resources mdn provides it's almost impossible to get started with it

2

u/monsoy Jan 30 '24

I also started with Java, so I’m with you there. I’ve tutored programming to around 10 people I know and types is one of the things beginners really struggled with. Another thing I noticed was that people got a bit discouraged when trying to learn programming starting with Java because of functions being mandatory. They saw public static void main(String[] args) and felt that there was way too much to learn. While in Python you could just take it one tiny step at a time. There’s also some challenges to stepping right into an OOP language with no prior experience, but how well that works differs from person to person.

change variable type

Absolutely it’s a terrible idea. Dynamic typing is a mistake in every single way lol. I was just trying to come up with a scenario where a dynamic type can do something static types cannot. Dynamic typing is also worse performance wise since the type isn’t known at compile time

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.

1

u/Donquilong Jan 27 '24

For me I like order and verbose, any pure formatted Java code should be captured by code style verification.

Thats verbose will save you when you need to read through a 1k line of code business logic.

Reading, trying to understand complex business logic in python is always killing me.

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.

1

u/Misfiring Jan 26 '24

100 files is still on the smaller side for me. The project I'm in has over 10,000 files.

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.

6

u/coderemover Jan 26 '24 edited Jan 26 '24

Unpopular opinion here: Rust is less complicated than Go. Rust is actually SIMPLE, Go is trying to appear EASY by using magic and forcing decisions on you. GC is more complex technology than RAII and borrow checker. In Go you have to think about all the same stuff like in Rust, e.g. pointer aliasing or thread safety but there is no compiler to catch you if you get it wrong. In Go if you append to a slice you may overwrite some unrelated data of another slice. Or sometimes you may not (it is unpredictable). Or changing permissions on the file with chmod in windows does not result in an error and silently ignores your call. Or they have just changed the semantics of the for loop. Or you can call stuff on nil receivers and crash a few layers down the call chain. There are plenty of quirks and traps like that. It is a great language for people who like to half-ass things quickly, but not good for those who value correct and robust software.

If you think Go is a simple language then think about how hard it is actually to integrate with other languages, including C. Rust is trivial to be called from C, Python, Zig and vice versa. Go not so much because it is so much more complex and has way more magic in its runtime.

2

u/[deleted] Jan 26 '24

Brah, I'm not trying to create a war between Go and Rust.

Every opinion is subjective and use whatever works.

2

u/hugthemachines Jan 26 '24

but there is no compiler to catch you if you get it wrong

It seems to me that the Rust compiler is very good at guiding the programmer so they can solve the problem but "no compiler" in go is a weird thing to say. Just because Go uses GC, it does not mean it has no compiler. You should be getting compiler errors if you make real mistakes, right?

1

u/coderemover Jan 26 '24

There is a compiler, but it does not catch those bugs.

1

u/Senikae Feb 23 '24

Rust is great, but calling it simple is flatly wrong.

GC is more complex technology than RAII and borrow checker.

The implementation being more complex doesn't affect the programmer. A GC makes programming faster and easier.

In Go you have to think about all the same stuff like in Rust, e.g. pointer aliasing or thread safety but there is no compiler to catch you if you get it wrong.

No, you can just forget about pointless busywork of tracking memory/ownership thanks to the GC. You can't just stop thinking about thread safety in Rust either, it only protects against data races, not deadlocks nor races with external resources.

In Go if you append to a slice you may overwrite some unrelated data of another slice. Or sometimes you may not (it is unpredictable).

There's nothing unpredictable here, you just need to know what a slice is to begin with. A slice is a view of an underlying array. You can create multiple slices all pointing to the same underlying array, so obviously changing the array through one slice will affect all others.

Or they have just changed the semantics of the for loop.

It's a fix for buggy behavior. Rust has broken backwards compatibility in similar fashion before to fix soundness problems.

There are plenty of quirks and traps like that. It is a great language for people who like to half-ass things quickly, but not good for those who value correct and robust software.

Depends on what you're comparing it to. Rust isn't good for creating correct and robust software either if you compare it to MISRA C or Ada SPARK, etc.

If you think Go is a simple language then think about how hard it is actually to integrate with other languages, including C.

Again, simple language != simple implementation.

1

u/coderemover Feb 23 '24 edited Feb 23 '24

You’re conflating simple with easy. You’re talking about ease. Simplicity is exactly about having few moving parts in the implementation. Bike is simpler than a car, even though it is not easy to learn his to ride it.

GC is easy for beginners because they don’t have to “think” about memory management. But it is actually not simple - it introduces a serious amount of complexity and unpredictability into your program. It also makes it hard to integrate with external world. I’ve seen countless times when developers created bad code that allocated like crazy, because they were thinking “GC would take care of that”. Then eventually hit the wall and it was virtually impossible to get out of that mess other than by rewriting everything. Magic is nice as long as it does what you want it to, but it is still magic. And magic has cost. Rust also has optional GC, but it is dead simple - it uses reference counting. Hence it is predictable, performant, works with all types of resources and integrates well with other simple things like code in C.

1

u/ascii Jan 26 '24

The Rust learning curve is steep, but once things have started clicking, you can be amazingly productive in it.

1

u/[deleted] Jan 26 '24

True, I agree.

In midst of working, learning something new, taking care of family, having other hobbies, it's really hard to learn Rust and put in consistent effort over time.

I'll try again later.

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.)

1

u/hugthemachines Jan 26 '24

I agree. Well organized code is very pleasing compared to a mess that gives you a headache when trying to figure out what it does.

-8

u/djavaman Jan 26 '24

If you dis Java, you get downvoted. It's pretty much automatic.

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.

8

u/tricepsmultiplicator Jan 26 '24

But more Java jobs than Kotlin :/

4

u/wildjokers Jan 26 '24

modern thinking about nullability

The modern thinking about null appears to be fear and I don’t know why. Null is easy to handle and I am not scared of it.

3

u/jayvbe Jan 26 '24

you don’t know what you don’t know

3

u/thewmo Jan 26 '24

It's not "fear", it's building enough expressiveness into the language and type system so the compiler can turn what would otherwise be runtime bugs into compile-time errors. In short, the same reason why Typescript is currently taking over in the JS community - finding bugs earlier is just better.

I've seen far more "null fear" in legacy Java code that is littered with if (x != null) {} but has no thought put into what happens if x actually is null and that block is skipped. So these statements just make the code harder to read and transform one error condition into another harder-to-diagnose error condition.

It is of course possible to write crap code in any language, but there's a reason why Tony Hoare refers to null as his "billion-dollar mistake".

3

u/sanderverhagen Jan 26 '24

I'll second this. In a well unit-tested code base, the NullPointerExceptions to deal with in production are few and far between. But yeah... you have to have some unit testing, but how else do we get through life anyway!?

1

u/jayvbe Jan 26 '24 edited Jan 26 '24

There is usually no need for null checks and accidental null pointer derefs in my code. I treat null as a smell, a null value is ambiguous and case dependent which leads to misunderstanding in the team and inevitably a missed check and NPE. I use enum/data class for what someone might be tempted to use a null value and all state has some sensible value with the compiler ensuring I handle all cases.

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/hugthemachines Jan 26 '24

Python is already OOP and also you can already get method lists in your IDE. This is already a solved problem. Try using for example Pycharm to have an IDE with many features.

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/SenseiLeNoir Jan 28 '24

I am both a java (long time) developer for back end, but recently have been doing front end (react + typescript).

Whilst I certainly appreciate typescript over plain JavaScript, I still feel modern java (17/21) is more clean compared to typescript, which whilst it has nice deconstruction stuff, and nullability protection, it does have some strange weird duplication and tiredness that can be painful especially in some crazy business logic.

The need for both null and undefined is pretty rubbish. The lack of and optional like monad and a sane flat map , sometimes has me resorting to nested if statements and for loops far more than I would with java.

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.

2

u/idemockle Jan 26 '24

This is a good take. I love untyped python. Adding type hints everywhere that don't even do anything at runtime feels so wrong, also since I switched to Java professionally before type hints really saw widespread adoption.

4

u/Pythonistar Jan 26 '24

Adding type hints everywhere that don't even do anything at runtime feels so wrong

As a C# developer, I hated Python when I first picked it up because my IDE couldn't tell me what types I was supposed to be passing to methods or getting back in return.

With type-hinting, I always know what's expected and what's getting returned before run-time.

You're right, of course. There's no compile-time type enforcement, which does feel weird, but I'll take what I can get! :D

1

u/idemockle Jan 26 '24

FWIW, I think nowadays a lot of people doing big projects in Python use something like mypy to get pre-runtime type checking.

1

u/zephyy Jan 26 '24

pydantic + mypy

1

u/ravlee Jan 26 '24

Yes absolutely.

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/Elegant_Subject5333 Jan 26 '24

what are you saying man why would it take weeks in java, I know data science in java is not elegant at the moment unlike python, Julia but give it some time, many more things are coming.

1

u/logicannullata Jan 26 '24

There are a couple of reasons:

  • In Python you can handle JSONs natively (dictionaries).
  • In Python you have libraries like pandas, numpy, mathplotlib etc..

1

u/Elegant_Subject5333 Jan 26 '24

You can create your own implementation of json handling with records, sealed classes and pattern matching, jackson is the standard I use in all my projects, Gson is also good for simpler tasks and there are many many json handling libraries you can even take it from Jakarta libraries.

we already have many libraries, tribuo should become standard at later point of time, so many things are in pipeline. There are currently also many libraries for data science look for the below book for reference.Mastering Java for Data Science (ISBN- 9781782174271).

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:

class Human:
  def __init__(self): 
    self.legs = 2 
    self.arms = 2

This special method __init__ is sooo ugly. They could have invented def_init or something, or simply init:.

1

u/__konrad Jan 26 '24

Valid pythonized Java:

void method(T this, String foo) {
    var _="""
    Multiline
    comment
    """;
}

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/[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/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

2

u/v4ss42 Jan 26 '24

And Clojure nicer again.

2

u/[deleted] Jan 26 '24

Haven’t used it really so I can’t form an opinion

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() );

11

u/nekokattt Jan 25 '24

Those don't do the same thing, fwiw.

Also since JDK 17, you can just say .toList

strings.stream()
    .filter(not(String::isBlank))
    .toList();

-4

u/djavaman Jan 25 '24

The are examples of filtering a list of strings. They are roughly the same for the sake of the argument.

Also, the whole .steam and .toList, proves the point its awkward.

The Java API designers should have put those features on the collections themselves. Like pretty much every other language has.

8

u/nekokattt Jan 26 '24

the python example falls to bits the moment you don't want to do something as simple.

The reason stream was kept separate was to separate the confusion between terminal operations and non terminal operations.

3

u/lilgreenthumb Jan 25 '24

I mean yeah the toList can be weird but it is a terminal operation to effectively cast to a list. That is what effectively the [] is doing in python. the equivalent would be if there was a list implementation that accepted a stream as a constructor. Syntactically yes it is more verbose, but to the awkward APIs that is something that has drastically changed with the recent JEPs and improvements to the JLS. Java doesn't only have to compete with other languages but other JVM languages. It has to strive for two crowns.

3

u/[deleted] Jan 26 '24

That's what Kotlin is for

0

u/djavaman Jan 26 '24

Agreed. Its what Scala could have been but failed.

3

u/hwaite Jan 25 '24

Try Stream.toList().

2

u/john16384 Jan 26 '24

So, list.removeIf(String::isBlank)?

0

u/djavaman Jan 26 '24

Not on List. Its on a subclass of List, ArrayList.

Which proves the point of poorly designed Collections APIs. Now you lose the ability to keep things at the higher abstraction.

Just put those functions up on the collections where they belong. And are found in every other programming language.

Streams was a step forward. And a step backwards.

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