
C? Go? Cgo - fogus
http://blog.golang.org/2011/03/c-go-cgo.html
======
vaporstun
Just curious, and I apologize if this sounds snarky, that's not my intent, but
is anyone here actually using Go for anything? If so, what?

~~~
supersillyus
I've written a few thousand lines. A couple toy VMs/compilers, some web apps,
some random graphical tinkering. Nothing big, but enough to feel like I've
gotten a sense of the language. I started using it expecting to be annoyed by
all of the features it doesn't have, but I ended up really liking it and not
really missing much. It has become my go-to language for random tinkering and
prototyping, in part because I always end up thinking about the code and never
the language.

~~~
gnuvince
Has the absence of generic types been a problem for you?

~~~
exch
For me this was something I missed when I started with Go about a year ago (at
that point my brain was still filled with years of C# dogma). I was not very
familiar with Go's own way of doing things back then. Go may seem familiar at
first glance, but there are some peculiar little differences which offer new
and novel ways of dealing with a problem. Unfortunately these are very
difficult to explain to someone who is not already familiar with the language.

At this point I don't miss generics at all. The benefit they would give me are
marginal enough to not consider it a vital component.

I've found that when you become proficient in Go, you will write different
code that does not really require generics to be present. At least 99% of the
time.

Having said that, I am still hoping that we might one day get unions.
Unfortunately there is little hope of that at this point. It has been
considered, but they would have to be type-safe in order not to circumvent
Go's type system. And doing so, would differentiate them very little from Go's
existing 'interface{}' type. There is a small benefit to unions, but
apparently not big enough to warrant implementing them.

As far as generics go, they are not out of the question. The problem so far
has been that nobody has yet offered a generics proposal that doesn't
partially or completely mess up the language and generally make things more
difficult for everyone.

------
nlawalker
C Cgo. C Cgo go. Go Cgo go.

------
piranha
#include <something> are broken in code listings

~~~
agl
Thanks, this has been fixed.

------
MatthewPhillips
I've used it as a lightweight web server in several projects.

~~~
alanh
Have you fuzz tested it? How’d it fare?

~~~
MatthewPhillips
What would I be fuzz testing, my own code? I do that always.

------
datashaman
Cgo, goatse, c goatse go!

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

~~~
kkowalczyk
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
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.

