why i use the go programming language

June 10, 2018

There are a lot of interesting and powerful programming languages to choose from within Raspbian and Arch Linux ARM on the Raspberry Pi. Python immediately comes up for consideration in no small part because it’s one of the first languages you can work with when you install either OS and log into it for the very first time. It’s immediately available from the command line as a REPL, in the menus under Programming (Python 2 (Idle) and Python 3 (Idle)), and as Python Games under Games.

Python is both approachable and powerful. You have a number of ways to enter Python code and get it to “do something.” The REPL interface is the closest you can get to the old built-in BASIC of the Apple // and the Commodore 64. As you grow in knowledge of Python, there is a breadth and depth of Python libraries to accomplish anything, from networking and Web frameworks to AI development and machine vision. When you buy external hardware for the Pi, the reference software that shows how to access the hardware is written in Python. For all these reasons Python is a great way to start, and a language worth staying with.

But it’s not for every “use case” as they say in software engineering. You have to make sure that the Python interpreter is installed where-ever you wish to run your developed code. If you develop an application that imports any libraries, you always have to make sure that the libraries you depend upon are installed on the systems you intend to run on, and at a minimum version that will support what you’re attempting to perform.

That’s one big reason I like Go. Go compiles to an executable like C++. Unlike C++, it compiles to a single executable with all it’s libraries and frameworks baked into the executable. The only location I need to have my external libraries and frameworks installed on is the system I develop on. I don’t have to install a Go runtime on a target machine. Everything I want to include is included at compile time, and ready to run. I’ve written a fair number of applications on one Raspberry Pi, compiled it (go build) and then copied the resultant executable to another target machine where I started it up and it Just Ran. Even when writing applications that work with attached hardware on the GPIO pins and I2C, I can move the executable around and not have any issues as long as the external hardware is the same (and why wouldn’t it be?).

I like Go’s relaxed syntax minimalism. I’ve come to appreciate Go’s implementation of concurrency and channels. There’s a lot the language doesn’t have, and a lot it won’t do according to other authorities, and I’m OK with that. It’s great for what I want and need it for. I even like the Go tool chain. In short, I’m an unapologetic Go convert, and that surprises me a bit. After all these decades of software development, I never thought I’d move away from the Holy Trinity of C++, Java, and Python. But I have, and I believe I’m better for it.