I'm Jonas Galvez, a software engineer and internet entrepreneur from Brazil.
I specialize in web application development in Python and Go and work at LaterPay GmbH.
October 28, 2012
Go is the first language that truly excites me since Python. Created by Unix pioneers Rob Pike and Ken Thompson and Google researcher Robert Griesemer, Go is powerful, minimalist and embraces pragmatic development ideas everywhere. As exaggerated as this article's title may sound, I have a honest feeling of enthusiasm about this new language and I hope to highlight my motivations here.
My language of choice for writing backend code for my own projects today is Python. I have always loved Python, but was drawn to Ruby because of Rails like most people and spent 4 years working as a Ruby developer.
At that time I was still a rather inexperienced engineer so I'm grateful for not only what Rails taught me, but how it managed to gather an entire community of people enthusiastic about lean and pragmatic web development.
Before I had my first job at a startup, I was a huge Python fan and tried CherryPy, but compared to Rails it just seemed way too boring. I kept trying to go back to Python though. I tried (and quite liked) web.py and later Django, but Rails and even Sinatra in all its minimalism still felt a lot more pleasant and elegant to work with.
I tried Tornado and Python Paste. I spent a whole year writing Django code for a large website with hundreds of thousands of active users. All these Python web frameworks still failed to make me feel like I was on the right direction. The problem I have with Rails is the same problem I have with all the others: way too much code under the hood, and way too many abstractions. I started wanting a framework that would make it as easy as possible to come up with my own code structure, and if I ever needed to change anything, I wouldn't have to spend a week grokking somebody else's entirely arbitrary and overachitected abstractions. HTTP, caching, database handling, session management, asset management: I needed a lot more control over these aspects than most frameworks were willing to naturally give.
What finally dragged me back to Python for real was Armin Ronacher's Flask microframework. Flask is everything I always wanted in a web framework, written by a guy who seems to share this vision of minimalism (and a lot more prolifically so). After Flask emerged, my web development toolset seemed complete. I would use Flask for all my backend code and be happy. Nevertheless, I always knew if push ever came to shove, I would need to have a faster, more powerful, industrial language around to deal with the really hard problems. I knew I would need to keep resource usage to a minimum or be ready to spend on servers.
Confronted with this possibility, I always told myself I'd keep using Python for all components until it was absolutely, unequivocally required to use something else for speed and scalability. I always imagined this something else would be Python-flavored C, like Cython.
I've been hearing good things about Go for over a year now, and in the past few weeks I've been reading more about it and trying it on my own projects. It was Rob Pike's Public Static Void talk from OSCON 2010 (slides) that finally sealed the deal for me. This talk is over 2 years old and has been on my Pinboard video queue since longer than I can remember. I finally watched it a few weeks ago. Rob Pike effectively and humorously exposes how ridiculously complicated, or as he says, bureaucratic, programming has become: "If you have to foo that often, somebody's not fooing right."

That is Java, by the way. Trashing Java and C++'s verbosity is beating a dead horse. I'd be surprised to find a developer today who hasn't switched or at least considered switching to a dynamically typed language like Python and Ruby for the majority of his or her work, even Java and C++ developers. That is another point Rob Pike makes in his talk. The problem is that we still often end up actually needing those languages for building industrial-strength software. Twitter is a classic example well covered in the Ruby on Rails community. Twitter was written in Rails but had to resort to Scala for several services in its architecture when it started growing like hell.
Personally, neither Scala nor Clojure managed to capture my interest. They're a paliative solution to a largely ignored problem: we're still relying on old and bloated programming languages to achieve the performance required in big web applications, while it's clearly understood and agreed upon by now that they tend to become a productivity bottleneck for programmers. Rob Pike says he resonates with the quote below because it is a concise description of much of what's wrong in the software world right now. I do too.

C is a good example of a simple, elegant programming language that gets the job done. Is it the answer? I don't think so, but I have for a long time believed it would be better to spend whatever time it was needed to master C and use it for writing Python extensions, than to give in to Java or C++. But the delivery schedules of startups simply don't have a place for the full embracement of Unix purity. C is too time-consuming for big projects on a deadline.
Python is still my main language for web development. All my personal projects are written in Python and after having accumulated so much experience with it, I can't simply let go. Python has wonderfully saved me from a lot of typing and can still bring a tear of joy to my eyes from its elegance and minimalism. It's still my bread and butter. But the sentiment I have right now is that as soon as I'm completely comfortable with a reasonable amount of Go's idioms and standard library, there will simply be no reason to continue using Python when I can start with a truly fast and scalable language from day one. But what is broken in Python that can't be fixed?

