4 ms·
Go is like the Six Million Dollar Man language, compared to C. It's everything C can do, but much better. Both C and Go are very, very simple languages; there
by peterevans 9y ago
Go is like the Six Million Dollar Man language, compared to C. It's everything C can do, but much better.
Both C and Go are very, very simple languages; there aren't many keywords, and it's pretty easy to grok both at a functional level. It takes, of course, a bit to reach the second-level understanding you need to make full use of either language, but it's easy to hit the ground running in both.
We sometimes get stuck on one language being better than others because it has X feature or Y concept, and I've seen some people essentially root for one language over another. But at the end of the day, languages are tools to get your work done, and on balance the work is going to be hard whichever route you go. Use the one that suits the talents you have available and that broadly complements the needs that you have.
- gameswithgo 9y agoYes it is definitely true that coming to a nearly-complete understand of Go is very very easy compared to Rust, F#, or Nim. I haven't used it with teams of people on any way yet but I imagine it makes it somewhat easier to drop into code that isn't yours and understand it. There are less ways to create voodoo. Which can be a pro or a con, depending!
- vvanders 9y ago> It's everything C can do, but much better. Are you sure about that? I don't think you'll be running Go on an AVR. Likewise to this day Go still can't pin pointers so interop with native C libraries is a royal pain(this is something that C# and Java both support). People love to bag on C but there are domains where it can go that a GC'd language can't. I wouldn't be so quick to equate the two.
- peterevans 9y agoI love C. It's the language I used when I first "got" programming, and it's stuck with me, even though I don't use much professional use for it. I don't think you can count me among those who "love to bag" on it. I don't think Go needs to be a like-for-exact-like analog of C to be a valid replacement. For many C programs, the memory management pattern they use is something that could be handled just as easily with GC, and done so in such a way as to lift a significant burden on the programmer. I mentioned this in another comment, but definitely, if you need to manage your own memory—don't use Go. I must disagree that GC disallows Go as a replacement for the language. But I will respect your opinion if you think it does!
- vvanders 9y agoI agree that you can claim it as a replacement for some sub-domains. However if I can't do embedded programming then it's not an all-up replacement. Much if modern C usage is in this space even if it's not as visible to the average developer. GCs have a host of problems like needing a 2x working set, pauses and the fact that you can't control allocation locations for better cache usage. Go may be fast but it will never unseat C/C++/Rust in performance for the reasons above.
- camus2 9y ago> It's everything C can do, but much better. No, go has a garbage collector. It is not a replacement for C. Languages like C++, Rust or Ada are.
- peterevans 9y agoLike I said: Go does everything C does, but better. I suppose you could write your own malloc in Go... if you preallocated a bunch of bytes in a huge chunk, and wrote some functions to use that up. But that sounds like a pain. If you really really specifically need to manage your own memory, then I agree, you shouldn't use Go. But that doesn't mean that Go is not a valid replacement for C. Do you think a majority of programs that are written in C are done so because they need to manage their own memory?
- camus2 9y ago> Like I said: Go does everything C does, but better. It doesn't do everything C does, it doesn't allow manual memory management at first place. So you can't pretend that a garbage collected language does everything a language with manual memory management does. Manual memory management is a feature, Go does not have such a feature. Deterministic behavior in a program is fundamental when writing hardware drivers or real time programming, Go can't do that.
- innagadadavida 9y agowhile it is not fully manual memory management, you can use sync.Pool and it gives you better performance as you can reduce garbage generation.
- thefounder 9y agoWhat does deterministic behavior has to do with "better performance" ?
- deleted 9y ago[deleted]
- flavio81 9y ago>Go is like the Six Million Dollar Man language, compared to C. It's everything C can do No, it is not. Put macros back in, pointers and memory without GC before claiming Go can do the same things C does.
- zkomp 9y agoEverything C can do but better? Sure you are not confusing Go with Rust? Go does have a GC, not manual memory management Go can't interact performantly with other languages. Go is like Java (not C). Its kind of nice but deliberatley sabotaged by (Big Company).
- peterevans 9y agoI'm pretty sure I'm not confusing it with Rust! That said, I don't think there's anything more I can say which can add to the conversation. I'm happy to allow what I have said to stand.
- pjmlp 9y agoGo can do some kind of manual memory management, via global allocated arrays or just calling OS APIs directly. C was owned by AT&T, and now by everyone that can afford to have a seat at ANSI/ISO C meetings, apparently it is easy to forget this little fact.
- earenndil 9y ago> [go is] everything C can do, but much better I have to disagree with this one. I tried go briefly, and what I found was that it provided a couple of relatively nice high-level features (multiple return, nested functions, interface{} (although that doesn't count it's basically void*)), but that ultimatley it tried to constrict what I could do in a way that c didn't. Add to that that c somehow has much better metaprogramming than go even though literally every language ever made has better metaprogramming than c.