Sunday, July 07, 2013

programming outside my comfort zone

Sample Go language inside Notepad++ editor, using Java syntax highlighting
My experience with computer languages extends all the way back to APL (A Programming Language). I was exposed to it at the Fernbank Science Center in Atlanta in 1971. I got into APL for two reasons; the cool symbols across the top of the keyboard (a mechanical teletype) and the fact that I could play moon lander, one of the computer games written in APL that I later started to hack.

For a high school junior who was growing up through Star Trek, 2001, and the Apollo program, learning APL on an IBM 360 mainframe was a dream come true. Since then I have continuously been programming in some language, from assembly on up, on some platform, from microprocessors on up, until today, and I don't see myself changing until I can no longer see a monitor, sometime in the unknowable future.

For someone with such a very long period of software engineering in their lives, staying with any language or even a group of languages can result in creative stagnation. I have been programming in C since 1982 when it was Lifeboat C on an IBM PC XT under PC-DOS, C++ since 1986 when it was C with Classes under VAX VMS, and Java since 1995 when I downloaded it from Sun as a beta under Windows. I have certainly worked with other languages over the decades such as Ada, PL/I, Perl, Python, etc, but the stalwarts I always fall back to are the C trinity.

If you've not heard of Google's Go before now then you probably need to mosey on over and check out what Google has wrought. According to its Wikipedia entry, Go, or golang, is "an open source, compiled, garbage-collected, concurrent system programming language." It's important to realize that concurrency is not the same as parallelism. It's better. And that's why I'm very interested in this language. That, and the fact that two of Go's creators are Rob Pike and Ken Thompson, a pair of living computing legends. Or a pair of old dudes like me (except I didn't do anything nearly as useful as invent Unix, Plan 9, or the C programming language).

While I've yet to write anything substantial in Go (except to follow a number of tutorials), the impression I get of Go is a language that you would write if, after having put a few languages under your belt such as C, you could then go back and "do it better" after watching decades of adoption and use. An example of a "fix"? The language doesn't use an unadorned equals sign for assignment, but more like what Pascal and Niklaus Wirth find proper, the character sequence ':='. Niklaus Wirth was right to call the use of a bare equal sign for an assignment operator a "notorious example for a bad idea."

Another interesting feature is the elimination of elaborate class nomenclature. C++ and Java et. el.  has all sorts of coding rules for writing classes as well as how to then use them. Depending on the problem, these classes can become overly complex and unruly, especially in novice hands. In the Go example above you define a data structure which also serves as a class (you can do the same in C++, but not as cleanly), then define the method save() for this class that appears paradoxically outside the scope of structure for which it was written. The only indicator save() is a method of Page is its "receiver *p, a pointer to Page." This is something of a surprise to an old dog like me, but I think I will get used to it. I'll need to do a bit more class creation before I fully understand it, but it's not outrageous, especially if the rules for writing are simple and consistent.

The feeling I get using Go is of a stripped down no-nonsense kind of language trying to incorporate best practices as well as fix a few language mistakes (assignment notation is but one). It is fun, and it seems to have a reasonably low bar to understanding how it works and getting non-trivial work done. Whether it allows for "simple" programming remains to be seen. Code is by necessity at times complex and hard because the problems you are trying to solve are complex and hard.

Update

Just finished a basic wiki server tutorial (the wiki is basic, not the tutorial), complete with interesting error handling, regular expression based validation, function literals and Go's version of closures. Not bad for a "new" (since 2007, or six years) language. It might not be a production wiki, but I do like the way key concepts were presented, such as error handling, validation, and patterns for code reuse.

I'd much rather build my mind doing something like this than wasting it along with money at some local Orlando tourist trap.