Live data from Hacker News

All New Java Language Features Since Java 21

inside.java

121–130 of 130 posts

Re: All New Java Language Features Since Java 21

#121
post #30

After trying out many languages at many places, I reached the conclusion that Java, as weird as it may be, is my favorite language. There were times I hated it, but turns out I really just hated messy, over-engineered legacy code and working in a gray cubicle at aging MegaCorps. The language itself is quite beautiful when used properly and with modern features. It just really needs a makeover and better tools.

> The language itself is quite beautiful when used properly and with modern features.

> It just really needs a makeover and better tools.

I love java, wouldn't call it beautiful though. But I don't need a language to be beautiful, I need it to be pragmatic, blisteringly fast, have an extensive ecosystem and top quality tooling. Java delivers #1 on all of those so I love it.

For beauty, I like ruby and lisp, but those both fail on all the other criteria so they are mostly for hobby use for me. (Python, the darling of everyone these days, is pretty much dead last on every criteria except popularity.)

> better tools

I'd say Java & JVM has pretty much the best tooling on all fronts.

I can't think of anything that has better tooling around the language and runtime.

Re: All New Java Language Features Since Java 21

#122
post #46
post #41

Earlier quoted context omitted.

> is literally less readable Please point me to an objective measure of "readability" that holds for all people. And then demonstrate that your example is "literally" lower on that scale.

Readability was a term coined by people writing languages that are litterally unusable without an IDE to hide stuff when they render the source file to explain why refusing to learn languages with curly braces is sane.

Oh man.. that comment really hit deep. I'll never understand why people argue that it is "easier" to adopt invisible characters and exact tab positioning instead of just using braces or similar to mark the code blocks.

Drives me nuts because you really can only write code for those programs with an IDE that is prepared for the case. Try to edit the code directly from the github web interface and it won't compile.

Re: All New Java Language Features Since Java 21

#123

Earlier quoted context omitted.

Not if only one is the right one in all cases. In python you can also do s = set() s.add(1) s.add(2) and s = set(x for x in [1, 2]) But I wouldn't call that having three ways to do the same. Disclaimer: I don't know java well, just commenting based on the comments above and my python knowledge.

In python, those give a mutable set, which is what I was referring to above. Also not to put too a fine a point, you'll never see python code like that in the wild, but even in code reviews these days, it's common to find Java code written like in my example because the syntax for sets in Java came after Java 8

Thanks for specifying, as I said I'm not a java programmer. I stand corrected.

>it's common to find Java code written like in my example because the syntax for sets in Java came after Java 8

So I think we went full circle back to GP claim:

> The language itself is quite beautiful when used properly and with modern features

:)

Re: All New Java Language Features Since Java 21

#124

Earlier quoted context omitted.

Programming language is a tool. Java developers value stability and ease of understanding for the code. I've seen the nice features you complain that don't get used, reality is that nobody wants to waste time knowing them unless they are intuitive to use. Especially when are forcing to use newer JDKs. There is no value in solving a challenge in a way that only you understand or make others lose time trying to underst…

> You mention "var", why would we ever want in Java to hold a variable that you can't read immediately what is the type? I've been a full time java developer for the past 7 years. Let me start by agreeing that I have very little interests in the functional "innovations" they added. They're fine, but most of my colleagues agree that code using streams or lambdas very quickly becomes harder to debug then if you just wr…

Yes, please don't get me wrong. There are always a few good things, but like you mention with streams: the person writing it can have an idea of what he was doing but the others afterwards will struggle to make changes and will likely revert the code base to simpler code.

Switch statements got better. I'm also getting used to Paths albeit don't yet understand why File wasn't already good enough. It is difficult to find compelling reasons for upgrading the JDK since I know it will be hassle for everyone that later down the line has to install/run the product.

Re: All New Java Language Features Since Java 21

#125

Earlier quoted context omitted.

Programming language is a tool. Java developers value stability and ease of understanding for the code. I've seen the nice features you complain that don't get used, reality is that nobody wants to waste time knowing them unless they are intuitive to use. Especially when are forcing to use newer JDKs. There is no value in solving a challenge in a way that only you understand or make others lose time trying to underst…

