Re:Show HN: I wrote my own RTS game engine in C
by lenkite on Thursday May 13, 2021 @08:24AM
(#27141291)
"The thing that's always special about the C ABI..."
Fixed. The C ABI is not in anyway restricted to the C language.
Re:Show HN: I wrote my own RTS game engine in C
by chris37879 on Thursday May 20, 2021 @02:06PM
(#27224807)
An important distinction. Thank you.
This practice is fairly common in python when you're dealing with AI (I'm sure there's other examples, but this is the one that sticks out to me.) SDKs like TensorFlow are written in a lower level language (C++ I think for TF) and then FFI called from python, so you can end up with a function like initTensorFlow() and calling it is enough to bring TF online and ready to start processing other data.
And you may be thinking "Well, I can do all that in rust or go or <insert prefered language here>" and of course you can, ultimately it's all just a linker and compiler deciding where to put code and data in an executable, but C is the defacto standard and more tools from more languages are going to work well with it than say, rust or go. Which, now that I think about it, is probably why Rust supports defining a c api for your code, so it's easier to call from other platforms. Rust specifically tries to play nice with being embedded in existing projects because it makes it easier to adopt rust incrementally.
Just my $0.02