News for hackers. Stuff that matters.
Re:Java at 30: The Genius Behind the Code That Changed Tech by cogman10 on Friday May 16, 2025 @11:17AM (#44006504)
Let me extol the virtues of Java the language.

You can take pretty much any code written for Java 1.0 and you can still build and run it on Java 24. There are exceptions (sun.misc.Unsafe usage, for example) but they are few and far between. Moreso than nearly any other language backwards compatibility has been key to java. Heck, there's a pretty good chance you can take a jar compiled for 1.0 and still use it to this day without recompiling it.

Both Ruby and Python, with pedigrees nearly as old as Java's, have made changes to their languages which make things look better, but ultimately break things. Heck, C++ tends to have so many undefined quirks and common compiler extensions that it's not uncommon to see code that only compiles with specific C++ compilers.

Re:Java at 30: The Genius Behind the Code That Changed Tech by brightball on Friday May 16, 2025 @11:56AM (#44006953)
That is an excellent point too.

It always made me wonder why I hear about companies who are running very old versions of Java though. It always seemed like backwards compatibility would make keeping up to date with the latest an almost automatic thing.

Re:Java at 30: The Genius Behind the Code That Changed Tech by fpoling on Friday May 16, 2025 @04:24PM (#44009493)
Java version updates typically change GC behavior. If one has highly tuned setup there is no guarantee that a newer version would not regress.

Another problem is crashes. Java runtime is highly reliable, but still bugs happens.

Re:Java at 30: The Genius Behind the Code That Changed Tech by Pet_Ant on Friday May 16, 2025 @08:07PM (#44010910)
Are you talking about performance or behaviour? I’ve never seen an issue caused by a GC.
Re:Java at 30: The Genius Behind the Code That Changed Tech by fpoling on Saturday May 17, 2025 @04:15AM (#44012852)
Latency spikes are the issue. Modern Java mostly solved this, but tuning GC settings is still the thing especially when Java runs on a big server.
Re:Java at 30: The Genius Behind the Code That Changed Tech by josefx on Saturday May 17, 2025 @06:04AM (#44013254)
It is "mostly" backwards compatible. Applets and everything related to them where dropped. A few interface dependencies where changed to improve modularity of the runtime. Widely used hacks like sun.misc.unsafe are getting replaced with official APIs and locked down. Development of some Java EE packages has been taken over by a third party, so they are no longer packaged within the java namespace. To name just a few of the bigger examples.
Re:Java at 30: The Genius Behind the Code That Changed Tech by kamma4434 on Saturday May 17, 2025 @01:00PM (#44015568)
It is - but you don’t want to find out that something broke because of odd JVM update. If it ain’t broken…
Re:Java at 30: The Genius Behind the Code That Changed Tech by jsight on Friday May 16, 2025 @11:32AM (#44006688)
Yeah, that and the portability are really incredible and underrated. It is funny, because I constantly hear things like "write once, debug everywhere", but I have yet to see an alternative that has a higher probability of working everywhere.

Although Python is pretty close, if you exclude Windows (and don't we all want to do that?).

Re:Java at 30: The Genius Behind the Code That Changed Tech by cestith on Friday May 16, 2025 @12:11PM (#44007129)
I can run basically any Perl code back to Perl 4 (March 1991) on Perl 5.40.2 which is current. I can run the same code on DOS, BeOS, Amiga, Atari ST, any of the BSDs, Linux distros, macOS, OS X, Windows, HP/UX, SunOS, Solaris, IRIX, OSF/1, Tru64, z/OS, Android, classic Mac, and more.

This takes nothing away from Java and the Java ecosystem though. The JVM allows around the same number of target systems to run not one language but dozens. There’s JRuby, Jython, Clojure, Scala, Kotlin, jgo, multiple COBOL compilers that target JVM, Armed Bear Common Lisp, Eta, Sulong, Oxygene (Object Pascal IIRC), Rakudo (the main compiler for Perl’s sister language Raku) can target JVM, JPHP, Renjin (R), multiple implementations of Scheme, Yeti, Open Source Simula, Redline (Smalltalk), Ballerina, Fantom, Haxe (which targets multiple VM backends), Ceylon, and more.

Perl has a way to inline other languages, but is only really targeted by Perl and by a really ancient version of PHP. The JVM is a bona fide target for so many. Even LLVM intermediate code has a tool to target the JVM, so basically any language with an LLVM frontend. I wouldn’t be surprised if there’s a PCode to JVM tool somewhere.

JavaScript has a few languages targeting it. WebAssembly has a bunch and growing, including C, Rust, and Go. That’s probably the closest thing to the JVM.

Re:Java at 30: The Genius Behind the Code That Changed Tech by sigzero on Friday May 16, 2025 @04:05PM (#44009322)
> I can run THE SAME CODE on DOS, BeOS, Amiga, Atari ST, any of the BSDs, Linux distros, macOS, OS X, Windows, HP/UX, SunOS, Solaris, IRIX, OSF/1, Tru64, z/OS, Android, classic Mac, and more.

No, you really can't. Not anything significant anyway. There are too many deviations between some of those systems to all you to run the same code.

Re:Java at 30: The Genius Behind the Code That Changed Tech by maxlybbert on Friday May 16, 2025 @04:25PM (#44009506)
Honestly, the main difference I run into is just file paths, and that’s easy to sidestep ( https://perldoc.perl.org/File::Spec ).

There are differences, but they’re usually esoteric ( https://perldoc.perl.org/perlport#PLATFORMS ).

Re:Java at 30: The Genius Behind the Code That Changed Tech by cestith on Tuesday May 20, 2025 @03:11PM (#44044848)
Yes, I really can, and with the same number or fewer OS-specific checks than the equivalent C program.
Re:Java at 30: The Genius Behind the Code That Changed Tech by vram22 on Friday May 16, 2025 @05:18PM (#44009887)
Interesting about that long list of languages.

There's also Groovy.

I wonder what other languages run on the JVM. What about Perl, Icon, SNOBOL, Prolog, Forth, Rexx, Nim, MUMPS, Haskell, OCaml, Ada, Rust, BASIC, Rebol, Haxe, Red, etc.?

Partly facetious question, because I think there are some limitations in some cases that prevent it (not sure, but a language being too closely tied to Unix or hardware could be why), but also serious. Since the JVM platform has all that power and performance, some of these languages could benefit from that, I'm guessing.

#lazyweb

Re:Java at 30: The Genius Behind the Code That Changed Tech by dmit on Saturday May 17, 2025 @05:25AM (#44013130)
> Haskell

https://github.com/Frege/frege

https://github.com/typelead/eta

Of the others you mentioned, I bet there's a couple JVM Prologs out there, but haven't encountered any myself.

Re:Java at 30: The Genius Behind the Code That Changed Tech by vram22 on Friday May 23, 2025 @04:12PM (#44076209)
Thanks.

I briefly looked at Frege; both it and the person it is named after are very interesting.

https://en.m.wikipedia.org/wiki/Gottlob_Frege

Re:Java at 30: The Genius Behind the Code That Changed Tech by vram22 on Wednesday May 28, 2025 @07:12PM (#44121438)
So I submitted HN posts about both of them:

https://news.ycombinator.com/item?id=44112115

https://news.ycombinator.com/item?id=44076220

Full speed ahead, and damn the naysayers, er, downvoters, er, torpedos! ;)

https://en.m.wikipedia.org/wiki/David_Farragut

Re:Java at 30: The Genius Behind the Code That Changed Tech by cestith on Tuesday May 20, 2025 @04:29PM (#44045584)
I mentioned Haxe by name, and Eta is essentially Haskell on JVM.

There is an OCaml-Java. NetRexx targets the JVM. For Prolog there are JIProlog and TuProlog at least.

Red basically is REBOL. Yes, Red targets IA-32, ARM, JVM, AVM2, x64, and the CLR.

I’ve seen some experiments for running Perl on the JVM. Rakudo can target the JVM for Raku, which is Perl’s sister language.

For Ada, gnat can target the JVM. https://docs.adacore.com/gnatvm-docs/jgnat_ug.html

For Forth there are a number of implementations. JVMForth, jForth, Misty Beach Forth, HolinJ Forth, bjforth, and xforth at least.

I’ve seen a couple different Java libraries for SNOBOL-style matching but I’ve never seen a SNOBOL tool that targets the JVM.

MUMPS has M4J.

Rust is interesting. There are JVMs written in Rust. There’s support for the JNI for Rust for interoperability. I’m not aware of a JVM target for Rust, though. However, Rust still uses LLVM as its primary code generator. As I mentioned, there are LLVM IC to JVM compilers.

Basic isn’t really a single language. For something like MS Visual Basic, there’s Jabasco. There’s JVMBasic. MBC transpiles Basic to C or C++, so you could use clang to put its output on the JVM. PuffinBASIC is a Basic interpreter written in Java. GLBasic compiles to C++, so again with LLVM all things are possible here. BCX Basic also outputs C or C++. There’s something just called “BASIC Compiler” that is both written in Java and compiles its source to JVM bytecode. The basgo compiler outputs Go code, so anywhere you can target golang code you can target Basic code with basgo, including the JVM. I’m sure there are a lot more. These are different versions of Basic on the source side, some of them similar to one another.

Nimlvm is a Nim compiler to LLVM intermediate code. So once again, as a chain of steps it can be done.

Speaking of chaining translators/transpilers/compilers, did I mention there’s a WebAssembly to JVM compiler? There are actually more than one. Chicory is one and asmble is another. There’s something called “Happy New Moon with Report”. There’s also a WASM written in Scala called Swam. I’m sure I’m missing some.

So the huge and growing list of languages that target WASM can also be chain-translated to target the JVM. That includes C, Rust, Nim, TypeScript, C++, Forth, Go, F#, Lua, Zig, and more. https://wasmlang.org/

So if it targets the JVM, it can run on the JVM. But also if it targets WebAssembly, C, C++, LLVM IC, Lua, Go, and more it can also through other tools target the JVM. Or if it has an interpreter that runs on the JVM because it’s written in Java, Scala, Clojure, or some other language you can get it there. If you really want to get exotic and esoteric, there’s an x86 emulator in WASM out there and you could probably run that on one of the JVM WASM interpreters.

Re:Java at 30: The Genius Behind the Code That Changed Tech by vram22 on Friday May 23, 2025 @04:20PM (#44076277)
Thanks. That's a lot of interesting stuff to check out!
Re:Java at 30: The Genius Behind the Code That Changed Tech by dotancohen on Friday May 16, 2025 @06:11PM (#44010221)

  > I can run basically any Perl code back to Perl 4 (March 1991) on Perl 5.40.2 which is current.
Yes, but can you _read_ it?

I'm only half joking. Perl has so many ways to do things, many of them obscure but preferable for specific cases. It's often a write-only language if you can't get ahold of the dev who wrote whatever script you're trying to debug.

I wonder if modern LLMs could actually help with that.

Re:Java at 30: The Genius Behind the Code That Changed Tech by johnisgood on Friday May 16, 2025 @06:31PM (#44010345)
> I wonder if modern LLMs could actually help with that.

From experience, they can.

Re:Java at 30: The Genius Behind the Code That Changed Tech by fuzztester on Friday May 16, 2025 @09:38PM (#44011388)
>Yes, but can you _read_ it?

Java was marketed (at least in its early days) as a WORA language - WRITE ONCE RUN ANYWHERE.

Perl was unmarketed as a WORM language - WRITE ONCE READ MANY (TIMES). ;)

jk, i actually like perl somewhat.

but I think Larry and team went somewhat overboard with that human-style linguistics stuff that they applied to perl.

Re:Java at 30: The Genius Behind the Code That Changed Tech by cestith on Tuesday May 20, 2025 @03:09PM (#44044836)
I can. Some of it by some developers I can read far more easily than others.

Can you read arbitrary code written by developers from around the world in PL/1, or Ada, Forth, APL, or even C++? Big languages have lots of syntax choices, yes. It doesn’t need to be abused.

Even C has an obfuscated code contest that’s been going on for decades.

Re:Java at 30: The Genius Behind the Code That Changed Tech by invalidname on Friday May 16, 2025 @12:16PM (#44007192)
I just spent 30 minutes trying to get a python package running on my Mac... Not feeling that. Pythons version compatibility is just awful and the mix of native is deeply problematic. Don't get me started on tooling and observability.
Re:Java at 30: The Genius Behind the Code That Changed Tech by bhaak on Friday May 16, 2025 @11:56AM (#44006959)
I often run into problems running Python code under Linux.

I don’t know if it is a me problem or if I’m missing the right incantations to set up the environment or whatever. Never had that much problems with Java.

But I’m a Java and Ruby person so it might really be missing knowledge.

Re:Java at 30: The Genius Behind the Code That Changed Tech by cestith on Friday May 16, 2025 @12:12PM (#44007153)
Python can be tricky with the big differences between 2 and 3.
Re:Java at 30: The Genius Behind the Code That Changed Tech by loloquwowndueo on Friday May 16, 2025 @04:00PM (#44009279)
Python 3 came out in 2008. If the 2 vs 3 differences are still biting you you probably have bigger problems to solve (deprecated, insecure, unmaintained dependencies for example).
Re:Java at 30: The Genius Behind the Code That Changed Tech by coolcase on Saturday May 17, 2025 @04:21AM (#44012872)
And IPv6 came out in 1995
Re:Java at 30: The Genius Behind the Code That Changed Tech by loloquwowndueo on Saturday May 17, 2025 @09:00AM (#44013991)
Your point?
Re:Java at 30: The Genius Behind the Code That Changed Tech by coolcase on Saturday May 17, 2025 @04:26PM (#44016756)
"Comes out" and "Ready to switch to" are two different things.

Your conclusion is correct but not because Python 3 came out in 2008. It was ready to switch to some point a few years later but we'll before 2025 (I don't recall when sorry I didn't do Python at the time!)

Re:Java at 30: The Genius Behind the Code That Changed Tech by icedchai on Friday May 16, 2025 @04:11PM (#44009385)
As late as 2022, I was at a company still in the middle of "migrating" from 2 to 3. I wouldn't be surprised if the migration project was still going on. The system had gone beyond tech debt and was bordering on bankruptcy.
Re:Java at 30: The Genius Behind the Code That Changed Tech by jonhohle on Friday May 16, 2025 @12:45PM (#44007475)
For anything more than just a one off script, look into venv. I’ve not written any python until this past year and can’t imagine maintaining an ongoing project without it.

Prior to that I would frequently have issues (and still have issues with one-off random scripts that use system python).

Re:Java at 30: The Genius Behind the Code That Changed Tech by kevin_thibedeau on Friday May 16, 2025 @04:11PM (#44009378)
It's not you. Python packaging has regressed into a worse mess than it was 20 years ago. I limit myself to simple scripts that only rely on builtins. Anything more complicated goes to a more dependable language.
Re:Java at 30: The Genius Behind the Code That Changed Tech by icedchai on Friday May 16, 2025 @06:44PM (#44010444)
I rarely run into issues when using Poetry. If you use pip, add packages to requirements.txt willy-nilly and don't pin versions then you are asking for trouble.
Re:Java at 30: The Genius Behind the Code That Changed Tech by myko on Friday May 16, 2025 @09:45PM (#44011417)
i like poetry though i've moved to uv - both work really well
Re:Java at 30: The Genius Behind the Code That Changed Tech by icedchai on Friday May 16, 2025 @10:58PM (#44011708)
I've heard great things about uv. I plan to try it for my next project.
Re:Java at 30: The Genius Behind the Code That Changed Tech by bornfreddy on Saturday May 17, 2025 @12:18AM (#44012013)
I use pipenv and it kind-of-works. Will try uv or poetry though - which one would you recommend?
Re:Java at 30: The Genius Behind the Code That Changed Tech by dwood_dev on Saturday May 17, 2025 @01:50AM (#44012310)
UV. Using it as the exec target for python (UV script) is great. Dependencies declared at the top, now I have executable files in something better than bash.

I no longer shy away from writing <500 LOC utility/glue scripts in python thanks to uv.

Re:Java at 30: The Genius Behind the Code That Changed Tech by myko on Saturday May 17, 2025 @11:00PM (#44018681)
I can't recommend uv enough. It's so fast, and uvx is so useful to run a random Python CLI tool. If you want to do things like you're accustomed to with pip you just `uv pip ...`
Re:Java at 30: The Genius Behind the Code That Changed Tech by LtWorf on Saturday May 17, 2025 @01:37AM (#44012264)
Poetry doesn't fix the fact that python removes modules from the standard library every release.
Re:Java at 30: The Genius Behind the Code That Changed Tech by icedchai on Saturday May 17, 2025 @06:32PM (#44017523)
I've never run into that.
Re:Java at 30: The Genius Behind the Code That Changed Tech by LtWorf on Sunday May 18, 2025 @11:20AM (#44022027)
Doesn't mean the problem doesn't exist.
Re:Java at 30: The Genius Behind the Code That Changed Tech by fuzztester on Friday May 16, 2025 @09:45PM (#44011416)
what languages do you use for the latter?
Re:Java at 30: The Genius Behind the Code That Changed Tech by fuzztester on Friday May 16, 2025 @09:50PM (#44011445)
I don't know about the difference between 20 years ago versus now, but it's certainly doesn't seem to be clear now.

e.g. poetry, venv and pyenv have been mentioned in just the next few comments below yours. and this is just one example. i have seen other such seeming confusion and different statements by different people about what package management approach to use for python.

Re:Java at 30: The Genius Behind the Code That Changed Tech by jsight on Friday May 16, 2025 @05:20PM (#44009895)
Honestly, it isn't just you. I had to hold off on 3.13 for quite a while too, because of various package conflicts. It isn't terrible, especially thanks to things like pyenv, but it is far from perfect.
Re:Java at 30: The Genius Behind the Code That Changed Tech by cbm-vic-20 on Friday May 16, 2025 @11:45AM (#44006821)
I've got a jar that does one small thing and does it well that was compiled in 1998. Still works fine, no reason to update it.
Re:Java at 30: The Genius Behind the Code That Changed Tech by eppp on Friday May 16, 2025 @04:03PM (#44009308)
I know that what you said is supposed to be true. However in my real world experience it is anything but. Cisco java programs are a disaster and require certain JVMs to run.
Re:Java at 30: The Genius Behind the Code That Changed Tech by aaronbaugher on Friday May 16, 2025 @05:14PM (#44009871)
The enterprise Java applications we use require specific versions of specific Linux distros. It's possible that they would run on other distros, or even other operating systems, if you got the right JVM. But there's enough question about it that the companies that sell them for a substantial price aren't willing to promise even a little portability.
Re:Java at 30: The Genius Behind the Code That Changed Tech by fpoling on Friday May 16, 2025 @04:44PM (#44009663)
I have C++ code from 1997 that I occasionally compile. So far it runs. 10 yeas ago compiling with -Wall exposed an inconsequential bug and that was it. I suspect when it stops to compile it will be from an absence of a particular X11 library that I used to parse a config in otherwise command-line utility.

Which also points to another thing where Java compatibility shines. One can have a GUI application that is from nineties and it still runs. It can be very ugly especially on a high DPI screen, but still one can use it.

Re:Java at 30: The Genius Behind the Code That Changed Tech by AnimalMuppet on Friday May 16, 2025 @05:07PM (#44009839)
That's not the virtues of Java the language. That's the virtues of Java the backward-compatible platform. That is, you didn't say anything about the language (syntax and semantics), you only talked about backward compatibility.

(It's still a valid point. It's just not the point you labeled it as.)

Re:Java at 30: The Genius Behind the Code That Changed Tech by cogman10 on Sunday May 18, 2025 @09:52AM (#44021418)
The language also follows the backwards compatibility principles. Java hasn't, for example, added new keywords in a backwards incompatible way. You can, for example, have something like

    int record = 1;
    double var = 2;
even though `var` and `record` are now used to create and define things.
Re:Java at 30: The Genius Behind the Code That Changed Tech by worik on Friday May 16, 2025 @06:00PM (#44010152)
I have been badly burned, twice, by Python's cavalier attitude to backwards compatibility
Re:Java at 30: The Genius Behind the Code That Changed Tech by vaylian on Saturday May 17, 2025 @03:07AM (#44012568)
Python "the language" or Python "the ecosystem"?
Re:Java at 30: The Genius Behind the Code That Changed Tech by worik on Saturday May 17, 2025 @06:44PM (#44017578)
The language?

I am a mere user. I have two Python based systems that worked in Debian 11 and not in Debian 12

Python 3.9 to 3.11 I think was the change.

A

Re:Java at 30: The Genius Behind the Code That Changed Tech by johnisgood on Friday May 16, 2025 @06:28PM (#44010332)
> You can take pretty much any code written for Java 1.0 and you can still build and run it on Java 24.

This is not my experience with Java at all. I very often have to modify $JAVA_HOME.

Re:Java at 30: The Genius Behind the Code That Changed Tech by winrid on Friday May 16, 2025 @07:07PM (#44010607)
Are you using Gradle projects? Gradle is especially difficult for some reason.
Re:Java at 30: The Genius Behind the Code That Changed Tech by johnisgood on Friday May 16, 2025 @07:12PM (#44010628)
Sadly. I would rather avoid Gradle and Java in general. I did not have good experiences with them. :/
Re:Java at 30: The Genius Behind the Code That Changed Tech by thomashabets2 on Saturday May 17, 2025 @02:38AM (#44012452)
I have the exact opposite experience. I haven't coded much Java, but when I tried to revisit it, code I wrote 10 or 20 years ago doesn't even remotely compile anymore. While with C++, 20 years later you may need to add a missing #include (that you were always supposed to have), but then it just works as it always has.

Java is, in my opinion, a complete mess. And I think it's weird how anybody could like it past the 1990s.

C++ not being compilable later hasn't been true since pre standard C++. We're talking 1980s now.

https://blog.habets.se/2022/08/Java-a-fractal-of-bad-experim...

Re:Java at 30: The Genius Behind the Code That Changed Tech by KronisLV on Saturday May 17, 2025 @01:37PM (#44015773)
> Moreso than nearly any other language backwards compatibility has been key to java.

The Java 8 and 8+ divide very much works against this. It was a needed change (much like Python 2 vs 3) but nowhere near pleasant, especially if some of your dependencies used the old Java packages that were removed in, say, OpenJDK 11.

Furthermore, whenever you get the likes of Lombok or something that has any dynamic compilation (I recall Jaspersoft having issues after version upgrade, even 7 to 8 I think), or sometimes issues with DB drivers (Oracle in particular across JDK versions) or with connection pooling solutions (c3p0 in particular), there's less smooth sailing.

Not to say that the state of the ecosystem damns the language itself and overall the language itself is pretty okay when it comes to backwards compatibility, though it's certainly not ideal for most non-trivial software.

Re:Java at 30: The Genius Behind the Code That Changed Tech by cogman10 on Sunday May 18, 2025 @09:48AM (#44021404)
The Java 9 change was to remove access to unofficial APIs.

I agree it was somewhat painful, but not nearly to the level of the 2->3 change which ended up changing python syntax. Most dependencies worked throughout the change and still work.

> Furthermore, whenever you get the likes of Lombok or something that has any dynamic compilation ... there's less smooth sailing.

Not sure about c3p0, but Lombok goes out of it's way to inject itself into javac internals in order to make it's output changes. It's using the most internal of internal code in order to make that @Getter annotation work. Plenty of other annotation processing APIs are completely unaffected by javac updates because they choose not to use internal APIs. Immutables, Autovalue, dagger2, all examples of dynamic compilation that continue to work regardless the version of java. Lombok is a horrible little dependency that I wish people would abandon. It's making a mess and then complaining that it's somehow Java's fault because Lombok decided it needed access to the AST.

I get it, things have broken. But what has been broken is literally the undefined and non-public APIs which went so far as to call their packages things like `sun.misc.unsafe` just to try and ward off people from using these APIs. (With the javadocs to boot which told people not to use this).

And even with the break, the Java devs went out of their ways to make stand-in apis.

Re:Java at 30: The Genius Behind the Code That Changed Tech by int_19h on Sunday May 18, 2025 @05:37AM (#44020134)
The counter-example to this is C#. Barely younger than Java (by 5 years), and starting its life as mostly a Java clone with a sprinkle of Delphi, it evolved much faster and made many changes which "make things look better" without breaking things. Source-level compatibility goes pretty much all the way back to 1.0, as well.