Nah, for all Go design decisions that I usually complain about, CGO is actually rather nice.
It feels quite similar to using C++ on .NET via C++/CLI.
There is some cargo cult against CGO, I could not care less.
Nah, for all Go design decisions that I usually complain about, CGO is actually rather nice.
It feels quite similar to using C++ on .NET via C++/CLI.
There is some cargo cult against CGO, I could not care less.
Calling C functions is not free, compilation becomes a lot more difficult, Go tooling is not as helpful. Signal handling is still a mess. It works in the happy path where the FFI is not on the hot path.
I think it is more a skill issue than anything else.
Yes, marshaling has a visible impact, hence why one should think how to actually make it happen, not much different from using FFI in any other programming language, there is always an impact over staying in the same programming language.
Compilation being harder, only if the developer is not acquainted with C, which seems to be something harder to learn nowadays.
Signal handling is a mess even in pure C, especially since all UNIX implementations added threading support.
Go makes signal handling harder. Further, there is no FFI call overhead in Rust, C++, Swift. It isn’t marshalling, a function with no args will still incur an overhead.
Because Rust, C++ don't have a GC, while Swift does have a GC (RC is a GC algorithm) it was designed to be compatible with Objective-C runtime, thus C.
Having to swap stacks has not much to do with GC.
It's fine if you're only targeting one OS with maybe a small handful of architectures. Doing anything cross platform is terrible.
I thought C was a cross platform language.
Maybe the syntax is, but setting up the compiler and build system and linkers is very much not, especially for cross-compilation.
One of Go's major selling points is cross-compilation to other OSes and architectures is incredibly simple and fast, and _the same short build command works across every OS._
I maintain a CGO app that targets Windows macOS and multiple Linuxes and oh boy the build system is probably more complex than the app itself at this point.
I started coding with Timex 2068, developed for embedded in a past life, thus I fail to see how complicated doing a simple cross compiler in C happens to be.
I also have developed C and C++ native libraries for Tcl, Python, .NET, Java JVM/ART (JNI), Node.js.
Yeah I think this is a case of an old timer not having the perspective of the younger generation
`GOOS=windows go build ./...` versus all the jank you have to do with C is just not at all comaprable
Try to do that for a Windows UWP, iOS, Android or z/OS application, in pure Go.
Yes it is super easy, in a few selected workflows of Linux, BSD, Windows, macOS, everything else is just as "complicated" as regular C cross compilation.
Good thing I don't write code for those platforms! :P