Categories
Uncategorized

The Humble Programmer

In 1972, Edsger W. Dijkstra published a paper titled The Humble Programmer. Dijkstra was trained in math and physics and was a university professor for much of his life. This paper is an interesting reflection on the history of computers and contains thoughts for the future. A few quotes are included below:

Categories
Uncategorized

Why are Go applications so reliable?

Go does a lot of things well (good performance, easy to learn, very productive, extensive stdlib, excellent tooling, etc), but after programming with Go for three years (both embedded Linux and cloud applications), stability is the characteristic that really stands out.

Categories
Uncategorized

Using Go in place of a Spreadsheet

Recently I needed to calculate NAND partition tables for a project where we will be supporting a number of different flash parts from 500MB to 2GB.  I first tried this in a spreadsheet, but found it difficult to work easily with hex numbers and do the calculations I needed.  I then looked into options for formatting text in columns from a program and found the nice text/tabwriter Go library.  With a few lines of code, I was then able to get the below output, which is quite easy to read.  The only tricky part was figuring out that for right justified data, you need to:

  1. not use tabs for the padding character
  2. add a trailing \t in the input data
Categories
Uncategorized

Setting up a Go development environment

Go has a pretty neat development environment, and its helpful to set up a standard GOPATH on your workstation up front.  This is what I do:

  • mkdir ~/go
  • add the following to .bashrc (or some file that configures your env on login)
    • export GOPATH=~/go
    • export PATH=$GOPATH/bin:$PATH

Now, after you log in, you can do things like:

Categories
Uncategorized

Go Language for Embedded ARM Linux Systems

In the quest for technologies that work well for embedded Linux systems, I recently gave Go another try.  The last time I tried this was very early on and there were some floating point issues on ARM that appear to be fixed now.  Having spent a few days porting an existing application to Go, there is a lot to like about Go.

Categories
Uncategorized

The Go language for embedded systems

As one of the things I do is evaluate new technologies for embedded systems, the Go language from Google is an interesting development.  I have been looking for a better “system” language for some time.  What I mean by a better system language is one that is nearly as efficient as C, does not require a large runtime, has a fast start-up time, and yet supports modern language features.  It is interesting that the constraints for very high performance server applications are often similar to those found in embedded systems in that applications must make very efficient use of memory and CPU cycles.  This is why C++ is still used a lot by Google and is also popular in embedded systems, but is not as common in applications where CPU power is plentiful compared to the resources to implement the application such as business applications.  One area of divergence is the focus on multi-core for high end server applications, but in the next few years, multi-core CPU’s such as the Atom and ARM Cortex-A9 will likely be common in low power embedded systems.

There are other options.  Vala is very nice to use, is efficient, offers advanced language features, and extensive language bindings.  Vala is being used to implement some of the http://freesmartphone.org software stack.  C/C++ are the old standby languages, but are rather tedious to program in compared to some of the newer languages in that source and header files are separate, and memory management is manual.

My interest in Go at this time is for ARM systems, so I ran a few experiments.  From what I can tell, there does exist an ARM Go compiler that is able to produce ARM code, but it currently lacks support for EABI soft floating point.  The lack of floating point support is pretty much a show stopper for now, but it is at least a start.  The following is an example:

export GOARCH=arm
cd $GOROOT/src/
./make-arm.bash

cd
(create the following source file: hello.go)

==================
package main
import "fmt"

func main() {
        fmt.Printf("Hello, world\n");
}
=================

5g hello.go   (5g is the ARM compiler)
5l hello.5
scp 5.out root@n900:  (copy to ARM system)
ssh root@n900
?:~# ./5.out
Hello, world

(modify with floating point code)

==================
package main
import "fmt"

func main() {
        var f = 1.5;
        fmt.Printf("Hello, world\n");
        fmt.Printf("float f = %f\n", f);
}

=================

(now run on ARM system)
?:~# ./5.out
Segmentation fault

As, you can see, floating point does not work as expected.  I’m not sure yet if gogcc can be configured to compile ARM binaries.  The other area where Go appears to need a lot of work is bindings to various libraries.  Though it does not appear to be ready for embedded ARM systems at this time, Go will be an interesting language to watch over the next few years.