why i use the go programming language

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.

the best general purpose raspberry pi os – raspbian

There is, in my not so humble opinion, a clear winner in Raspberry Pi operating systems, and it is Raspbian Stretch Desktop and Raspbian Stretch Lite. Combining Raspbian Stretch Desktop (which I’ll refer to hereafter as RSD) with the latest Raspberry Pi 3 Model B+, creates a very pleasant programming environment. It won’t run anywhere near as fast as a full-blown notebook or desktop solution with contemporary Intel or AMD x86-64 multi-core processors, but for what it offers, especially for US$35, it’s more than sufficient. And that’s key to this, sufficiency, especially when it comes to developing software. I’m going to continue this post as a series of questions with answers about my experiences with RSD.

I thought you used Arch Linux Arm on your Raspberry Pies

In the beginning I did. My experience with the Raspberry Pi goes back to 2013 and the Raspberry Pi 1 Model B with 512MB of memory. You know the model, the one with just two USB ports, the yellow RCA jack that split the GPIO pins, and only half the GPIO pins soldered on the card. The version that accepted that absolutely huge SDHC sized flash cards. My first post about using Raspbian was January 2014. That version of Raspbian used XFCE as the desktop. At that time I wrote that using Raspbian demanded patience, as it was so slow. I then switched to using Arch Linux Arm (referred to hereafter as ALA), and stayed with it for a very long time. Except…

There were indications of dissatisfaction with ALA. Sometime in 2015 I wrote I’d switched away from ALA and back to Raspbian because when I went to update my ALA installation (pacman -Syu) it would mysteriously fail with package failures all through the file system. ALA itself would boot just fine, but getting it to update on occasion would fail. In the end I’d back up what I thought was important, re-flash the SDHC card with a new ALA image, then reconfigure and move my save files back over. The only thread to all these failures was how long I waited between updates.

ALA is a rolling distribution. That means when you update you are always up-to-date. Great when it works, misery when it doesn’t. And the last time I lost three of my Raspberry Pies in succession to the same update failure, I noticed that my one lone Raspbian system was just fine and updated just fine. That’s when I made the decision to switch completely to Raspbian.

Why did I go with ALA to start with? Performance and the quality of the tools. ALA had up-to-date software tools such as GCC, Python and Python 3, make, git, etc, etc, etc. The older Raspbians, based on older Debian releases, came with much older versions. Python software in particular would sometimes have a hard time running under older Raspbian because current Python features supported on other Linux distributions wouldn’t work on Raspbian out-of-the-box. C++ software developed on current gcc releases supporting the latest C++ standards wouldn’t compile under older Raspbian. But it all worked just fine on ALA. So there was a strong motivation to live with ALA, warts and all. But in the end, Raspbian evolved to a better place, the hardware continued to grow more powerful, so that when ALA had its update issues one more time I could switch over permanently to Raspbian and not look back.

But before I leave this section, let me say how grateful I am to have the opportunity for choice. I’ve tried to create a personal distribution following Linux from Scratch, and I’ve done a fair amount of custom kernel builds, tailoring them for x86-based embedded systems. And if I’ve come to appreciate anything it’s that producing a working distribution involves a tremendous amount of hard work, especially if you’re doing it alone. The community that supports Arch and the Arm variant do a lot of hard work continuously, and provide a vital service with their work in the broader Linux community. If nothing else, ALA has the most up-to-date developer tools of the two distributions, and that’s a critically important feature worth cherishing if you have a need for that. If you’re reading this and you’re curious about Arch Linux for ARM, then by all means give Arch a try on your Raspberry Pi.

How do you have your Raspbian configured?

It’s standard Raspbian, with additional bits. If you’ve got access to a regular computer (Windows, Mac, or even another Linux distribution) then I whole heartedly recommend you use Etcher to flash your image. Etcher is available on all three major platforms and works identically across all three. Flashing an image is as simple as downloading a distribution, plugging in a micro SDXC card into its SDXC adapter, plugging that into the computer that has Etcher and the downloaded image, then starting Etcher and following Etcher’s very simple directions. You don’t even have to untar or unzip the image; Etcher will do that on the fly as ti copies the image to the micro SDXC card. When Etcher is finished plug the micro SDXC card into the Raspberry Pi, connect keyboard and monitor, plug in power, turn it on, and let it boot. Easy peasy.

The tweaks I’ve done to my installation?

  1. On the desktop, set my font to Bold (PibotoLt Bold). This makes the menus and general desktop text easier to read.
  2. Set LXTerminal font to Monospace 12.
  3. Copy hid_apple.conf to /etc/modprobe.d. Inside hid_apple.conf put the single line: ‘options hid_apple fnmode=2’ without the quotes. This enabled the function keys on an aluminum Apple keyboard. That keyboard is recognized by Raspbian during setup.
  4. Finally, to enable virtual logins, edit /etc/systemd/logind.conf and modify the following: ‘NAutoVTs=9’. Make sure to uncomment it if it’s commented. Then reboot the Pi. From that point you can change between virtual logins via Ctrl | Alt | F#, such as CTRL | Alt | F2. If you enable this on the RSD installation, then Ctrl | Alt | F7 will take you back to the graphical desktop. Virtual desktops make a lot more sense on installations that don’t have the desktop.

Other than that it’s bog standard Raspbian.

How is the Raspberry Pi hardware configured?

In order to make the Raspberry Pi feel as fast as possible, I use SanDisk Ultra PLUS 64GB microSDXC UHS-1 cards. The have a video speed class of V10 and an app performance rating of A1. Their claimed read speed is up to 100 MB/s. These were on sale at a local Costco for a time back in early May for US$20 for a two pack, limit 5/customer. I hit my limit. I’ve used other cards from other vendors (Samsung primarily), but these seem to provide the smoothest performance. I had a Samsung 64GB Pro (a picture of which is in an earlier post) and it would cause the 3 Model 3 B+ to freeze for seconds at a time between operations. I thought there was a problem with both of the new Raspberry Pies until I put an older, slower, and smaller version of these cards in both for debugging. Since moving to these SanDisk cards I haven’t had any problems with performance.

I’m also using a 5V 2.5A power supply as recommended. When they say 2.5A, they mean 2.5A.

I’m also using head sinks on the processor on top and the memory on the card’s backside. No special brand, but they are aluminum and gold anodized, which is why this particular Raspberry Pi has the system name ‘goldpi’. The head sinks are recommended, and at the current standard frequency of 1.4 GHz, they run warm to the touch.

What tools do you use?

I use Go version 1.10.3, fromĀ https://golang.org. I use VIM as my editor, configured to use Vundle for Go language plugin syntax highlighting. I will, on occasion, use make and gcc. I use the Gobot framework because I’m currently focused on GPIO and I2C programming with devices.

How do you feel about Raspbian?

I feel it’s probably the best practical operating system you can use on the Raspberry Pi, especially the latest iteration, the Model 3 B+. There may be others that provide some specialized capabilities, and if you need those on the Raspberry Pi, then by all means use that OS. Raspbian and the Raspberry Pi in general have a great, extensive, supportive community. The tooling has matured so that it’s no longer an issue to use it, especially the Raspbian Lite version. It also helps that everything that is released for the Raspberry Pi has supporting software that expects to be used on Raspbian. It took a while for me to figure out, but all the tweaks I did for ALA were already a part of RSD. When I move over and redeployed all my work, I didn’t have to do anything else except install the OS and deploy all my work.

Unless something goes very wrong with Raspbian, Raspbian is where I’ll be.