New stable release of Go
golang.org
golang.org
I'm personally extremely happy with this development. We run Tinkercad on a moderately complex Go/C++ based server infrastructure (7 server types on tens of machines) and we have been lagging the Go tip given our need to avoid instability. The fact that we can now sync more often than 6 months and with less risk is great. It's a important step towards making Go a solid choice for distributed systems programming.
gofmt - no need to argue over coding style since it is enforced by this tool.
gofix - as the language evolves, the go team provide fixes that you can run across your old source code automatically.
And languages that have function overloading have plenty of API changes that could benefit from something like gofix.
1. Simplicity matters more than compatibility. 2. Assume all extant Go code is easily mutable.
The purist in me finds that appealing, but I'm not sure how that will hold up over the long term. The language seems intentionally designed to not evolve which doesn't seem like a good way to stay useful for real people for a long time.
Maybe I'm wrong and everything will work out, but I wonder if several years from now, Go will just fall over from its inflexibility and become unusable.
This is a strange claim to make given how much the language (and its libraries) have actually evolved during their little more than a year of life.
If you compile a program using Go, you get a binary that will run forever. Statically linked, contains the runtime, you're all set. If you update Go, you can then re-build that same program, but you might have to update a few things to get a working binary again--but you only have to do this if, somehow, that originally-compiled binary isn't working for you.
If Python decides they want to change the syntax for opening a file, then you can either 1. Keep a second Python around forever for compatibility or 2. Modify your program so it uses the new syntax. Go will never do this to you; as long as your OS continues to support the same binary format, I don't see why a binary shouldn't work indefinitely.
I bet the coding standard discipline at google has something to do with it, as described by Steve Yegge[1]:-
"Google is an exceptionally disciplined company, from a software-engineering perspective. They take things like unit testing, design documents and code reviews more seriously than any other company I've even heard about. They work hard to keep their house in order at all times, and there are strict rules and guidelines in place that prevent engineers and teams from doing things their own way. The result: the whole code base looks the same, so switching teams and sharing code are both far easier than they are at other places."
[1]:http://steve-yegge.blogspot.com/2006/09/good-agile-bad-agile...
Bold, delicious digression from oop - there literally is no relation between objects by identity, only by behaviour via interfaces - not your usual crappy java/c#/etc. interfaces, but rather 'true' interfaces, which are implicitly implemented by dint of a type fulfilling them. This is surprisingly powerful and the simplicity of it helps move you away from thinking about complexities you get with oop that have nothing to do with the problem at hand.
Extremely fast compiles - you miss this when you go back to languages that compile more slowly. It allows for rapid prototyping and trying stuff out without having to worry about a massive build time. Check out this vid - [1].
Great concurrency support - concurrency is primitive in go via go-routines.
Sensible, simple, clean syntax.
The list goes on... yeah I need to do a blog post here :)
I think you're referring to duck typing, which Python has leveraged heavily for over a decade (http://en.wikipedia.org/wiki/Duck_typing#History).
In Go, something implements an Interface by virtue of having the right method. No "implements" declaration is necessary. This is statically typed and safe at compile time, while Python is not.
Does anyone know what this feature/pattern is called? As far as I know, Go is the first language to have this feature. Seems different from "Duck Typing" to me..
Reference: http://golang.org/doc/go_faq.html#types
Rather than requiring the programmer to declare ahead of time that two types are related, in Go a type automatically satisfies any interface that specifies a subset of its methods. Besides reducing the bookkeeping, this approach has real advantages. Types can satisfy many interfaces at once, without the complexities of traditional multiple inheritance. Interfaces can be very lightweight—having one or even zero methods in an interface can express useful concepts. Interfaces can be added after the fact if a new idea comes along or for testing—without annotating the original types. Because there are no explicit relationships between types and interfaces, there is no type hierarchy to manage or discuss.
Replace "Go" with "Python" in your final paragraph and it's just as true.
Implement __setitem__(key, value) and you can use it in a dict-like way such that you can say "foo[bar] = baz" where foo is an object of your defined type. Define __iter__ on your type and you can now say "for x in foo: ..."
You're paying a price for this speed: the Go compiler is single pass, which considerably cripples the language and imposes a lot of weird asymmetric features.
And the compilation difference is really still in the ballpark of Java or C#, so it should definitely not be a factor in your decision. Odd that it was a design goal for Pike and his team, but everything is Go seems to indicate that the last language they programmed seriously in was C++ in the late 90's.
What evidence do you have that it cripples the language? And can you point to a single 'asymmetric feature' (whatever that means) caused by this?
If you read any of the interviews with Rob, he clearly points out that the compile speed has little to do with it being 'single pass', and all to do with the package system.
In my subjective experience the compiler is way faster than Java or C# compilers, and they still have plenty of room to optimize compiler speed (for example, there is plenty of stuff the compiler could do in parallel but at the moment doesn't because they have tried to keep the toolchain as simple as possible specially while the language is changing so fast.)
That's just not true - go is not single pass (as I understand it). There are separate passes performed for top-level types and code blocks, for example, and you can forward reference all you like.
Actually, I've made a couple contributions to the language so have played with the internal implementation, and in fact the parse is done in one pass, setting up internal representations of the types/names/etc. before type-checking of top-level types is performed in a separate pass, then variable assignments, then function bodies. I can't see how this is single-pass, e.g. src/cmd/gc/lex.c:238:-
// Process top-level declarations in three phases.
// Phase 1: const, type, and names and types of funcs.
// This will gather all the information about types
// and methods but doesn't depend on any of it.
// Phase 2: Variable assignments.
// To check interface assignments, depends on phase 1.
// Phase 3: Function bodies.
defercheckwidth();
for(l=xtop; l; l=l->next)
if(l->n->op != ODCL && l->n->op != OAS)
typecheck(&l->n, Etop);
for(l=xtop; l; l=l->next)
if(l->n->op == ODCL || l->n->op == OAS)
typecheck(&l->n, Etop);
resumetypecopy();
resumecheckwidth();
for(l=xtop; l; l=l->next)
if(l->n->op == ODCLFUNC)
funccompile(l->n, 0);
if(nerrors == 0)
fninit(xtop);
while(closures) {
l = closures;
closures = nil;
for(; l; l=l->next)
funccompile(l->n, 1);
}
dclchecks();
Unless I'm missing the point - what is crippled and where are the weird asymmetric features?One thing that go avoids is weird syntactic conflicts which require big lexer/parser hacks to work around. C# has quite a few of those, e.g. Foo<Bar<Baz>>> - that's emphatically not the same thing as a single-pass compiler.
Actually Rob has talked about this[1] and highlights dependency management as the most important factor.
I use C# in my day job and find the go compiler considerably quicker, incidentally.
Also saying that you are not trolling doesn't make your comment any less trollish, specially given that your only claim is false, Go, despite still being much younger and greatly unoptimized is already considerably faster than OCaml: http://shootout.alioth.debian.org/u64/benchmark.php?test=all...
(And just so we're clear: I actually like OCaml and have never used Go. So I'm not trying to wave some Go fanboy flag or anything. Those are just the numbers.)
http://shootout.alioth.debian.org/u64/which-programming-lang...
Which shows Go is well ahead of OCaml.
The "which language is best" chart you linked has rather arbitrary weighting.
> The "which language is best" chart you linked has rather arbitrary weighting.
That chart has exactly the same "weighting" as the chart you say is "the relevant chart"!
> Which shows Go is well ahead of OCaml.
Which shows the time measurements for those programs with Go 6g and OCaml completely overlap
http://shootout.alioth.debian.org/u64/which-programming-lang...
The time measurements are similar for both Go 6g and OCaml -
http://shootout.alioth.debian.org/u64/benchmark.php?test=all...
Those tables do not show a rank # by each programming language implementation because that might encourage people to make a completely bogus comparison!
(For example, six places rather than five just because one table includes an extra programming language - Clean.)
You're both being silly! "The numbers" for Go 6g and OCaml overlap and are quite similar.
That aside, personal preference is a one reason to choose Go over OCaml. I happen to like Go's syntax better, and I rather like the design of various bits of the language. Go also has better concurrency support. Also, for some tasks it can be quite useful to be able to control the memory layout of your data structures, and (to my knowledge) OCaml can't do that.
There are other points to make on both sides, but really, it's a tricky question. Which langauge is best is a per-task and per-person question, so unqualified comparisons aren't terribly useful.
tl;dr:
gc: slower code, faster concurrency.
gccgo: faster code, slower concurrency.
On the flipside, I think learning OCaml (if you've no experience with that family) will make you smarter in a way that Go won't. Of the two, given someone that knew neither: if you want to learn something learn OCaml, if you want to do something use Go.
Aside: speaking of OCaml and new languages, have you looked at Rust? https://github.com/graydon/rust/wiki - it was bootstrapped in OCaml.
Yes, Go is not a 'purely functional' language, or 'purely' anything, Go is a pragmatic language following from a very long tradition mostly at Bell Labs.
You're correct. I haven't used Go particularly much and I've only heard third-party descriptions of Limbo et al. Regardless, a number of the semantic and syntactic differences between Limbo and Go strike me as Python-influenced (obviously not goroutines or the defer statement) but if you have evidence to the contrary I'd love to see it.
> Yes, Go is not a 'purely functional' language, or 'purely' anything
Whoa buddy. That's not what I meant at all. There's no technical value in being able to say your language "purely" implements some programming style or other. Now, it would be nice if higher-order functions became a little easier to work with in Go; it is also unlikely that this will happen, because that's not one of the design goals. I can't fault them for that, but is there really any harm in pointing out a true fact such as this one?
And anyway, a "purely functional" language is just one where there's no built-in support for mutable state. Obviously this does not describe either Go or OCaml.
And among "safe" languages, OCaml is probably the most efficient, generating fast code running with a small memory footprint.
Moreover, although its development was a little slow in the last years, they have recently restarted working on it, on optimizations and soon multicore support, so I would wait a little before making more comparisons.
For example, function names are sometimes CapitalizedLikeThis, but sometimesLikeThis. This kind of messy inattention to detail makes the language come across as sloppy and unfinished.
Go's naming conventions are much more clean, respected and even enforced than in almost any other language I know (Ruby and Python are specially bad in this, but C++ and Java are not much better).
Do you mind explaining this statement a little further, specifically related to Python and Ruby. I work with both of those languages and find the naming conventions to be quite clean and respected. The style of the language is not enforced, but you'll certainly be chastised by any serious developer in either language for doing something outside the norm.
In Ruby just looking at the methods for strings is enough to find this like: "instance_variable_defined?", "rindex", "tr_s", "casecmp", "equal?", "eql?" and more. Yes, it is all lower case, but consistent it is certainly not.
The idea itself is cool, communicating extra context about what the method does or its intended usage, but they're used so inconsistently (even withing the Ruby stdlib) that A) They're unreliable and you need to check the source to find out the behavior anyway and B) It's less predictable whether the method exists with the suffix or without, so you need to either run it and modify your method call if there's an error or check the lib/API docs. This is the sort of thing that makes having an IDE handy for completing method names, which is unfortunate because Ruby is generally very usable without any IDE crutches.
fmt.Printf(colorizeWithAnsi(strings.Replace(s, " ", "/", -1));
It goes from being mere syntax (like Ruby's elegant use of '@' to denote instance variables) to screwing with the names themselves apparently just to avoid introducing keyword (like Java's 'public') or additional syntax for exporting symbols.I'm not perfectly happy with this convention because I prefer the everything_lower_case_with_underscores style but you get used to it. Go's benefits out weight its awkward quirks by far.
I've also written 2 smaller web apps using Go and I had really fun doing so. Statically typed language for webdev = <3
I can say I became a Go fanboy in the last few weeks and I hope Go gets more traction. Go @ Android would be freaking awesome.
Go on Android should be quite cool, but what will be awesome is Go on AppEngine.
I'm British. I was being understated :)
I hope that's the "surprise" Andrew mentioned on twitter: > http://twitter.com/#!/go_nuts/status/63762141555064832
http://code.google.com/p/googleappengine/issues/detail?id=23...
It did and still does make me wonder, though.
Like Java, or Scala, or even C++ (Okcupid did it)? I'm trying to figure out why Go made you arrive at this conclusion and other languages did not.
There's something (possibly irrational) in me that has a deep aversion against Java. Maybe it's from my job as game developer for J2ME devices back in 2003. Java is to me 90% boiler plate 10% actual app logic.
> Scala
Burn me on a stake but I'm not that into FP. Though I didn't look too much into Scala - maybe I missed a lot.
> C++
I've been using C++ a lot for game development and other "serious" stuff. I don't love it. I don't like the OO model. (I tend to not like OO nowadays at all.)
> Go made you arrive at this conclusion
It's not that I arrived at this conclusion lately. I always favored static typed languages - but for a quick hack there wasn't anything that could beat ruby/python (at least nothing I know about). Go maybe doesn't beat them too but getting a webapp running with Go isn't too much effort either. I can live with that. And my hate for python's whitespace madness and Ruby's 1000 ways of saying one thing made the decision to try out Go for web dev easier :)
What do you like? Honest, straight question.
Go looked to me like a c-language guy's take on very simple OO with a few functional and parallel features. On the whole the API looked terse to the point of being cryptic, which is a throwback to the 1980s.
Can you sell it to me? What's the best part? Is it something that's not in any other language, or some way that the parts combine?
Many other languages have loose, duck typing and a few others (notably erlang) have the lightweight parallelism.