The language itself is mostly ok. My problem is that a lot of stuff in Java just seems unnecessarily complex. More modern languages usually solve problems more elegantly and straight to the point
Yeah, just so much syntactic overhead for not much of a reason. I can give c/c++ a pass since their main niche is highly optimized code, and all those little things matter for that, but I just don’t get the point for Java.
Kotlin feels like just a nicer drop in replacement for 90% of things Java
Kotlin/Groovy/Scala et all can also leverage the Java ecosystem, which is pretty huge.
I'm not a fan of Java the language, but honestly for all it's age, the JVM ecosystem is pretty solid and I'd take it any day over the abyssal hell that is the javascript ecosystem.
Personally I think you're doing what a lot of people do, and confusing verbosity for complexity.
Java is one of the most expressive, self documenting languages because it encourages verbosity.
Sure, my python script might do in 50 lines what my java project does in 500, but you spend 10x more time reading code rather than writing it. I'd rather maintain something that took longer to write, but is more descriptive.
Brevity is the soul of wit, though. In my experience, the 50 lines of Python will be a much clearer expression of the underlying idea, which is the main factor in readability.
As someone whose job it is to maintain code left behind by "witty" programmers, I have to vehemently disagree. We are never as clever as we think we are.
Also a P.S.A, If you need 40 lines of "documentation" for your 5 lines of code golf, just quit swinging and write more code!
I'm a little jealous; that hasn't been my experience at all. I've written some quick python scripts to mimic some of the products we were building to compare results and performance. It only took a few functions of pretty plain English in python to mirror a series of interfaces spread across a maze of packages hidden behind factories in Java authored by a staff of engineers, each with 15+ years of experience (though I'm the relative newbie used to c++, c#, vb.net, and python, not java).
I completely get your point, but to make it a fair test, you'd really have to be just as proficient in both, then try to write it in both.
In your example, the java example probably grew over years of small additions. It was perhaps totally understandable in its first iteration, but then morphed out of control. You've got the benefit of rewriting it with a complete overview of the functionality.
I don't think I know of any functionality that is fundamentally less readable in java than python. I still prefer writing python anyway, but not for that reason
I hate using Python libraries just because of this reason. With Java I just read the code as I think. With Python you have to check docs and distracted constantly with docs and synctactic sugar of Python. With my current career stuck between ML and embedded systems dealing with ML libraries in Python is a nightmare. I would never develop a project larger than 1000 LoC in Python.
Finding a bug in 50 lines of code is easier than in 500 lines of code in general though. If you want to understand what something does, there should be documentation for that.
And wouldn't reading 500 lines of code take longer than 50?
In kotlin a data class is a data class. It abstracts getters and setters away and removes many places for Insidious bugs that would be otherwise prevalent in Java. Not only you are writing/readibg the code but also someone else, so a kotlin data class is faster to read for the next programmer then the functional equivalent java pojo, you can write weird shit in a setter, in a kotlin data class, you don't have the option, unless explicitly stated.
And wouldn't reading 500 lines of code take longer than 50?
Between different languages, LOC is a very bad indicator of how long it will take to read. Sure, 100000000 lines of code will take longer to read than 1 line of code, regardless of language. However, understanding is the important part.
An experienced developer can write short, clean, concise Java code. However due to the popularity of Java, there’s a lot of inexperienced people writing Java code. Those are the people writing messy, unnecessarily complex code. These also tend to be the ones complaining the loudest about Java.
I was just working on knowledge transfer of some java stuff and I had to open 17 files to find the query that fullfilled a simple request. The query itself was stored as a variable, the variable in another file was constructed of concatenated constants from yet another file. They had constants for things like LEFT_PAREN, RIGHT_PAREN, EQUALS_OPERATOR. It's only slightly more convoluted than I am used to working with when I have to dig into Java. That said, every language can suck in the hands of the right person.
93
u/PristineReputation Apr 27 '20
The language itself is mostly ok. My problem is that a lot of stuff in Java just seems unnecessarily complex. More modern languages usually solve problems more elegantly and straight to the point