To view parent comment, click here.
To read all comments associated with this story, please click here.
Personally, I find the sintax cryptic and I would only use it as a last resource.
For example:
func fib() func() int {
a, b := 0, 1
return func() int {
a, b = b, a+b
return a
}
}
Some people may feel comfortable with that kind of syntax, I don't, It is as bad as the worse C++ IMHO, well not that bad.
Edited 2013-01-23 20:58 UTC
To be honest, that doesn't even look valid Go (though, as I said, I'm only a week in on the language).
However some of the weirder syntax I've read on the tutorials were purely demonstrations showing how the more advanced C++ routines would be ported (so not really your typical day to day functions).
But lets be honest, you can find extreme cases of bad code in any language, so if you're genuinely curious about the language then I'd recommend have a quick browse through the tour: http://tour.golang.org/
It takes time to adjust, but Go's declaration syntax is novel and helpful, especially when dealing with complex types.
Go:
f func(func(int,int) int, int) int
C#:
var f = Func<Func<int, int, int>, int, int>
There is just no sane way to write the syntax generally. I'm scared to even think what this would look like in C++.
You've been space butchered, but it's not that weird.
The anonymous function is simply a closure that captures the variables a and b, then modifies them both to produce the next Fibonacci number when called.
It's really quite standard. I mean compare to a similar Scheme function (mind you it's been awhile):
(define fib (let ((a 0) (b1))
(lambda () (begin (set! a b) (set! b (+ b 1)) a)))
But of course, until you share what language you think does this "better," it's impossible to address your complaint.
Edited 2013-01-23 22:19 UTC
Congrats, you've written shit code with no sense of style and taste. Hope you feel good that even automatic code formatting tools like "indent" are smarter than you. Writing unreadable code to make a statement about style is about as valid as criticizing car safety by driving down a mountain road at 200+mph, IOW nobody will take you seriously.





Member since:
2007-03-26
Go is a C like language, a little more pretty but still with a syntax that can become hard to read IMHO.
Sorry, but I'm not sure I get your point as both the officially supported languages are C-like (Java and C++).
However Go is much more than just another C-like language. Syntactically it's concise yet still verbose enough to be readable. It's a managed language but it doesn't make assumptions (unlike some managed languages).
In all honestly, I've only been using it a week yet it's so easy to pick up that I already feel like I've been programming in the language for months. It really is a joy to use.
Plus it's cross compiling support is child's play. I can write an application on x86, get it working exactly how I want, then just change one compiler flag to create and ARM binary for my Raspberry Pi. I will concede that it's been the best part of 10 years since I've done any cross compiling in C++, but I'm sure it was never that easy.
Edited 2013-01-23 20:50 UTC