3 ms·
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
by cestith 1y ago
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.
- sigzero 1y ago> 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.
- maxlybbert 1y agoHonestly, the main difference I run into is just file paths, and that’s easy to sidestep ( https://perldoc.perl.org/File::Spec https://perldoc.perl.org/File::Spec ). There are differences, but they’re usually esoteric ( https://perldoc.perl.org/perlport#PLATFORMS https://perldoc.perl.org/perlport#PLATFORMS ).
- cestith 1y agoYes, I really can, and with the same number or fewer OS-specific checks than the equivalent C program.
- vram22 1y agoInteresting 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
- dmit 1y ago> Haskell https://github.com/Frege/frege https://github.com/Frege/frege https://github.com/typelead/eta 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.
- vram22 1y agoThanks. 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 https://en.m.wikipedia.org/wiki/Gottlob_Frege
- vram22 1y agoSo I submitted HN posts about both of them: https://news.ycombinator.com/item?id=44112115 https://news.ycombinator.com/item?id=44112115 https://news.ycombinator.com/item?id=44076220 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 https://en.m.wikipedia.org/wiki/David_Farragut
- cestith 1y agoI 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 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/ 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.
- dotancohen 1y ago> 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.
- johnisgood 1y ago> I wonder if modern LLMs could actually help with that. From experience, they can.
- fuzztester 1y ago>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.
- cestith 1y agoI 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.