Re:Go-style concurrency in C
by _ak on Wednesday November 18, 2015 @01:29AM
(#10586313)
If you want Go-style concurrency, why not use Go in the first place?
[ Parent
| on HN ]
My primary use case was writing network protocols (the stuff I had to deal extensively when implementing ZeroMQ and nanomsg). On one hand you want ultimate performance, i.e. no context switchers, manual memory allocation et c. On the other hand, you want the convenience of writing linear code without caring about what to do when function blocks.
I you've written advanced-enough go, you probably have a bunch of file that start with some C code before the Go code starts.
Go simply can't interface everything the way C does. Go doesn't give you the same level of flexibility either.
tldr: Go's great, but it's just not as powerful as C (unlike Rust or some others, which can do anything C does).
What specifically are you talking about? Go can do syscalls perfectly fine, you can mess in your memory perfectly fine (even if you have to resort to the unsafe package), so what exactly is it where you think Go lacks flexibility compared to C? Because so far, your posting sounds rather hand-wavy.
Re:Go-style concurrency in C
by wishing_for_ffi on Wednesday November 18, 2015 @11:27AM
(#10588673)
One problem is that it's very hard to call go libraries from other languages (it requires a runtime). C libraries can be called from almost any language.
There are many go libraries I would love to use, but can't because of this. I expect many others are in a similar boat.
For ex try to read the data from a signal.
Another example is to start a namespace before all threads start.
I can go on for a while :)
I can imagine it being nice if you're tied to existing C code. Or if you want C-style memory management.
Garbage collection.
What stuff are you working on where the runtime guarantees of the Go 1.5 GC aren't good enough?
Me personally? Nothing. I'm sticking with Go.
Exactly. I'd argue that the majority of people complaining about Go being unusable for them because of the GC would actually be able to deal with the GC easily. I'm working on a soft realtime application in Go, and the GC has never gotten in the way.
Right back at you though: I'd argue that the majority of people complaining about OCaml (or even the JVM) being unusable for them (and using Go instead) would actually be able to deal with it easily.
Stop derailing this discussion about Go GC vs. C no GC.
It is relevant though. You're talking about the large number of people who are using C and don't need no GC as though they're people who should be using go - but if they don't need no GC they probably don't need a language as low-level as go full stop and would be better served by a more expressive alternative. Ultimately, a large proportion of "people who need go or C" actually need C, making this library a good idea.
Can you elaborate about your experiences writing soft real-time in Go. Is your project open source?
Re:Go-style concurrency in C
by stefantalpalaru on Wednesday November 18, 2015 @07:55AM
(#10587384)
You don't even need to use Go, the gccgo implementation of the runtime (including garbage collection) is available from C: https://github.com/stefantalpalaru/golib