Sunday 10 June 2012

Like Python, like Go

Long ago I vowed I would learn Python. Yet, despite a little dabbling in the past I've never actually dove right into it. Well, now I have and I must say I love it. You might think that I'll be talking about specific features and compare them both but I'm not going to. There's enough of that sort of thing already. Instead, this probably will read like a love letter.

Python's similarity to Go borders on the uncanny. I consider it flattering to Python that that this is the case. Both are fantastic to work with. Slices, great built-in abstract data types, well documented standard libraries and a forced coding style are all reasons I like these two languages. They are so similar that I've even forgotten which language I've been programming in and start using braces in Python and colons in control structures in Go. Thankfully, I don't have to choose between the two languages because I don't think I could. Go is best suited to server programs and system daemons. Python is fantastic for user level applications. Of course, there is a great deal of overlap and cross pollination between the two but that's how I define it.

If you are new to programming I would happily recommend learning either language but, due to the youth of Go, I would probably give the nudge to Python. There is a tremendous amount of introductory material, a plethora of third-party libraries, and a ridiculous amount of other online resources for Python. These will likely come with time for Go, and they are, but its far too young to have the support you would get with Python. After learning Python, however, transitioning to Go will be a breeze. Like Python, it is a terse, well formatted, and powerful language.

Outside of each of their respective third-party libraries, Python is almost a write once, run anywhere language just as Go is almost a write once, compile anywhere language. That is one thing about C that drives me crazy. I hate always having to use tons of boiler plate to conditionally do things depending on the operating system or compiler I'm using to build my application. Its wonderful to know that something I commit to one of my projects will work without modification on any architecture and operating system supported by the language.

That's not to say these languages are perfect. There are things I don't like about both. I prefer the static typing of Go. I prefer how I can run Python scripts directly from the shell without needing to install a third party utility. I prefer compile time error checking in Go. I prefer how I can use the Python shell to interactively run programs and use the interpreter as a calculator. I prefer Go's get program for installing libraries from source. I like how minor changes to the source code, simple things like changes in the doc strings, don't require having to be recompile the work to take advantage of them (via godoc).

Anyway, this is a long winded way of saying that I really like Python and I am glad I've added it to my tool-kit as I intend to continue using it for a long time to come! Hopefully, it won't be so long between posts again. I am going to be learning Scheme and following the SICP soon. I am very happy to see the 1980's lectures up on MIT's OCW site and look forward to watching them!