Google Go boldly goes where no code has gone before
Every Google data center has a Chubby, and Heroku wanted one too. Like the rest of Google's much admired back-end infrastructure, Chubby is decidedly closed source, so Heroku men Keith Rarick and Blake Mizerany built their own. Although they didn't have source code, they did have one of those secret-spilling Google research …
Bill & Ted
Every Google data centre has a full-on robot chubby.
Chubby and the Goo Girl
Great name for a movie that.
Also the Matrixy Symantec ad is horrible.
one awful bit: the implied ;
Go is sweet. It's like stackless python but fast and with a lower memory footprint. However there is one thing IME which is wrong with the language: the designers didn't like the way C and company require a ; between each statement, and so they made it optional in Go. The rule is that if a ; could be placed before an end-of-line and things still parse then act as if the ; had been there all along. That makes statements like
x = 10
look nice. But
if (x == 10)
body
is dangerous because the compiler realizes it could put a ; after the ), and does so, with obvious incorrect results.
Interesting; But what about
if (x==10) {
body
}
But I must confess i havn't tried to touch GO yet (but if it has C roots), just seems a logical solution to the problem you outlined. If that is the case then I for one welcome this new mental coffee.
yes that's the the only way it works
Yes explicitly putting the {} and making sure the { is on the same line as the if statement works as expected. However the other three common "C" layouts fail: the one I mentioned above, the { on the next line, and the body on the same line as the if. I don't like C-like unless it is really C-like. Somewhat close trips me up.
Go also missed the "indentation is information" boat which python, haskell (and others I don't know--Eiffel I think) got right, IMO. It enforces that the code be pretty. That isn't nice for generated code, but great for humans.
Still despite its faults it's very nice for multi-threaded code, server or otherwise.
Language enforces K&R shock
Oh damn, I was getting interested until you said that. So "ANSI" bracing is out? C syntax may not be optimal but it is automatic to millions of programmers...
"built-in mechanisms for running concurrent tasks"
So - like Occam2 then? He who doesn't learn from the past is doomed to re-implement it from scratch...
Re: "built-in mechanisms for running concurrent tasks"
Uh? They mention Hoare's CSP in the article, and Pike and pals have done several generations of concurrent programming languages.
He who doesn't read the article properly is doomed to comment on it without understanding the context of certain remarks.
Doozer!
That's cute! Same as the little builders on Fraggle Rock!
Slight nitpick
Node.js doesn't have a user-visible event loop; it uses callbacks.
Otherwise, bang on.
This is possibly stupid
but can anyone explain how that function works in the Go Fibonacci Closure code snippet?
Reaching closure
It's a long-winded way of doing Fibonacci but a nice-ish way of demonstrating closures. The fib() function doesn't actually do anything, it returns a function which can be asked to do so something later. a and b act rather like globals and are held in a 'closure' attached to the function object returned by fib(). Each call of this function (which gets assigned to 'f' in the main()) modifies a and b. The double assignment is a trick to calculate both right-hand sides before assigning them to new values of a and b, which gives you a kind of two-element queue, which is what you need for calculating Fibonacci. HTH.
First stab
So a and b exist throughout the life of the call "println()"? That would explain
set a = b
set b = a+b
and the next function call actually taking those values into account.
If you run
println( fib(),fib(),f(),f())
instead, you get
0xf84000b040 0xf84000b080 1 2
Two function "addresses" I'd assume...
Try it all out here. http://golang.org/
I've typed it already if you care to copy and paste:
package main
func fib() func() int {
a, b := 0,1
return func() int {
a,b = b, a+b
return b
}
}
func main() {
f := fib()
println( fib(),fib(),f(),f())
}
WTF...because I'm thick :)
Cheers but...
it looks to me like the line
a, b := 0,1
is always assigning a and b to equal 0 and 1 every time the function is called.
That's a fib
No, fib() is only called once. It's the function it returns, called 'f' in main() which is called repeatedly, modifying a and b each time.
the sound that you hear
is the echo of the penny dropping in the cavern that is my empty mind. Thanks to those that responded; I understand now.
Does Go make it easier to program bug-free concurrent code?
One of the biggest problems with concurrent programming is writing code that is free of deadlocks, livelocks, race conditions, etc.
There's no mention of how Go makes this easier, so I'm guessing it doesn't?
