4 ms·
Nitpick, but it actually compiles down to C. Nim works at a higher abstraction and the compilation is a one-way street. But what is more important is that it ge
by PMunch 7y ago
Nitpick, but it actually compiles down to C. Nim works at a higher abstraction and the compilation is a one-way street. But what is more important is that it generates efficient C code, it looks ugly, and it's not something you would ever dream of writing yourself, but it's been optimised to give fast run-times. Often times in benchmarks the Nim code with optimisations comes out as fast as the C code with optimisations, even in some cases beating it.
- 19ylram49 7y agoWhat you said here was literally my point. Maybe you misunderstood me?
- dom96 7y agoI think the point is the terminology, Nim doesn't transpile it compiles to C.
- RussianCow 7y ago"Transpile" is such a nonsense term that I don't think it's useful to split hairs here.
- daemon_beard 7y agoSince you seem to know how this works -- I hope you won't mind if I ask you a slightly on-topic question about this... I've been trying to find out if I can take the generated C code that nim produces and, for example, compile it on some exotic architecture (say an ancient solaris/sparc system or some aix/power thing, or some mips microcontroller with linux) however I can't find any examples of people doing this... Is it possible? Or should I abandon hope and continue writing C for these platforms? :}
- PMunch 7y agoAs the others have said it should be possible. Nim is already pretty good at cross-compiling, but it is also able to just spit out the C files it generates and allow you to play with those.
- tokai 7y agoYeah you can get to the generated C. See this SO question.[0] Give it a try :) [0]https://stackoverflow.com/questions/29956898/how-do-i-get-the-c-code-of-a-nim-program https://stackoverflow.com/questions/29956898/how-do-i-get-th...
- Tiberium 7y agoAre you sure your OS/CPU is not on this list? :) https://github.com/nim-lang/Nim/blob/devel/lib/system/platforms.nim https://github.com/nim-lang/Nim/blob/devel/lib/system/platfo... And yes, compiler works on almost all of them (you can see which ones are precompiled in csources - https://github.com/nim-lang/csources/blob/master/build.sh#L76 https://github.com/nim-lang/csources/blob/master/build.sh#L7... ) And for CPUs - https://github.com/nim-lang/csources/blob/master/build.sh#L132 https://github.com/nim-lang/csources/blob/master/build.sh#L1...
- nimmer 7y agoYes, Nim can run on all sorts of architectures including AVR microcontrollers, MIPS, RISC-V.