3 ms·
Simple C Interface By using build directives you can integrade with C libraries really easily. And its a bunch of magic. I thought these people were serious a
by revelation 14y ago
Simple C Interface
By using build directives you can integrade with C libraries really easily.
And its a bunch of magic. I thought these people were serious about having a language for "systems programming".
What good is it if it can't properly interface with the systems programming language that people actually use, C?
It seems they wanted to add "C interop", but didn't understand what that means.. at all. You give it a header with function prototypes, because thats apparently the only way to tell it "I want to call this native function", and you get... undefined references for the native functions? What the hell is it even trying to do? You don't have source and you don't have linker stubs for a lot of the libraries you want to interop with.
It's a complete non-starter. It's interop for awesome magic demos.
- james4k 14y agoIt sounds like you couldn't get it to work and then decided they've done it wrong. I'm not terribly convinced.
- shadowmint 14y agoWhat? CGO is pretty cool actually. It does have some irritating downsides (pkg-config for example, is used, and there's no other option to link to a specific library afaik)... ...but seriously, what are you even talking about? All you need is a header, and a binary (library; .so or .dll). Done. How would you even use a library that doesn't have a header? Sounds like you've spent some time using COM objects and the . autocomplete function on them; that's just windows crazy-talk, if you want to use that kind of nonsense, go write powershell.
- drivebyacct2 14y agoYou, literally, have no idea what you're talking about. And I'll simply laugh at your very last sentence.
- jbarham 14y agoNonsense. Go's cgo facility is a fantastically productive way to wrap C code. I've written a lot wrappers using Python's C API and a bunch wrappers using cgo and cgo is light years ahead. For a real-world comparison see this Sqlite wrapper for Go at http://code.google.com/p/gosqlite/source/browse/sqlite/sqlite.go http://code.google.com/p/gosqlite/source/browse/sqlite/sqlit... and compare it to a similar wrapper for Python at http://code.google.com/p/pysqlite/source/browse/#hg%2Fsrc http://code.google.com/p/pysqlite/source/browse/#hg%2Fsrc. The Go wrapper isn't a "magic demo", it's code that works reliably in production. The bottom line is that cgo lets me quickly write production quality C wrappers for Go using Go itself.