Live data from Hacker News

C? Go? Cgo

blog.golang.org

21–26 of 26 posts

Re: C? Go? Cgo

#22

For a language based on C, it has dreadful C integration.

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).

Re: C? Go? Cgo

#25

For a language based on C, it has dreadful C integration.

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).

In 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.

Re: C? Go? Cgo

#26

For a language based on C, it has dreadful C integration.

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).

I can't imagine Python without ctypes. That must have been terrible.
Post reply on HN