News for hackers. Stuff that matters.
Re:"100% of our production system is now running Go" by tjoff on Friday August 31, 2012 @04:36AM (#4458836)
I have such a hard time believing how anyone could have believed that C/C++ programmers would switch to a GC-only language just like that.

I just can't see Go as an alternative to C or C++, and I'm quite surprised that anyone (especially someone such as Rob Pike) could.

Sure there are situations where a program that typically would have been written in C/C++ could benefit from Go (so there is a place for it), but the reasons for choosing C/C++ are often the same that makes Go a really bad fit.

My dreams of a C-like language where the dangerous parts have been removed (and in this context I don't consider having control of your memory dangerous) took a hit with the introduction of Go :(

Re:"100% of our production system is now running Go" by eckyptang on Friday August 31, 2012 @07:11AM (#4459151)
I think C/C++ programmers have had their reign long enough and have shown us through the amount of utterly horrible security issues that managing memory yourself is a bad idea.

Go fits an important niche: stuff that doesn't have to play with the hardware directly, which is pretty much everything but the OS.

I controversially consider there to be no other use for C bsaed languages these days other than at the kernel level.

It's better to centralise the memory management and optimisation either into a VM or compiler. It's easier and safer to verify a compiler (mathematically or otherwise) than every memory access that you do.

Due to my engineering background, I would always sacrifice performance for less risk and more reliability.

I've also spent 20 years writing C and C++ so I know how horrible it is.

Re:"100% of our production system is now running Go" by tjoff on Friday August 31, 2012 @09:11AM (#4459510)
Go fits an important niche: stuff that doesn't have to play with the hardware directly, which is pretty much everything but the OS.

The anything-but-the-OS-niche? I thought we had plenty of languages for that.

It's better to centralise the memory management and optimisation either into a VM or compiler. It's easier and safer to verify a compiler (mathematically or otherwise) than every memory access that you do.

You seem to ignore performance altogether, if you programmed in C/C++ for twenty years but don't care for performance and don't do low-level work, why have you been using C/C++?

Or if you have been doing low level or performance critical work, why wouldn't you want a safer alternative for that?

When you have to tune and debug your application to please the garbage collector having to deal with your own memory seems like child's play. It is much easier and safer to verify that your own memory management won't bite you than it is to be sure that your garbage collector won't eat you. (surely that depends on the context etc. but making broad claims seems to be on topic...)

Right tool for the right job. C/C++ has "monopoly" on a lot of use cases (way more than any other language) and considering its issues I truly believe that a "better C/C++" is needed, way more than those 20 JVM-based languages that popup every other month. Or Go.

Re:"100% of our production system is now running Go" by eckyptang on Friday August 31, 2012 @09:48AM (#4459659)
The anything-but-the-OS-niche? I thought we had plenty of languages for that.

We have plenty of languages, but most of them are low performance interpreted languages, have major compromises or are not architecturally sound. Go addresses a lot of those issues - more than any other language so far.

You seem to ignore performance altogether, if you programmed in C/C++ for twenty years but don't care for performance and don't do low-level work, why have you been using C/C++?

I don't ignore performance. There are many ways to achieve performance. I've worked on embedded systems (military, medical sector) and occasionally need direct hardware access which is where I use C/C++ and that is primarily to manipulate a device and hand off a suitable abstraction to a higher level language (with a garbage collector).

When you have to tune and debug your application to please the garbage collector having to deal with your own memory seems like child's play. It is much easier and safer to verify that your own memory management won't bite you than it is to be sure that your garbage collector won't eat you. (surely that depends on the context etc. but making broad claims seems to be on topic...)

That is all down to determinism. Determinism can be achieved in various simple ways. If you understand the language, you can write code that pre-allocates and reuses memory in critical sections therefore invoking no garbage collection penalty. Isolating critical sections from each other is still a problem in C/C++ if you consider the threading model that they use.

Right tool for the right job. C/C++ has "monopoly" on a lot of use cases (way more than any other language) and considering its issues I truly believe that a "better C/C++" is needed, way more than those 20 JVM-based languages that popup every other month. Or Go.

I'm not a fan of all "those 20 JVM-based languages" - I find them tedious and ugly. I'm the most critical person on the planet when it comes to this sort of thing. Go pretty much hits the mark.

I think your complaints could be addressed with a simple extension to pause the collector therefore introducing determinism i.e:

   func CriticalFunc() {
       defer runtime.ResumeGC()
       runtime.PauseGC()
       // critical section
   }
Re:"100% of our production system is now running Go" by pcwalton on Friday August 31, 2012 @10:13AM (#4459760)
"I think your complaints could be addressed with a simple extension to pause the collector therefore introducing determinism"

I don't think that scales to multiple threads. Remember, the GC is global. With a lot of goroutines, you're going to end up delaying GC far too long if any of them can block the GC.

These sorts of things are the reason why it's considered a bad idea to muck around with the GC settings in e.g. the JVM unless you really know what you're doing. The right way to avoid GC pauses in a GC'd language is to avoid generating garbage; e.g. with free lists.

Re:"100% of our production system is now running Go" by eckyptang on Friday August 31, 2012 @10:49AM (#4459945)
GC doesn't have to be global or blocking. If you look at the GC in CLR/.Net 4+ then it can run GC on low priority background threads.

I know Go's GC isn't there yet, but it's easier to centralize a performance improvement under this model i.e. GC improvements will lead to global improvements rather than case by case.

There's more than one way to skin a cat on this one.

Re:"100% of our production system is now running Go" by luriel on Friday August 31, 2012 @10:54AM (#4459969)
> The right way to avoid GC pauses in a GC'd language is to avoid generating garbage; e.g. with free lists.

And Go makes it much easier to avoid generating garbage than pretty much every other GC language around, already "by default" Go code tends to generate dramatically less garbage than for example Java, and when you care, you can further fine tune it to produce even less garbage.

Re:"100% of our production system is now running Go" by mogrim on Friday August 31, 2012 @01:49PM (#4460812)
Genuine question, from ignorance: How does Go create less garbage than Java? I can certainly appreciate that a lot of the common frameworks used in JEE development may be memory-hogs, but the language itself?
Re:"100% of our production system is now running Go" by vetinari on Friday August 31, 2012 @02:58PM (#4461147)
just iterating:

  for (Object o: collection) {
  }
causes memory allocation.

If you are interested, android team at had several talks at Google I/O (not just 2012) about optimizing memory usage.

Re:"100% of our production system is now running Go" by mogrim on Saturday September 01, 2012 @06:46AM (#4463334)
Cheers, will check those out.
Re:"100% of our production system is now running Go" by MatthewPhillips on Friday August 31, 2012 @07:56AM (#4459253)
Re:"100% of our production system is now running Go" by jk4930 on Friday August 31, 2012 @10:34AM (#4459872)
You should look at Ada 2005 (or Ada 2012). Ada is battle-proven and comes with plenty of reliability tools and inbuilt safety. It's also focused on embedded, distributed and real-time systems.

AdaCore provides high quality compilers and tools (GPLed) under http://libre.adacore.com/

Interested fellas might start with reading this article: http://www.adacore.com/adaanswers/gems/gem-30/

EDIT: oops, that should be an answer to eckyptang... anyway, check out Ada. :)

Re:"100% of our production system is now running Go" by tjoff on Friday August 31, 2012 @09:13AM (#4459514)
I'll definitely read up more on Rust, thanks.
Re:"100% of our production system is now running Go" by zedzedzed on Friday August 31, 2012 @08:08AM (#4459280)
+1 Rust is a lot closer to systems....
Re:"100% of our production system is now running Go" by slurgfest on Friday August 31, 2012 @12:06PM (#4460268)
> I have such a hard time believing how anyone could have believed that C/C++ programmers would switch to a GC-only language just like that.

Java believed the same thing. Many did switch. The difference today is that most of the people liable to switch already switched to Java.

If I could guess, I'd guess that Go is doing a better job at picking up Java programmers than C++ ones.

Re:"100% of our production system is now running Go" by wapper on Friday August 31, 2012 @10:59PM (#4462533)
I've been meaning to ask someone that. If you switch from java to go, is it really such an improvement in non-trivial cases ?

In Go, you'll be doing the C thing : you'll be reimplementing every datastructure from scratch (or use void, also known as interface{}), and have the same memory allocation problems as java. The problem with that is obvious : only experienced C library authors stand any chance of getting complicated trees right the first time (and I still only seen one person get red-black trees insert right first time once*, 3 other university professors and several assistants failed).

And the fact that you need to write those things from scratch everytime means you've got to debug that extremely finicky and difficult code every single time ... and then a junior programmer comes in and says "hey I can get to the internal fields easy, why don't I just" and you're in for an 8 hour debugging session because that causes a crash in the normal insert code, not the actually wrong code.

One thing I did in go that really, really bugged me was sorting a list (sorting a list of strings). I was making it as short as I possibly could without violating style rules ... 70 lines of code. That's ... well that's just not reasonable.

ArrayList<String> x = Lists.newArrayList("b", "c", "d", "a"); Collections.sort(x); System.out.println(x);

Give me the Go equivalent, in less than 50 lines of code. Please. That just has got to have a short solution, right ?

As it stands, I believe Go is good at being a fast conduit for nearly-ready data. A way to write asynchronous servers. If you need complicated algorithms or quick ways to change data operations ... maybe I'm wrong but it just looks like Go is really not going to be your friend.