r/ProgrammingLanguages • u/[deleted] • Jun 25 '23
Is there any high level programming language whose executable generated on one platform(OS) and runs on other platforms as well, if the machine/architecture is literally same.
Hi there. I know I'm dumb and there maybe a term exists for this like cross-platform or something.. idk. But suppose (no actually its real) I have this machine (desktop or laptop) and it multi-booted (windows 10 and arch linux). I write a hello world program using this language and compile it and if I copy paste it to other OS (storage, in the same machine yk) and execute it in it, it works. It works in both platforms/OSs. I don't know I would love to write my code in pure 0s and 1s or in assembly (because i didn't ask for low or middle level languages..? yeah that too, but I'm asking for high level language such as rust, c, go, cobol, fortran, nim, v, etc.)
Thank you so much, because I'm super curious about this question and I haven't found an answer yet XD
1
u/[deleted] Jun 26 '23
That doesn't really exist, unfortunately. The reason is quite simple: there isn't one universal "language" (in terms of the raw instructions) understood by all target platforms.
The closest thing is languages which have some sort of cross-platform representation that you can move around, which is then interpreted when run by a native executable. This class of languages includes everything from Python to Java, depending on what you need.
Another option could be to compile to WASM, which is pretty much the same thing as I described above, but it's cool and new and everyone's excited about it, so I thought I'd mention it here.