Paraphrasing Bruce Eckel from his classic Why I Love Python presentation, Python doesn't value performance over productivity. I'm the kind of guy who doesn't like getting anything done on a cluttered desk. I am surely able to, if I have to, and at many times, if I'm too lazy to unclutter.
But I realized that I can reach an incredibly higher level of focus and productivity if I take the time to tidy everything up before work. I don't even fight it anymore: it became part of my work ritual to unclutter before anything else. I have no doubt I function better when there are absolutely no distractions in sight. Anything in your sight not directly related to your object of focus will generate cognitive noise.
Some people have amazing tolerance for noise. I don't. I know most people don't, otherwise I wouldn't have witnessed so many stagnated, broken projects written in languages that promote clutter at the syntax level.
And that is the point I'm trying to make. It's surely possible to write cryptic code in Python, it's just not part of its culture and it's definitely not incentivated by its syntax. Python code is made up from simple concepts and simple idioms. The problem is that it's just too simple for its own good. It is slow, not type-safe and very poor at scale.
Go is past 1.0 and is already being used in production big time. Go's goal is very clearly defined as achieving the same benefits of dynamically typed languages in a lean, modern and statically typed low-level language.
It is revolutionary.

The best place to start is A Tour of Go. It's an efficient introduction that manages to present you with nearly all concepts about Go in 72 slides. It can be a little overwhelming. Due to my JavaScript and Python background, a few of these concepts really stand out to me:
Names are placed before their types, which makes statically typed code a lot more easy to read (just like ActionScript 3, Adobe Flash's JavaScript powerful spin-off). Functions are values too, just like in Python, Ruby and JavaScript (and possibly others that are not relevant to me).
func add(x int, y int) int { return x + y }
As you can see, no parentheses. Braces required, parentheses forbidden. Go has a simple rule for dealing with semicolons. I like the fact you can drop indexes altogether in an iterator by simply using _ (in_list). I like the fact you can specify the name of the return variables at the function declaration (make_list). I like the fact you can place a statement just before an if block (main). It's intuitive:
package main import "fmt" func in_list(x int, list []int) bool { for _, value := range list { if value == x { return true } } return false } func make_list(length int) (list []int) { list = make([]int, length) for i := range list { list[i] = i } return } func main() { if numbers := make_list(10); in_list(4, numbers) { fmt.Println("Found in list.") } }
Like in JavaScript, there are no real classes or methods. Go simply has the ability to associate functions to struct types. Sounds familiar? JavaScript works the same way with its prototype-based inheritance. In JavaScript, every object gains access to methods that are available in whatever object is referenced in __proto__. So if you already know how this makes sense in JavaScript, Go will feel similar but better:
package main import "fmt" type User struct { name, email string } func (u *User) PrintNameAndEmail() { fmt.Printf("%s <%s>\n", u.name, u.email) } func main() { user := &User{"Jonas Galvez", "jonasgalvez@gmail.com"} user.PrintNameAndEmail() }
Go's concurrency is based on goroutines. They should not be confused with coroutines, like the ones possible with Python's iterators and generators. Goroutines use channels to communicate, which act similarly to UNIX pipes. They can be synchronous (unbuffered) or asynchronous (buffered). Channels are like pipes and queues from the Python multiprocessing module, with send (<-channel) and receive operators (channel<-). Very straigthforward and clean:
func Query(conns []Conn, query string) Result { ch := make(chan Result, 1) for _, conn := range conns { go func(c Conn) { select { case ch <- c.DoQuery(query): default: } }(conn) } return <-ch }
If there's anything cryptic about this example, is the usage of an anonymous function (like you do all the time in JavaScript) preceded by the go keyword. The go keyword makes the function run in the background, much like Unix shell's & notation, abstracting away much of the complexity of traditional thread management. Once a goroutine completes, it exits silently and gracefully, unless you force its output upon a channel. The main program can try and receive messages from goroutines running the background using the select control structure in the listing above.
Go is ruthless against clutter, bad code formatting and unnecessary dependency inclusions. The documentation encourages running the gofmt tool against all your code. It enforces a few formatting conventions in the interest of creating a unified coding style across codebases. Obscure code and one-liners are strongly disencouraged. Also, if you import a package and make no use of it your program will simply not run. Zero tolerance for clutter:
./user.go:4: imported and not used: "strings"
Go is here to stay. It has very pleasant concepts and a very clean, minimalist syntax. I'm curious to see how it will pan out in the next few months, as I've already started rewriting some of the Python code in my personal projects in Go. Make sure to read the following presentations: