Skip to content

Comment on A review of Nim 2: The good and bad with example codeparent

Comments

With `nim cpp` the Nim compiler actually just generates C++ from the Nim source for the backend to compile. So, calling C++ code is just emitting the calls at a C++ source level and so is straightforward. The situation with Rust "sharing" LLVM is very different, as that is not a source-to-source compiler.

C++ code calling Nim code is also not usually as straightforward. So, "fantastic" here may apply only in one call direction.

The way to enable C++ code calling Nim is via exportc or exportcpp and by writing a head file with the declarations you are exporting

This will require manual work, but you can use macros or a code generation script to help if your api is large.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.