Hacker News new | ask | show | jobs
by delusional 285 days ago
> 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 wrote the code with loops and.

That's far from true for every java feature though. Switch statements have been super cool, Green threads are a promising road out of the CompletionStage hell the children are dreaming of these days. "var" is a very nice way to reduce double typing ("Thing x = new Thing()" -> "var x = new Thing()") and also a nice way to avoid changes to unrelated files ("Thing x = getFoo(); f(x);" -> "var x = getFoo(); f(x)" means changing the name of class Thing doesn't require any change to the code) that's been helpful in a lot of cases.

1 comments

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.