3 ms·
AT FIRST GLANCE: Annoyances: braces; variable declarations more verbose than in C Flaws: no discriminated unions; no generics or parametric polymorphism Doub
by nearestneighbor 17y ago
AT FIRST GLANCE:
Annoyances: braces; variable declarations more verbose than in C
Flaws: no discriminated unions; no generics or parametric polymorphism
Doubts: no exceptions; no macros (as far as I can tell)
Edit: I take back the verbosity claim. := does inference
Edit2: interfaces replace generics, but are
type-checked at runtime, apparently:
http://golang.org/doc/go_for_cpp_programmers.html#Interfaces
- agl 17y agoNo macros indeed. Unions types will probably happen sooner rather than later.
- jrockway 17y agoYeah. Languages with no control flow other than "call" and "return" were ok for the 80s... but we know better now. Just add continuations and you get functions, coroutines, exceptions, loop exits ("last", "next", etc.), and so on for free. I am not sure why I'd use this language with no libraries when I could use a better-designed language with no libraries instead.
- telemachos 17y agoIt ain't CPAN yet, but I think "no libraries" is an over-statement: http://golang.org/pkg/ http://golang.org/pkg/
- btilly 17y agoThere are other control flow options available. For example they offer the following simple example of what they call goroutines: ch := make(chan int); go sum(hugeArray, ch); // ... do something else for a while result := <-ch; // wait for, and retrieve, result You can actually set up any complex mess you want of functions talking to other functions through channels. This gives you coroutines, threading, etc. Looking through the spec, it looks like they have anonymous functions and closures as well. While I agree that they need to add exceptions, they do have some interesting things in there already.
- gchpaco 17y agoNo macros is pretty annoying, but note the package go/ast and go/parser; they include in the standard library a parser for the language, which should make writing tools operating on Go significantly easier.
- blinks 17y agoOn Edit2: interfaces don't replace generics, they're more like a strong duck-typing system (if that makes any sense). Generics are being worked on (according to the tech talk), but they haven't determined the best way to do them yet.
- mleonhard 17y agoExceptions are definitely needed.