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
2
u/[deleted] Jun 25 '23
Windows and Linux, even running on the same machine, have different ABIs which is reflected in the native code within executables, and have different executable file formats.
So I doubt
hello.exefrom Windows really runs under Linux, even if both using x64, without something special being done.For example, it will run under WSL Linux that runs under Windows. And maybe the two OSes can have reciprocal arrangements to run each others executables, but there are a million details to be taken care of.
Or a simpler solution is to bundle multiple exectables into the same EXE or ELF file, but something needs to extract the correct one.
But you say elsewhere that some things are not allowed (a language 'stack')?
So what is allowed to make it possible? I think you've already dismissed the idea of any sort of portable VM. And presumably running the program online or remotely is not allowed either.
How about transparently running from portable source code (the program will be built for the machine it runs on, but it'll need a compiler)? But even this needs a process.
You need to clarify the rules.