7 ms·
I asked this on Ask HN sometime back but did not get a lot of responses. So asking it here because it might be of interest to people reading and commenting on t
by distcs 4y ago
I asked this on Ask HN sometime back but did not get a lot of responses. So asking it here because it might be of interest to people reading and commenting on this artile here.
Which programming language other than C is available for most platforms?
It is well known that some C compiler implementation is available for almost every computable platform. I am looking for another programming language that has compiler implementations available on a large number of platforms. It must compile source code into native machine code. It doesn't have to match C in ubiquity. It can be less popular than C. But are there any programming languages out there that are available on a large number of platforms?
- SQueeeeeL 4y agoThis is not a direct answer for compiled languages, but Greenspun's tenth rule feels relevant here: >Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp
- naasking 4y ago> Which programming language other than C is available for most platforms? Wouldn't any language frontend for gcc count? Last I checked that includes Ada, Fortran, and others.
- atan2 4y agoWell, not really a systems language (and strongly dependant on C), but Lua is usually a good choice and it runs virtually everywhere.
- amatria 4y ago:ICANT: java :ICANT:
- selfmodruntime 4y ago> Which programming language other than C is available for most platforms? There is almost no platform java can't run on. Rust is a bit esoteric, but it can run anywhere you have a working libc.
- School-Cotton 4y ago> Rust is a bit esoteric, but it can run anywhere you have a working libc. I don’t think that’s true. Doesn’t Rust only run on platforms that LLVM supports?
- selfmodruntime 4y agoI'm wrong, but you're also incorrect. Turns out, that rust can in theory run anywhere you have a libc, but if the target isn't known to the compiler yet, it's on you to connect libc to the rust STD.
- School-Cotton 4y agoHow can rust run somewhere that LLVM doesn't support?
- FartyMcFarter 4y agoJava requires a certain amount of memory and CPU power (if nothing else because it's a garbage collected language). I doubt Java is available on some of the smallest computers C can run on, like many microcontrollers or legacy platforms.
- haspok 4y agoThere is https://en.wikipedia.org/wiki/Java_Platform,_Micro_Edition https://en.wikipedia.org/wiki/Java_Platform,_Micro_Edition But of course, a 32KB RAM minimum would be too much for some legacy systems. Still, Java is actually far more flexible than most people would think. (Also, at its heart the JVM is just a Forth-like stack based interpreter, and I would guess that loading and parsing a .class file is more complicated than the interpreter itself!)
- bryanlarsen 4y agoTwo very different answers for you. 1: Forth. I've seen Forth on things that I didn't even realize were computers. Since an interpreter can run in a few hundred bytes of ROM, that's not too surprising. 2: Rust. Rust can run on 8/16 bit micros, client side web (WASM), and on iOS, along with all of the more conventional and easier targets. Probably the only popular universal language for 2022 targets, although there are Rust competitors like Zig that may falsify that statement. And in a nice coincidence, both languages are fun.
- _gerald_ 4y ago[flagged]
- AndyKelley 4y agoThis guy has been doing "concern trolling" about once a day for a week now: https://gist.github.com/andrewrk/9aed922a6210e57243af8be8d10fba50 https://gist.github.com/andrewrk/9aed922a6210e57243af8be8d10... There's plenty of things to criticize about Zig. Just do it honestly instead of pretending that you're "just asking questions".
- blueflow 4y agoIf you are looking for a language that is portable across platforms and widespread/long-lived enough to make learning it deep worth it, i think C is unmatched and will probably stay like this for a while.
- samatman 4y agoForth is available for more platforms than C, and like C, it is usually but not always a compiled language. Because Forth always has an interpreter, and a powerful one, it's more obvious that Forth doesn't have to compile to run, but again, true of C as well: https://gitlab.com/zsaleeba/picoc https://gitlab.com/zsaleeba/picoc exists, and it isn't the only one. Edit: an important difference between them is that C implementers take the standard very seriously, while Forth is culturally resistant to standardization, Chuck Moore being on record as having considered it a bad idea, and disliking the resulting ANSI Forth language. If the goal is to compile "the same code everywhere", well, good luck doing that with C, but with enough #ifdefs it can be done. The Forth approach is to have a personal base layer of words, which one either adapts or implements for a given system, and target the rest of one's code at that dictionary.
- badsectoracula 4y agoFree Pascal[0] supports a wide range of platforms and architectures. From the site: > Free Pascal is a mature, versatile, open source Pascal compiler. It can target many processor architectures: Intel x86 (16 and 32 bit), AMD64/x86-64, PowerPC, PowerPC64, SPARC, SPARC64, ARM, AArch64, MIPS, Motorola 68k, AVR, and the JVM. Supported operating systems include Windows (16/32/64 bit, CE, and native NT), Linux, Mac OS X/iOS/iPhoneSimulator/Darwin, FreeBSD and other BSD flavors, DOS (16 bit, or 32 bit DPMI), OS/2, AIX, Android, Haiku, Nintendo GBA/DS/Wii, AmigaOS, MorphOS, AROS, Atari TOS, and various embedded platforms. Additionally, support for RISC-V (32/64), Xtensa, and Z80 architectures, and for the LLVM compiler infrastructure is available in the development version. Additionally, the Free Pascal team maintains a transpiler for pascal to Javascript called pas2js. [0] https://www.freepascal.org/ https://www.freepascal.org/
- Tozen 4y agoGood post. Too many people act like there is C or C++, then nothing else. As Pascal shows and along with others, there are various options, if one chooses to see them.
- distcs 4y ago> As Pascal shows and along with others, there are various options The number of platforms Pascal is available looks impressive! Can you mention some of the others like that? You say there are various options. What are those?
- Tozen 4y agoAda is up there with Pascal (which there are various dialects aimed specifically at embedding) as an alternative. Some people will take issue, but Java and Go can be viable alternatives as well. Lots of activity and talk to try to push Rust into being a stronger alternative too. There are also the other newer C alternative languages and languages that compile to C (Nim, Vlang...), that can be directed towards this purpose. Speaking of Vlang, there is now a project for it to compile to Pascal, as one of its backends (in addition to C and WASM). So... Pascal, Ada, Java, Go (including TinyGo), Rust (future), and others mentioned (future/transpile to C)... Don't get me wrong, C dominates. But, depending on what is being done, its not the only language that has to be used or it can be written in something else that transpiles to it.
- pjmlp 4y agoBesides all other replies, C++.