V-lang is planing(?) for Version 0.5 like Carbon to implement "Direct C/C++ interop without generating wrappers".
Would this be possible for Nim too?
What would this mean for external C/C++ libs? Simple "import" eg. GLFW an use it?
That is pretty much the pitch for Futhark. Basically it automatically generates the wrapper for you (and by wrapper it's just all the function and type declarations, there's no runtime overhead). However these automatic wrappers will be very C-like, so if you want an easier Nim experience then you would probably want to write a more Nim-like interface to the C library which maps it to the automatic memory management, converts types, and prettifies names.
Futhark can't currently do C++, but it handles even complex C libraries like Gtk. Just import it and start writing code (in Nim, but very C-like as mentioned above).
You can even replace CMake with Nim:
There is no wrapper, you can call the functions directly.
This is pretty cool!
https://github.com/mratsim/agent-smith/blob/a2d9251/third_party/ale_build.nim#L65-L83
Is it possible to pass paths (and use the "/" operator) to the compile pragma? Is it possible to use strformat on those pragmas and on the .passC pragma?
I've replaced some CMake stuff with Nim as well. It's surprising how much simpler life is with sane os / arch checks vs the CMake pains. I just wish pkg-config was better supported as some C/C++ packages don't set it up.
@didlybom it's a compile time pragma and so requires compile time constants. Most any string manipulation that works at compile time should be fine.
Thanks for the hints.
@PMunch
However these automatic wrappers will be very C-like, so if you want an easier Nim experience then you would probably want to write a more Nim-like interface to the C library which maps it to the automatic memory management, converts types, and prettifies names.
That makes sense.
It will be interesting to see how "C++ interop on source level" should work in V as V-lang is not an OO language?
Is it possible to pass paths (and use the "/" operator) to the compile pragma? Is it possible to use strformat on those pragmas and on the .passC pragma?
I do pass paths in that example, and even const strings and globs.
const rel_path = "./arcade_learning_environment/src/"
{.compile: (rel_path & "common/*.cpp", "ale_common_$#.o") .}
should work in V as V-lang
I wouldn't put too much faith into any claim coming from V-lang. There is a history of over-promising and under-delivering. Everytime I've seen people try to check their claims, they ended up finding compiler bugs or edge cases not handled.