Google-code-as-a-service: Go on App Engine
Python, Java, and a custom tailored suit
In beginning, you could only use Python with Google App Engine, the online service that lets you run applications atop Google's famously distributed infrastructure. Then, after countless requests from developers, Google added a Java runtime to the service. And now the company is adding a runtime tailor-made for the service.
The rub is that this runtime is used by almost no one. But that may change.
This week, at its annual developer conference in San Francisco, Google announced that App Engine will soon offer an "experimental" runtime for its own Go programming language, a less-than-two-year-old creation that seeks to reinvent programming in the most practical of ways.
Go was first conceived in 2007 by three big Google names: Unix co-creator Ken Thompson; Rob Pike, who worked on Unix at Bell Labs with Thompson; and Robert Griesemer, who helped build the Java HotSpot compiler at Sun. The idea was to create a language suited to building the sort of distributed applications that Google builds. "We realized that the kind of software we build at Google is not always served well by the languages we had available," Rob Pike recently told us. "Robert Griesemer, Ken Thompson, and myself decided to make a language that would be very good for writing the kinds of programs we write at Google."
This means that, like Erlang, Go offers built-in tools for concurrency. "The world is concurrent and parallel. But the programming languages we use to interact with the outside world – through users on the web and mice and keyboards on a local machine – they don't tend to support that way of thinking about things very well. There was a lot of interesting theory work on this, but very few practical languages."
And so, like C, Go is a statically-typed, compiled language. But it's also meant to "feel" like a dynamically-typed language along the lines of Python. "For large programming - programming in the large, like we do at Google, using large systems with many programmers working on them - static [typing] is a huge safety net. It catches tons of stuff early that would not be caught with all-dynamic typing," Pike told us. "Go is a real systems language, a compiled language. You can write really efficient code that runs closer to the metal. But you can use these higher-level ideas to build servers out of the pieces you put together."
At this week's conference, reporters seemed mystified by the addition of Go to App Engine. But Peter Magnusson, the Google engineering manager who oversees App Engine, explained that Go is particularly suited for use on a "platform-as-as-service" like App Engine, which operates very differently from an "infrastructure cloud" like Amazon EC2. Whereas an infrastructure cloud exposes raw virtual machines, a "platform cloud" operates at a higher level, attempting to share resources with even greater efficiency.
"When you're looking at platform-as-a-service versus infrastructure-as-a-service, there is a fundamental challenge in running arbitrary binaries. You can do this on infrastructure-as-a-service, but you can't really do it in the high-level, multi-tenant, shared environment of a platform. So we have to control the languages that run there. We have hundreds and thousands of apps, and we have to have very strict guarantees that there's no leaks and no impact between them," he said. "But at the same time, there's a need for a low-level programming language for compute-intensive tasks."
That language is Go. One of its chief strengths when running on a platform-as-a-service, Magnusson said, is that it was designed for quick compilation. "Go was designed from the outset to be quick to compile. ... It compiles really fast even with a really large application. That allows you to deploy it on a platform-as-a-service like App Engine, where you upload the source code and compile and link and run it," he said
"The compilation linking is so fast, that it's just as fast as uploading the binary, or arguably faster. So it allows you to provide a low-level programming language on a platform-as-a-service. That's why Go is an interesting addition, as opposed to a lot of other languages that we might add in the future. Go provides a fundamental benefit that Python and Java don't."
But Go isn't just fast at compile time. It's fast at runtime as well. Google says the speed is comparable to C. Martin Odersky – the creator of Scala, another language that focuses on concurrency – tells us that a research paper is in the works showing that C, Scala, and Go provide comparable speeds at runtime. Google says that on App Engine, Go is particularly suited to CPU-intensive apps because it compiles to native code.
Google has released a Go SDK for App Engine, but you can't yet deploy Go apps on the service. This will "soon" be an option for a limited number of beta testers.
The Go runtime arrives with the new 1.5.0 version of App Engine. This also marks the debut of Backends, instances that have no size limits or request deadlines. They're designed for applications that require long-running and high-memory processes, using between 128MB and 1GB of memory and a "proportional" amount of CPU power.
Magnusson calls Backends a "potential game changer" for App Engine. "Previously, instances had limited resources at runtime. They were very good for running scalable applications. But they didn't provide long-running scalable back ends that were good for compute intensive or persistent state applications," he said.
"Whenever you need long-running code or computational intensity or persistent state and it doesn't match directly to a combination of data store or memcache or even HTTP requests, then it becomes very cumbersome to express it. With Backends, you can very easily – in fact, delightfully easily – code that up."
The new version also improves on App Engines "Task Queues" by introducing "Pull Queues", which let you pull tasks from a queue as applications are ready for them rather than waiting for a push. But the real news is the arrival of Go. Reporters may be perplexed, but the move only stands to reason. App Engine is a means of building and running applications on Google's back-end infrastructure. And Go is specifically designed for that very back end. Google is already using Go for "several" systems internally, though it won't specify which. ®
Sponsored: Network DDoS protection