Are there any best practices for binding C-librarys to a higher level language?
Like, regarding Concurrency-Safety, memory-safety, general fault-tolerance, glue-datastructures with low overhead?

  • 0
    That would depend upon the language.

    C++ is pretty free form so people will be less picky. Python would be very picky about the interface being "Pythonic". Not sure about other languages.
  • 0
    Most of the time the language provides all the necessary primitives if you're using it's runtime library. If you're straight up using pure c via ffi then the standard is integrating the "problems" of C into the accompanying library in the target language, not the other way round... I.e. Java wrapper libs around low level stuff expose pointers in safe objects that track their lifetime and which often also do have allocate() and free() methods
  • 1
    One horribly specific observation: dealing with the bloody Python GIL sucks.

    Edit: ... so make a multithreaded back-end for Python at the peril of your sanity and/or anything approaching decent performance.
Add Comment