Why Android should switch to Go

DEPRECATED: This post has been marked as deprecated and may no longer contain industry best-practices.

I'm sure you've heard about the recent situation where Oracle is suing Google for using Java in their Android operating system. Which is pretty ridiculous, since Java's popularity is supposedly due to it being open source. (This isn't the first time Oracle has sued someone, btw).

Why did Google pick Java for Android, anyway? There are plenty of nicer languages out there. Google ultimately picked Java because of its popularity and being a systems programming language, meaning it can do some low-level hardcore stuff (like C), while higher level languages (such as JavaScript) don't have that sort of control (or efficiency). Since Google picked such a popular language, it was easier for new Android developers to write applications.

Android is a very popular mobile platform these days. But, iOS is very close in market share. And you know what language they chose? Objective-C, which is about as proprietary as can be. Nobody uses Objective-C outside of development for Apple products. So, it is reasonably safe to say that Apple chose an unpopular language for its platform; a language controlled and “created” by Apple itself (or, at least NEXTStep, the predecessor of OS X).

Google really needs to pick a different language for Android, a language it will have more control of, a system programming language, where popularity doesn't matter (as proven by Apple iOS). Google should use Go. From golang.org:

Go is an open source project developed by a team at Google and many contributors from the open source community.

Go is distributed under a BSD-style license.

What more can you ask for? Go is new and doesn't have a lot of followers yet, but Objective-C wasn't exactly a favorite among programmers either. Google is the primary developer of Go. Google has control over Go. Go is open source (BSD) and can be used for anything, meaning developers who learn Go can use it wherever they want. Go is a system programming language.

Here's some more information about Go, e.g., why it was created in the first place:

Go was born out of frustration with existing languages and environments for systems programming. Programming had become too difficult and the choice of languages was partly to blame. One had to choose either efficient compilation, efficient execution, or ease of programming; all three were not available in the same mainstream language. Programmers who could were choosing ease over safety and efficiency by moving to dynamically typed languages such as Python and JavaScript rather than C++ or, to a lesser extent, Java.

Go is an attempt to combine the ease of programming of an interpreted, dynamically typed language with the efficiency and safety of a statically typed, compiled language. It also aims to be modern, with support for networked and multicore computing. Finally, it is intended to be fast: it should take at most a few seconds to build a large executable on a single computer. To meet these goals required addressing a number of linguistic issues: an expressive but lightweight type system; concurrency and garbage collection; rigid dependency specification; and so on. These cannot be addressed well by libraries or tools; a new language was called for.

Just for kicks, here are some syntax comparisons between the three languages I've mentioned:

Hello World in Go:

package main
import "fmt"
func main() {
    fmt.Println("Hello, World!")
}

Hello World in Java:

Notice the arbitrary class name, I think the entry point is defined in a manifest file, although I am not sure.

class ArbitraryClassName {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

Hello World in Objective-C:

#import <stdio.h>
int main( int argc, const char *argv[] ) {
    printf("Hello World!");
    return 0;
}
Thomas Hunter II Avatar

Thomas is the author of Advanced Microservices and is a prolific public speaker with a passion for reducing complex problems into simple language and diagrams. His career includes working at Fortune 50's in the Midwest, co-founding a successful startup, and everything in between.