334 points · by enneff · 13y ago · 195 comments
However, if you do a lot of collection processing, you start to really itch for something like generics (Which can lead down some pretty interesting rabbit holes: http://blog.burntsushi.net/type-parametric-functions-golang). I think this is a pretty big feature to be missing, actually. I hope it comes soon in future updates. It's pretty frustrating to have to reimplement data structures that can accomodate custom structs.
But overall, it's very impressive, and a step in the right direction. I think we're approaching a golden age of programming languages, where syntax, expressiveness, and performance are all given equal seats at the table.
I really hope it keeps gaining momentum.
This was reason enough for C to get popular.
For example, Go has no REPL. (It's difficult for statically-typed languages to provide one.) It's commonly believed that a REPL is valuable and increases productivity. So if you were offered the choice, is there any circumstance in which "no REPL" is equally powerful as having one? Well, the vast majority of great hackers seem to agree that it's always superior to have a REPL than to be forced to live without.
Lots of people love programming in Golang (I especially love to write distributed systems with it!) yet it probably won't ever offer us a REPL. That must mean one of two possibilities are true, both of which are bizarre: either 1) we love Go in spite of being limited by not having a REPL, or 2) having a REPL isn't as big of a deal as everyone thought.
So I'd like to ask all of you: Do we love Go in spite of being held back by it? If so, then what are the factors that cause us to decide that using Go is worth giving up programming power? After all, each of us are choosing to use Go in lieu of more powerful languages. So why do we choose to give up programming power?
Or do you believe in the other possibility: having a REPL doesn't matter as much as everyone thought? That seems plausible. It's at least as plausible as "it's a good idea to give up REPLs for static typing."
Go is wonderful to work with. But I'm so confused why it feels wonderful to me. I know I love programming in it, but once I start thinking about the implications, I start to wonder: Isn't giving up power a bad thing, and therefore choosing to use Go == choosing to be forever held back by its deficits, and therefore it's a bad decision? Or is it true that having every possible language feature available to you ("maximum potential programming power," i.e. as far above Blub as possible) isn't as big a deal as we all thought?
This pg essay talks about why it's worthwhile to have as much power as possible: http://www.paulgraham.com/avg.html (search for Blub Paradox) .... So either he's wrong, or we're ignoring him even though he's right. Which is it?
EDIT: There are other limitations besides lacking a REPL, e.g. there's no dynamic typing. It seems like we should try to figure out why it's a good idea to give up any programming power at all.
So we are pleased to see Go being used for the job it was designed for, but we are also happy to see that Go has a broader appeal.
This sounds a bit like revisionism. Rob Pike made it clear that the initial motivation for Go was the slowness of the C++ compilation.
Go was clearly initially targeted at replacing C++ and it's not being successful in that area at all.
Personally, I think it will grab a decent amount of Ruby and Python programmers but it won't go much further than that.
This is a strong overstatement. It's true that we thought more C++ programmers would be into Go, but it's also true that there more than a few teams at Google that have moved from C++ to Go, or chosen to use Go instead of C++ for new projects. It's not a black and white thing; there is no archetypal C++ programmer that does or does not like Go.
To reiterate: Go was designed for systems programming. People are using Go for systems programming. On top of that, there are many others using Go for other purposes. We're pretty thrilled about this.
Or, was adding garbage collection that big a need? GC of course makes Go quite different from C++, so they should not be surprised if some "speed demons" refuse to convert over. (note that I hate C++, but can see the point of this aspect)
Most of the software we build at Google are server processes that talk to other server processes. Go was designed primarily for this role, but it is obviously useful for a lot more.
1. So we don't get generics, but the language built-ins seem to get to be type-parameterized (channels, slices, maps). Unfortunately the syntax for doing so for each of these is inconsistent (probably as a result of being special-cased rather than dog-fooded using language-level generics): []float, map[float]float, chan float.
2. Built-in types seem to receive other special treatments as well, which includes special initialization keywords (make vs. new) and built-in functions (len, cap, etc.) but I don't see why this needed to be the case, even for performance reasons. There's no reason why the these built-in types couldn't pretend to implement built-in interfaces to make more transparent with user-types while having the compiler optimize them with special-case functions for efficiency.
3. Unused variables are a hard error which is a completely understandable stance. Unfortunately, I think people may use workarounds to get around this. Also, I can't believe unused variables are a hard error, but uninitialized variables are not! Instead we are supposed to trust that everything is OK since they get initialized to some kind of "zero" value that isn't even under the developer's control.
4. Other small quibbles: I think pattern matching on function arguments could have been implemented as sugar that uses interfaces and method calls under the covers. Also named return values are ugly, and the function declaration syntax could have been made more concise.
Like many well designed and well engineered things, I think familiarity and time cause that satisfying feeling to blend into the background and become the norm. You only realize the difference again when you have cause to use some other tool laying around (I just need to pound this nail I will just grab this random hammer laying here) and it "feels" different -- the weight is wrong or the grip is weird.
I by no means claim Go is perfect, but it seems to a great match for the kinds of things I tend to work on, and it "fits in my hand" rather well these days.
Wow! The state of C++ searches on google were 0 in 1987, as were searches for "Apples" and "Oranges" so go must be doing incredibly well to have infinity times the results!
Which doesn't seem to matter anyway. There are tons of languages released every year that fare even worse than languages released in 1980, despite having "ubiquitous-internet, Github and widespread blogging" at their disposal.
Anyway the hype is surely not the reason why anyone should use go. People should use go because it has good libraries, encourages good interfaces, is fast and space efficient, has good self documentation, is easy to test, etc.
Who's to say that a similar thing isn't happening with the current latest and greatest tools?
There was and continues to remain NOTHING that compares to the Java platform.
XML is still the right tool for the job for many use cases. JSON is great for serializing data structures. XML is great for marking up various types of textual data.
Other people have already covered your comment on Java.
In the 90s, before Java, you had C/C++ dominating server based code that wasn't COBOL (Smalltalk tried to compete, but it's failure is a whole different story), with BASIC/Delphi/PowerBuilder/OracleForms/arguablyMFC dominating UI based code.
I will grant that Java gained a lot of buzz due to Java Applets in the browser and with deceptive claims regarding how portable AWT and later Swing applications were. But for server side business application coding (NOT systems coding), Java blew C/C++ out of the water.
C++ on large projects, especially with the feeble template compilers at the time, had insanely long compile/link times. It wasn't unusual to kick off a build and have to wait an hour or more to be able to test it. It's true you could break things up into dynamic libraries to try to reduce link times, but that meant more work, especially if you had to run on different platforms. And there were specialized tools like ClearCase's ClearMake that could speed things up, but they were far from commonplace.
Java for server based code compiled quickly and eliminated the link times (well, it moved linking to runtime, but effectively it also made each class into it's own mini shared library). And Java stack dumps were orders of magnitude more useful than C/C++ core dumps. Performance was slower compared to C/C++, but faster than interpreted languages at the time, and generally "fast enough" for most business applications.
Java's JDK also provided a lot more "out of the box" functionality than what you had with the C++. Heck, even just having a standard String class was tremendously more useful than having to deal with char arrays. And the collection library was feeble, but it was there. (The C++ STL wasn't released until 1998, and RogueWave was probably the closest thing to a de facto C++ library, but it was a commercial product).
The rise of internet e-commerce also convened to help Java out. A lot of sites started with cgi-scripts, which had to launch a new process for every CGI request. Even C/C++ CGI programs were slow because of this. Java's servlet spec provided a very convenient way to run multiple requests in a single process, which was typically at least an order of magnitude faster than CGI at the time. And it was much easier to write servlets than to compile a custom Apache C/C++ module into your apache distribution.
And for as many headaches as Java caused for "cross platform" UI code, it actually worked pretty well for cross platform server side code. Gone were the spaghetti pragmas from cross platform C/C++ code.
So what happened with Java is that the applet/UI buzz got in through the enterprise door, but it's server side conveniences are what enabled it to gain tremendous enterprise acceptance. And IBM jumping on board the Java ship was somewhat of a green light for COBOL shops to move to something else that was still blessed by IBM.
>> XML was pretty big back then, too
XML really didn't come about until the late 90s and was really more of a 2000s buzzard. It's being rightfully replaced by JSON for a lot of browser/server interactions, but for better or worse there are still quite a few places that it's sticking around.
There WAS an industry in 1987 and people who are around now were also around then, and can compare how well Go does compared to how well C++ did circa 1987.
Hopefully in 4 years when Golang developers are in demand, I have 4 years of experience under my belt. :)
These skills will transfer very well into other programming languages.
It may be better than Python for some kinds of large applications programming, I don't know. But since a lot of apps do need the simple scripts and the application logic, it's kind of nice to have them all in the same language - which is one place where javascript may take over more, I suppose, if ever they can convince OS designers to build node.js tools into the default installs...
Oh really? Checking every single function call for an error return code doesn't complicate things?
It's more than unfair since they don't show any numbers. At all. Not for Go, not for Java, not for anything.
The graph is cute but it's not even a number of installations, projects on githubs or lines of source code: it's Google searches. Searches measure nothing more than buzz. I bet Google Wave showed similar curves facing up for months.
If the Go team had hard and impressive numbers, I bet they would show them. The fact that they don't makes me think that Go is not seeing a lot of traction, besides a few Python and Ruby programmers.
Has anyone come up with a good solution to this? Preferably using Vim tooling.
:Drop fmt
to remove package "fmt" from imports, and :Import fmt
to put it back.However, it doesn't impact whether I enjoy writing Go code or not. It tends to be mitigated by blessed built in types and functions with parametric polymorphism (e.g., `map`, `[]`, `append`, `delete`, etc.) in addition to Go's structural sub-typing and type embedding. First class functions help too.
Actually, this results in a really nice aspect of Go that I've come to appreciate: reading and writing Go code tends to have very little cognitive overhead. Things tend to be very straight-forward and clear. I'm not sure if this is because there aren't generics, but I have my suspicions that it is. The language itself and its semantics is very simple and can fit in your head easily. But this is my experience, YMMV.
Dirty little secret: sometimes I cheat a little when writing small commands in Go and sacrifice compile time type safety by using my `ty` package.[1]
[1] - http://blog.burntsushi.net/type-parametric-functions-golang
The problem is Go lacks immutable data structure. I believe everybody know why immutable data structure is required. Go slice and map are all mutable-only, so to make some read-only data view, we need to write all the containers by hand. Amount of code increases exponentially.
It would be great if Go had such a immutable slice/map stuffs, but they decided not to have that due to legacy compatibility issue with existing []byte/string(which is actually just an immutable view on []byte) types.
So now the only hope is generics. I don't want to write hundreds of same list/map classes just to offer immutable views. That's all duplicated works, and I just want ability to write List<T> and Map<T>.
If you don't think immutable data structure or view is not important, Go is good enough to you. But that feature is crucial to me, and that's one of the biggest reason of why I stopped using Go.
I got a half-working solution [4] with a lot of interface{} and some reflection, but upon speaking with some of the Golang devs, the consensus was "this is not something you do in Go." From what I understand, you're expected to build a custom memoizing function for each set of datatypes you're expecting to use it for (which admittedly is not a ton of code), and generic helpers are not advised.
I can't say authoritatively whether "Go needs generics!" or not, but life has been much easier after porting my code back to Python—though a large part of it was because it was a fairly dynamic webapp which is still a pain point for Go. I hope to give Go another try soon, probably for a different project.
[0] https://pypi.python.org/pypi/dogpile.cache
[1] https://pypi.python.org/pypi?%3Aaction=search&term=cache&sub...
[2] https://pypi.python.org/pypi?%3Aaction=search&term=memoize&s...
[3] http://docs.python.org/dev/library/functools.html#functools....
To me, it just seems ugly. I like a type system where I know what a type is at each point, and there isn't some ugly "catch all" type that you can use when you run out of other options, which effectively just throws away all type information (and this is what interface{} does, as everything implements it).
public T Get<T>(int id, string cacheKey) {
}
When I consume it and say Get for User object, I expect an User object as I already know it's type.In Go, you have to return an interface (and ideally an error)
Here would be the equivalent,
v, err := s.Get(id int, cacheKey string)
if err != nil {
//Handle error here
}
if v == nil || v.(*models.User) == nil {
return nil, http.StatusNotFound
}
Its a bit more code, but on the flip side, it gets you thinking as a client of all the things that can go wrong with your code interface Fooer {
func Foo()
}
type Bar struct {}
func (s Bar) Foo() {}
func (s Bar) Baz() {}
func DoFoo(f Fooer) {
f.Foo() // fine
// f.Baz() compile error
f.(Bar).Baz() // fine
}Yes, that is one of the reasons I eventually moved to D.
And the rise of interest in "golang" in general seems to correspond to the massive spike in China [ http://i.imgur.com/Y3oO2jf.png ].
I'm not really sure what that means...
Also, in my experience, very few (mainland) Chinese play weiqi. Everyone plays Chinese chess, but very few play Go. So people searching for "go" are quite likely searching for the language. (Although I'd expect that the people who know about the language know enough to search for "golang", so who knows)
http://www.meetup.com/Go-London-User-Group/events/147685182/
Don't worry about the waitlist, people always drop out nearer the time.
Yeah I was been ironic but go is quite a nice language =)
Ok, so now I really have to attend next year's FOSDEM.
After compiling Android a few times, though, you'll appreciate what the Go team was talking about when they said C++ compilation time was a driver for them.