> why would we ever want in Java to hold a variable that you can't read immediately what is the type I can use my IDE to see the type if necessary. > Everything that came after isn't really memorable nor helpful, There are several improvements that are very helpful One example is how multi line strings help me to read more clearly without the unnecessary string concatenations: var sql = """ SELECT foo FROM bar WHERE…

You could have as easily used String instead of var and there would be no ambiguity. This gets worse for numbers where it is important to know if you are dealing with an integer, long or something even bigger.

I agree with you on switches and do like the """ feature, thought. It was a real pain in the rear to include the multiple + "\n" back in the old days. This is a very clean and intuitive improvement.

Re: All New Java Language Features Since Java 21

#126
post #69

Earlier quoted context omitted.

I agree, and I'm not sure how something like 'var accounts = calculateAccounts(something)' can be thought of as better in a code review setting. I suspect using "var" or equivalent will be considered a problem by most companies within the next few years.

This experiment has already been run with pretty much every language that isn’t Java or C, and I think most people have been ok. Yes, code review is arguably worse, but most people who write Java do so with an IDE and the type is never unknown at that point. Also, if your function is big enough to where the type of var is not very clear, it likely shouldn’t be passing code review regardless.

Those writing in python and javascript don't honestly know any better. They grew in a world without unit testing or without products that need to grow into gigantic systems maintained over the next decades.

This reminds me of a developer writing in jRuby because "it was better". While he was in the company he'd still give support to his own works, after leaving nobody else wanted to pickup those "better" things and would prefer to write workarounds to the tool, it effectively became a black box that few could improve and even worse to test. As result, those portions had to be rewritten in proper Java so that we'd be able to deeply measure/test and improve.

Never again.

Re: All New Java Language Features Since Java 21

#127
post #46

Earlier quoted context omitted.

Readability was a term coined by people writing languages that are litterally unusable without an IDE to hide stuff when they render the source file to explain why refusing to learn languages with curly braces is sane.

Oh man.. that comment really hit deep. I'll never understand why people argue that it is "easier" to adopt invisible characters and exact tab positioning instead of just using braces or similar to mark the code blocks. Drives me nuts because you really can only write code for those programs with an IDE that is prepared for the case. Try to edit the code directly from the github web interface and it won't compile.

Whoops, my initial intent was "without curly braces", since that's where most of the readability comments are from. I guess the comment works both ways, though.

> Drives me nuts because you really can only write code for those programs with an IDE that is prepared for the case.

Usually people have strict rules for that (e.g. pep8), and most text editors will do it for you with little configuration.

Re: All New Java Language Features Since Java 21

#128
post #119
post #117

Earlier quoted context omitted.

Scala definitely had some missteps but its much nicer to program in than Java and simpler as well. I mainly program in Go these days but I could imagine explaining the benefits of Scala over Go to my coworkers. It would be embarrassing trying to do the same with Java however.

I don’t think anyone I know would classify Scala as simpler. In my opinion Java is a much better language than Go. I can’t imagine anyone liking Scala would prefer it over Java.

Having coded in Java for 15 years and Go for five, I can say that Go is clearly the better language for most tasks.

Re: All New Java Language Features Since Java 21

#129
post #128
post #119

Earlier quoted context omitted.

I don’t think anyone I know would classify Scala as simpler. In my opinion Java is a much better language than Go. I can’t imagine anyone liking Scala would prefer it over Java.

Having coded in Java for 15 years and Go for five, I can say that Go is clearly the better language for most tasks.

That's just like your opinion man. Mine is that its far too verbose and error prone.

Re: All New Java Language Features Since Java 21

#130
post #30

After trying out many languages at many places, I reached the conclusion that Java, as weird as it may be, is my favorite language. There were times I hated it, but turns out I really just hated messy, over-engineered legacy code and working in a gray cubicle at aging MegaCorps. The language itself is quite beautiful when used properly and with modern features. It just really needs a makeover and better tools.

it consistently works and has a huge ecosystem, but "beautiful" is never a word I would use to describe java. off the top of my head: * no type level concept of a const object (ie, you can have a const reference to a List, but never a reference to a const list). this makes const-ness an implementation detail of the class itself! so frustrating that List:add() can throw depending on the underlying class. * lack of tup…

The missing constness is the biggest flaw of them all, in my opinion, especially when reading other people's code. Always having to dig deep to make sure an object isn't altered somewhere down the line gets old really quick.
Post reply on HN