297 points · by enneff · 14y ago · 182 comments
When asked about surprising things about Go, its creators have said that they expected to recruit people from c++ communities, instead it seems to be more ruby/python people.
And it's interesting to see Python and Ruby being squeezed lately, from various directions; Clojure, Go, other languages. Since Python went mainstream and started being picked up for serious projects, it naturally came under the spotlight a lot more than it had previously, and I think many people have started to see some of its warts. The transition from version 2 -> 3 wasn't exactly a smooth one, either. Furthermore, although Python is a pretty good all-round language, it doesn't really excel at anything in particular, unlike for example Perl which continues to maintain a strong niche in the areas of text processing and system administration, despite its popularity having fallen away in some of the other areas it was formerly strong in.
In my case, although I have recently moved from Perl to Racket for larger and/or more complex work, I still use Perl a lot for small, simple scripts (which constitute most of my programming). A couple of the Java guys I know switched from Python to Clojure for scripting tasks (I could never convince them to like Perl..), and have started to take an interest in languages like Scala and now Go for more substantial projects.
For many years now, Python has been the fresh, fun challenger going up against older (and perhaps clunkier) languages, whereas now things seem to be shifting and Python may soon find its role has reversed and it has become the old, crufty language.
I basically agree with this as a Rust developer (although I'm not sure about Go being in Java's niche; I think of it more as in node.js's niche -- highly scalable web apps). Early on, I think both Rust and Go were thought to be targeting the same segment, but it turned out that we really weren't. Personally, I'm completely fine with that; different language designs are appropriate for different roles. The huge amount of work that we've done to make non-allocating and manually-memory-managed code easy, predictable, and type-safe is totally overkill for Go's niche, for example, while for games and web browsers this sort of thing is essential.
With C++11 it now has a foot in the concurrency niche. The question is, whether C++ can keep its niches or if lots of different languages will chew away its market share on various levels.
I'm going to elide any commentary about the syntax for now, as I know why it is the way it is (the type system/annotations). I'm basically just going to expound on one thing for the sake of emphasis.
For the love of god make Rust more accessible. I don't mean dumbing down the type system or abandoning regions (I really hope that works out). I mean the frickin' documentation. Digging through the core libs to figure out how to dp fairly common case stuff is obscene.
Part of the reason I like to tinker with Go in my spare time is that it's extremely hygienic, clean, cheap, and cheerful.
Look at the way the "go" binary works, it does everything. It does builds, automatic formatting of code, the works. And it just "works".
On top of that, I'd consider getting somebody more knowledgeable about Rust and get them to team up / pair-document with somebody who is a goddamn dumbass like me and start building tutorials/documentation together.
I can't imagine the language's syntax and features are so nascent that tutorials and docs for core functionality/libs would be out of the question, you're already prototyping that web browser engine.
Documentation is a UX problem, like syntax. Syntax alone crippled Erlang, please don't let obscurity harm a language I am very excited about.
If there's any way I can help (maybe a trail of bread crumbs/notes from me as I try to learn it?), let me know in this thread or via email.
I'm a geneticist whose (work) code is centered around data processing. I previously used Perl for just about everything (although I've used Python & Ruby also), but started to broaden my programming horizons recently, and after a grand tour of what was on offer I settled on Racket as my language of choice for the more complex end of the scripts I was writing. I'm finding it easier to maintain (and especially refactor) complex scripts in Racket than I did in Perl (or Python or Ruby), and the increase in performance is substantial when processing huge data-sets. One current weakness of Racket here is the relative lack of specific libraries for bioinformatics, but most of my code doesn't need any anyway and when it does I revert to Perl.
I'm also excited about investigating other areas of the language, especially Typed Racket, as static typing is something I haven't really utilized so far.
In general, the more I learn about Racket the more I admire the quality of design that has gone into it; everything seems to be extremely well thought out, not just from a theoretical perspective, but from a practical one too.
Well, it does excel in scientific computing. Biologists, astronomers and such use it a lot, and it has lots of advanced math/stats/physics etc libs, with fast C implementations underneath.
links: http://en.wikipedia.org/wiki/BioPerl | http://pdl.perl.org/
And since a lot of Java shops are fantastically risk averse I'm not at all surprised that the same kind of people that were willing to take a risk on Python or Ruby are now into Go. It offers a lot of the expressiveness of either of the former with much better performance, concurrency as a fundamental, and the extra safety of static type checking.
Python and Ruby programmers come to Go because they don't
have to surrender much expressiveness, but gain
performance and get to play with concurrency.
C++ programmers don't come to Go because they have fought
hard to gain exquisite control of their programming
domain, and don't want to surrender any of it. To them,
software isn't just about getting the job done, it's
about doing it a certain way.
The issue, then, is that Go's success would contradict
their world view.
And we should have realized that from the beginning.
People who are excited about C++11's new features are not
going to care about a language that has so much less.
Even if, in the end, it offers so much more.I just can't see Go as an alternative to C or C++, and I'm quite surprised that anyone (especially someone such as Rob Pike) could.
Sure there are situations where a program that typically would have been written in C/C++ could benefit from Go (so there is a place for it), but the reasons for choosing C/C++ are often the same that makes Go a really bad fit.
My dreams of a C-like language where the dangerous parts have been removed (and in this context I don't consider having control of your memory dangerous) took a hit with the introduction of Go :(
I call BS. The parent explanation is much better: for a lot of the kinds of jobs C++ is good for, Go is not that good, whereas for a lot of things Python is good for, Go is as good and has better performance.
If you're writing realtime code, you can avoid triggering the garbage collector simply by not allocating memory on the heap. It is harder to get anything done this way, but writing realtime code in any language is difficult.
But there's a huge uphill battle ahead for Go here. For instance, I write C++ code because I'm doing music software and all the APIs and existing code libraries and samples are in C++. It's just so much easier in this environment to put up with C++'s warts than it would be to try to shoehorn Go in there. As John Carmack says, externalities can quickly overwhelm the advantages of any particular language.
But if you're implementing web services from scratch you don't have any of that baggage to carry around so it's much easier to choose Go.
This is true only for very limited meanings of "anything"; if your point was that you had direct control of memory layout and you can use CGO for those things that C offers but go does not. For instance, the volatile keyword..
Most things don't seem surprising in hindsight. That's why you don't judge surprises by it.
If C++ programmers did flock to Go, would you then say that that was surprising? If not, you've just fallen victim to hindsight bias (because a model that predicts everything is useless).
Surprising was GP's original term, not mine.
I don't expect Go or any other language to displace C++ any time soon. But I do think the "scripting" languages are very vulnerable to challenges from languages with static typing systems less primitive than Java's.
As someone who has been clamoring for a statically-checked Python-esque language, Go looks awesome.
I'm aware of gohaml; but last I checked it hasn't been updated to work with Go1 and friends. Namely it's using `gomake` and the packages aren't organized for use with `go build`; those issues alone have stopped me from considering it.
I went for a version of mustache.go instead, and then bolted Lambda support onto it.
At one end there's flat HTML files, where you could serve 800 million pages/month from maybe a single particularly beefy server; at the other fully-dressed SOAs and CEPs and your uncle's pet dog rover performing multivariate regressions, meaning you need 9,000 servers.
It seems extremely high for what my absolutely-no-idea-what-these-sites-could-possible-need-that-many-servers-for thought process can fathom.
Two of my customers are doing 500mio and 400mio respectively on ~20 each, on Rails (i.e. as slow as it gets).
Moovweb creates mobile versions of standard websites on the fly. That sounds pretty expensive, and they probably have a ton of network overhead from distant servers and slow clients.
Is that still the case with the latest version 1.0.2 ?
Also, is there any chance for a precise generational garbage collector to get implemented for Go? As far as I know, pointers make the implementation of precise garbage collectors difficult.
edit: I think it's this one: http://youtu.be/sln-gJaURzk ("Meet the Go team"), but maybe some other from: http://blog.golang.org/2012/07/go-videos-from-google-io-2012... (sorry, don't have time to watch them all again now to make sure ;)
If you run a 64 bit server then these problems just goes away.
And from all accounts these issues will also be fixed for 32 bit systems in then next Go release or two.
Using the net/http package that comes with Go.
>>Can anyone point me to a basic tutorial?
To learn Go - http://tour.golang.org/
To learn about http http://golang.org/doc/effective_go.html (A list of available functions are found here http://golang.org/pkg/net/http/)
Gorilla is a great web framework that builds upon the net/http package - http://gorilla-web.appspot.com/
>>Is it still running under something like Apache is golang IS the server somehow? If so Wouldn't each http request have to fire up the compiled executable?
What you are describing is CGI (http://en.wikipedia.org/wiki/Common_Gateway_Interface) whilst it could be possible but don't for real severs its really old and slow.
It is extremely fast.
The main risk is process failure which is very rare but can be mitigated via putting a front end balancer such as nginx or apache mod_proxy. Process recovery and spawning can be managed by another tool such as supervisord.
However, you can run a process happily from init if you desire.
Does writing your own server in Go kind of violate this idea? Are you opening yourself up to re-inventing a web server and repeating decades of mistakes something like Apache has already figured out and fixed?
You are writing a bunch of handlers (as you would with Apache) and plugging them into the compiled in web server from the standard library.
For network servers, there is standard library support for SMTP, HTTP, normal stream based text protocols etc as well as serialization formatters and parsers for JSON, XML, HTML etc. You should never have to re-invent the wheel.
These building blocks are very complete and are all available in the standard library. This means they are tested, debugged, tested again and have become pretty damn robust.
The point about Apache/NGinx being well established and battle hardened still stands, but Go's library is quickly following suit.
What Go offers over the others in this respect, is that you do not have to settle for a monolithic one-size-fits-all package. The code you write in Go does one thing (serve your application) and does it well without any compromises.
So is there anywhere I can see an example of code that runs a server like this?
// this defines the entry point
package main
// import formatting and HTTP server packages
import (
"fmt"
"net/http"
)
// This is your HTTP Server instance
type Hello struct{}
// This is a method on your HTTP server instance that sends hello for all requests
func (h Hello) ServeHTTP(
w http.ResponseWriter,
r *http.Request) {
fmt.Fprint(w, "Hello!")
}
// this is your entry point
func main() {
// create a new HTTP Server instance
var h Hello
// tell the runtime to serve it
http.ListenAndServe("localhost:4000",h)
}So... 95% of their production system is running Go.
I'm curious what the 5% is that they didn't convert to go.
"100% of our production system is now running Go as 95% of our application (C being the other bits). Not side bits, but our critical path."
Basically, once you are 95% Go, what parts are hard to convert to Go to make it 100%
It will take some time to replace 40 years of existing accumulated C libraries.
Go is still very young, a better GC will come, just give it time. In the meanwhile, let's not pretend that the current sub-par generator is as performant as that of modern JVMs.
And with Go if you really care, you can be even more careful and produce close to no garbage.
Control over memory layout is really useful.
GC is an area where always there is room for improvement, no matter how much you work at it.
gccgo does better at some things, but the default compilers do quite well already.
Really? in 2012?
Additionally, cookies can be marked as http only or even as secure, making it very hard to lose the token by virtue of a fire sheep like, or even just XSS attack.
For that reason, I personally would prefer a site using (session) cookies to one hacking it via DOM storage any day.
And finally, depending on the store you might want to persist the shopping cart between visits- likely across machines. Thus, the cart should be stored on the server and not in DOM storage.
I suppose it's better than 1990s websites that would go into an endless loop but what about people who are just browsing?
Session cookies on the other hand can be marked as http-only, mitigating XSS in many browsers (there are some that still screw this up with XmlHttpRequest) and by not having the session id in the url, the id is much less likely to be shared with others, nor to appear in search engines.
Also, it keeps the URLs nice looking.
So why exactly would one want to disable session cookies?
Because of all of the above reasons, I'd much rather keep users with cookies disabled away from my application than to subject them to the ugly URL fallback which will impact their security much, much more than the perceived privacy loss of session cookies (which go away when you close the browser)
Or, if you insist, at least do not expect to use any web app / sales page, anything without them.
We search with Google, run our phones with Google, run Google's browser, now they want us to write all our code in Google's language. Why Google? What's wrong with Java? Other than the fact that Oracle owns it, I miss Sun. Scott McNealy tried to make the technology world better. Scott, Gosling. Google...why should everything we do all day and night be about Google?
http://en.wikipedia.org/wiki/Go_(programming_language)
>> The syntax of Go is broadly similar to that of C
C, seriously? C??!? Why? Why would I want to go back to ... C?
>> Of features found in C++ or Java, Go does not include type inheritance, generic programming, assertions, method overloading, or pointer arithmetic.
And that is a good thing or a bad thing or what?
>> Go allows a programmer to write functions that can operate on inputs of arbitrary type, provided that the type implements the functions defined by a given interface.
Huh? Oh I can pass interface references, ok.
>> A Go interface is best described as a set of methods, each identified by a name and signature.
That sounds like Microsoft's crappy COM from the 1990's.
The code sample on that page shows there are no braces in the if evaluation statements. A wise man, Peter Van Der Linden formerly of Sun's Compiler Group and author of Deep C Secrets wrote about using more braces if needed as explicitness is always better. I agree with that.
At this point, I think I'd rather program in Groovy or even go to JavaScript if I had to, than use Go.
Oh...the language name sux.
Tip, buy Oracle and fix Java or by Java rights from them and fix it, then programming in a language owned by Google when you own so much of our lives now wouldn't be so bad.
PS How does Guido Van Rossom feel about Go?
For those, like myself, that like C and do systems programming. Really never understood why people dislike or fear C so much. It is the foundation for so many systems and libraries.
>> The code sample on that page shows there are no braces in the if evaluation statements.
This is just Go's style but look you can still use braces. http://play.golang.org/p/_j7r6GB-ZN
Which language name were you talking about?
Which is also open source and has a community behind it.
(Plus, you can search with Bing, run an iPhone, and run Safari/Firefox/IE)
>Why Google? What's wrong with Java?
You mean besides the stagnation (no closures? no type inference? no functional goodness? It's 2012 already), the enterprisey vibe and the lawsuits?
>>>The syntax of Go is broadly similar to that of C C, seriously? C??!? Why? Why would I want to go back to ... C?
They don't ask you to go back to C. The SYNTAX is similar. Which is also true for Java.
That said, from reading the rant, you don't seem like the type that ever was in C in the first place, so it wont be "going back" for you.
>>> Of features found in C++ or Java, Go does not include type inheritance, generic programming, assertions, method overloading, or pointer arithmetic.
And that is a good thing or a bad thing or what?
That is what it is. Languages have different features, and it's not a spec war.
Java doesn't have tons of features C++ has (e.g operator overloading, pointer arithmetic, hey, even closures, as of the latest standard). But you don't seem to be the type that wants to go to C++, right? So why the double standard?
>>> A Go interface is best described as a set of methods, each identified by a name and signature.
That sounds like Microsoft's crappy COM from the 1990's.
Yes, I can see how you are qualified to make this kind of comparisons: "Interface of methods, with name and signature. Ah, just like COM!"
>The code sample on that page shows there are no braces in the if evaluation statements. A wise man, Peter Van Der Linden formerly of Sun's Compiler Group and author of Deep C Secrets wrote about using more braces if needed as explicitness is always better. I agree with that.
Good for you. You missed the "if needed" part.
>Oh...the language name sux.
And Rob Pike pissed on your cornflakes.
>PS How does Guido Van Rossom feel about Go?
Why should we care?