Hacker News new | ask | show | jobs
by afavour 14 days ago
I’m curious if this closes the door on Nim’s capability to output C code which you then compile yourself. I first discovered Nim when I was looking for something that could work with Apple’s requirements to embed bitcode in iOS apps, it meant you had to use their specific version of LLVM and that ruled out a lot of languages. It always seemed like a really unique feature (though IIRC Haxe has something similar).

Apple has long since removed that requirement so it doesn’t really matter anyway and I wouldn’t blame the Nim folks if it’s gone, these seem like a great set of improvements.

4 comments

The real win with the compile-to-C strategy is embedded - a million embedded devices only publish vendor-provided (typically GCC) C toolchains.
This is a great part of Nim. I started using it with ESP32's for 5+ years or so now. Nimony is even more ideal for embedded.

Great part is that Nim's stdlib networking was easy to port to esp-idf's lwIP based network stack. So you get access to production Nim libraries for lots of networking stuff, or async, etc.

Which I used in actual production at my previous job! Running lots of devices in the field in extremely remote areas :)
Very few of them don't support at least C++98/C++03 nowadays, in fact I would assert that they may have evolved into C++11 by now.

The modern embedded devices that still only get Assembly and C toolchains are like PIC class devices.

Compiling to C is still supported.

https://medium.com/@s.quddin/nim-3-0-a-deep-dive-into-the-ne...

Nimony plans multiple backend targets, reflecting Nim’s philosophy of not being tied to a single code generation strategy:

NIFC to C Translator: This is close to being production-ready. It even generates makefiles. For a language that has historically compiled to C, this ensures backward compatibility and continued access to GCC/Clang’s optimization pipelines.

NIFC to LLVM Translator: Planned for future releases. This would enable Nim to benefit from LLVM’s extensive optimization infrastructure and target WebAssembly.

NIFC to Native Code Translator: [...]

A lot of compilers nowadays compile to wasm, when you have wasm, you can compile to C.
Wasm is great, but it's a terrible IR for C back-compilation if you have alternatives available IMO.
Nimony still puts the C code in the .cache/ folder as nim does.
what does this imply? are you saying it does in fact still actually "transpile" to C?
I don't think we can call that transpilation as it's not a 1:1 conversion But yeah, the native backend and LLVM backend definitively close the "transpilation" door
As I understand it both 'transpile' and does native code generation.