Developers’ Weblog

Sponsored by
HostEurope Logo

Developers’ Weblog

All 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

Go

02.04.2010 by bsiegert@

Today was a fine day, which I spent at the excellent Zoo de Mulhouse. Alas, most of the plants there are still in “winter mode”.

Recently, i mentioned in a thread on reddit that Limbo (under Inferno) is “my favorite obscure programming language”. Someone else replied that “it is now called Go”. This led me to take a look at the Go programming language made by Google. Sure enough, there are big names behind it: Rob Pike and Ken Thompson, of Unix (and Plan9) fame, and also Russ Cox, one of the most prolific Plan 9 fans.

When you compile Go, the first thing that is built is a lib9, which contains Plan 9 code, such as the rune routines for UTF-8. The Go compiler is derived from kencc. For the 386 architecture (the one I tested), you get 8g (Go), 8c (C), 8l (linker) and 8a (assembler). For the record, there is also a Go compiler using gcc, which is able to call C code.

Leaving obvious syntax differences aside, Go indeed resembles Limbo quite closely. There is no first-class list data type however, and there exists a curious difference between arrays and slices. Slices are some sort of pointer to (part of) an array. Arrays are passed by-value to functions while slices are passed by reference, it seems. There is also an associative array type that maps one data type of your choice to another, for example a string to an int. Other Limbo niceties, such as easy string manipulations, are also present.

The first thing I tried was porting a scientific program I had written in Limbo before. The math module looks almost like its counterpart in Inferno but is missing the gemm() function (generic matrix multiplication) from BLAS3. Thus, I ported it from the Inferno sources, where gemm() is written in C. (By the way, that code looks like it has been ported from Fortran 77.) Porting from C just involves removing a few parentheses (in if and for clauses) and semicolons (just about everywhere).

I have not explored it much further yet. But it does look very interesting for system programming and similar things. The only thing missing now is a MirPort ...

MirOS Logo