News for hackers. Stuff that matters.
Re:Java 18 / JDK 18: General Availability by munificent on Tuesday March 22, 2022 @12:42PM (#30768339)
I think it's a combination of four things:

1. GC is an enormous productivity improvement for applications whose performance characteristics can afford it. Seriously, I can't think of a single programming language feature/concept/technology that makes a bigger difference in developer velocity than memory safety and GC.

2. Static types are also a large productivity improvement for developers comfortable using them and the kinds of projects that benefit from them (large, multi-dev, multi-year).

3. Imperative and object-oriented. Java is imperative in the small, which is familiar to most developers and seems to strike a balance of letting developers write correct code with good performance. Java is OOP in the large and for many classes of applications, that's been a wildly successful way of organizing code and lowering the cognitive overhead.

4. Path dependence. The past largely determines the present. We don't reset all of our technology choices and start from scratch at the beginning of each fiscal quarter, so the languages that were widely used tend to stay the languages widely used.

Java was the first heavily engineering and marketed language that featured GC, static types, and OOP, so it got big and continues to stay big.

I also think it's a pretty decent language. The things people don't criticize about Java are mostly complaints about a certain style of programming in the 90s and less the language itself.

Re:Java 18 / JDK 18: General Availability by paulmd on Tuesday March 22, 2022 @05:23PM (#30771743)
> I also think it's a pretty decent language. The things people don't criticize about Java are mostly complaints about a certain style of programming in the 90s and less the language itself.

(assuming that's a typo there, the things people don't like/the things people criticize?)

I disagree on that point, I think the language itself was a problem. Java 6 and prior were very very verbose and very very slow. I think that really changed with JDK 7/8, but the java we know today isn't the java of the 90s.

Even then, to some extent that problem hasn't gone away, it's just been papered over with frameworks and library code. Like honestly even as a java dev, I couldn't tell you off the top of my head the exact code to open a file, read each of the lines, and then close everything, or the right way to open a JNP connection to RabbitMQ or something. Anything touching files or sockets is still an absolute nightmare of boilerplate code, inputstreams, filestreams, printwriters, try/catch, and mother. fucking. IOException. thrown everywhere. But you don't care, because you just call Apache commons-io or Spring RestTemplate.

And that has contributed to some criticism of its own. Spring tends to turn into architecture-astronaut crap, like everyone's favorite AbstractSingletonProxyFactoryBean.

> Java was the first heavily engineering and marketed language that featured GC, static types, and OOP, so it got big and continues to stay big.

The other quiet boost that people don't talk about is Android. Tons of libraries get written with the intent of being used in some android app somewhere, but you can use that equally much on desktop/server. It really really helps the rapid-prototyping aspect of Java that ~half the smartphones in the world are running Android.

Re:Java 18 / JDK 18: General Availability by vips7L on Tuesday March 22, 2022 @05:48PM (#30772004)
> exact code to open a file, read each of the lines, and then close everything

    var lines = Files.lines(Paths.get("file.txt"));
or if you want to be extremely cautious:

    try (var lines = Files.lines(Paths.get("file.txt"))) {

    }

I agree about IOException though. It's the bane of my existence :) The amount of times I have to rethrow UncheckedIOException is far too high.
Re:Java 18 / JDK 18: General Availability by munificent on Tuesday March 22, 2022 @06:50PM (#30772641)
> (assuming that's a typo there, the things people don't like/the things people criticize?)

Oops, yes, sorry.

> Java 6 and prior were very very verbose and very very slow.

It's kind of verbose, when looking at it from today's perspective, but at the time I didn't think it was that bad. I think they deliberately tried to be less cryptic and more wordy than C/C++ (which can often be impenatrable). I think they overcorrected for that, but I don't think the language is interolerably verbose.

Performance was definitely bad until Lars Bak and company showed up and wrote HotSpot. But almost every managed language at the time had poor performance. It was certainly painfully slow compared to C and C++ but... what wasn't?

> I couldn't tell you off the top of my head the exact code to open a file, read each of the lines, and then close everything, or the right way to open a JNP connection to RabbitMQ or something.

I mean, I couldn't tell you how to do that off the top of my head in just about any language. Except C. But, of course, the code I would write for C off the top of my head is simple and wrong because it doesn't handle all of the various ways IO can fail.

Networking and file systems are honestly just kind of grungy. You can paper over it with simple APIs but what you end up with is code that looks pretty but can fail in obscure ways.

> try/catch, and mother. fucking. IOException. thrown everywhere.

Yeah, checked exceptions were simply a mistake. I don't fault them for trying to fit exceptions into the static type system. It was a cool, ambitious idea. At the time, no one really had a sense of how the ecosystem would settle around using exceptions. In practice, it ended up being more trouble than it's worth.

> The other quiet boost that people don't talk about is Android.

Android is definitely keeping it popular these days, but Java was huge because of server development before Android came along.

Re:Java 18 / JDK 18: General Availability by igouy on Wednesday March 23, 2022 @01:49PM (#30781218)
> But almost every managed language at the time had poor performance.

Slow compared to Smalltalk. Slow compared to Lisp.

Re:Java 18 / JDK 18: General Availability by munificent on Wednesday March 23, 2022 @02:47PM (#30781841)
Depends on which implementations you're talking about.

But even fast Smalltalks weren't very fast relative to C, just relative to most other dynamic languages. And, of course, the people who made Smalltalk fast ended up making Java even faster.

Re:Java 18 / JDK 18: General Availability by igouy on Thursday March 24, 2022 @11:28AM (#30791238)
> relative to C

Seemed like you'd shifted your comparison to "almost every managed language."

So Java at-the-time compared to Smalltalk and Lisp at-the-time.

I suppose Haskell at-the-time, OCaml at-the-time :-)

Re:Java 18 / JDK 18: General Availability by munificent on Thursday March 24, 2022 @05:31PM (#30795575)
I did say "almost every" and not "every". :)

Were there fast managed languages? Yes, a couple.

Were there fast managed object-oriented languages? Yes, Self and a Smalltalk or two.

Were there fast managed statically typed languages? Yes, SML and Haskell.

Where there fast, managed, statically typed, and object-oriented languages? Not many. Maybe Eiffel, but that was shackled by DbC dogmatism and probably some amount of Eurocentricity. I don't think Ada had GC back then and if your complaint is that Java is too verbose, you sure as heck aren't gonna like Ada.

Re:Java 18 / JDK 18: General Availability by igouy on Wednesday March 23, 2022 @02:07PM (#30781438)
> Java was the first heavily…

Free-as-in-beer?