Hacker News new | past | comments | ask | show | jobs | submit login

That means if programs written in C work on your OS, so do the ones in Nim.



Sorry if this is a silly question but I've always thought of C as generating machine code and it had compilers available in any imaginable platform besides perhaps really niche stuff.

Were my assumptions accurate?


Simplified, but yeah. It generates intermediate object code, which is transformed to machine code.

And as you say, pretty much every platform in existence has a C compiler targeting it. In many cases, you use what's a called a cross-compiler, which lets you generate code for, say, Arduino using tools run on, say, Linux. But one way or the other there'll be a way to compile for it.

Net result is that as long as the code isn't doing something that is specific to the platform (memory layout assumptions, asm blocks, Windows API, etc.) the same C code will run on many different platforms. You'll have to recompile it for each one, but you won't have to change the source (much).

If I understand correctly, Nim ultimately generates C source (among other options) which then goes through the above process. So it has the same level of portability.


I think you got confused when the C standard library was listed as a dependency. What is meant is the resulting binary had a link to a dynamic library (libc). For example if you are on a Mac run "nm /usr/lib/libc.dylib", those are the symbols that it might be referencing in a compiled nim program. I don't know the equivalent in Windows, but the dynamic library is a DLL. It doesn't have a runtime dependency on the compiler.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: