3 ms·
Cgo seems to me like one of the best (i.e. seamless) implementations of C integration (certainly better than e.g. generating wrappers with SWIG). Can you elabo
by kkowalczyk 16y ago
Cgo seems to me like one of the best (i.e. seamless) implementations of C integration (certainly better than e.g. generating wrappers with SWIG).
Can you elaborate what is so "dreadful" about it and which language does it better?
I'll give props to C# as one of the languages that does it very well, but most others don't (Java's jni is worse, Python before ctypes was worse, lua is worse - I could go on).
- pornel 16y agoIn terms of C integration, Objective-C wins, giving C priority even over it's own syntax :) D has pretty nice integration - you can convert (reasonably non-hacky) C headers to D headers and use C functions and types almost as if they were D native. Explicit type casts, even for most basic types like ulong and void* stuck me as very inelegant. For known prototypes, it should be possible to do it much cleaner. There are various Objective-C bridges (e.g. PyObjC) which are able to seamlessly convert known C types and ObjC classes to equivalents in high(er)-level languages.
- anacrolix 16y agoI can't imagine Python without ctypes. That must have been terrible.