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 :)
> 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.
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.
> 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.
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.
> the Go compiler is single pass, which considerably cripples the language and imposes a lot of weird asymmetric features.
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.)
> 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.
I'm not sure if what Go is doing is "Duck Typing", but there's a huge difference from Python.
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..
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.
You're exactly describing duck typing. Resolving it at compile time in a static, "safe" way is a useful feature to be sure, but that doesn't mean it's not duck typing.
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: ..."
It's a more restricted version of duck typing and requires an interface specifically to be set up for the type, though not for the type to explicitly implement it, so it's not quite the same thing.
The alternative is the way C++ was handled--for a very long time new stuff would be added to compilers in a non-backwards way and break all your code. This was happening pretty much every time you got a compiler update and was very frustrating. "gofix" seems like a pretty good compromise for using the language while it's developing and not having your code break constantly.
While the Go language is still under development you will run into problems from syntax and API changes. I think the existence of the gofix command speaks more about the quality of the effort put into Go as a whole. They actually put in the effort to make syntax and API changes as easy to fix as possible.
If you look at the actual fixes gofix provides, most of them are to paper over a lack of language features. In particular, if Go supported function overloading, they probably wouldn't need gofix at all.
Am with the siblings - disagree very much. A very nice thing about go is that it isn't afraid to say 'no' to features, nor is it afraid to enforce conventions to encourage consistency.
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."
It's pretty to make version one of your language's libraries clean and simple. The real challenge is how they hold up over time and the needs of evolution. Go's philosophy seems to be:
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.
You typically can't even compile Linux with the previous GCC version, yet somehow that kernel has been tottering along for about 20 years now.
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 disagree. Even for the gofix fixes look to be simple "n args to n-1 args" changes, even in a language that supports function overloading I would prefer to have one version of the function, not two. The use of overloading to avoid the pain of an API change over time leads to a pretty crappy interface.
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.