The Best Feature of Go

I’ve been programming since the late 90’s and I’ve done quite a bit of coding in C, C++, a lot of it in PHP and some in Python as well. On the front-end I’ve done some JavaScript and I’ve also had the misfortune of programming in Java 😉

I started programming in Go in 2012 and since then I haven’t wanted to program in any other language. I’ve had a handful of large Go implementations across two companies and by now I have my own short list of favourite features.

One of those features is not mentioned very often but it has changed things significantly for me, and that’s what I’m going to discuss here.

Continue reading “The Best Feature of Go”

Why I Program in Go

Go is a fresh new programming language, that has come out of Google and is primarily targeted towards server development. It is developed by some very accomplished computer scientists, like Ken Thompson and Rob Pike. I recently launched a significant new product built with Go at work, and it has proved itself out very well in terms of developer productivity and performance. So much so that many other teams are also giving it a go (oh, how punny this language’s name is).

Think about it. How often do you come across a programming innovation that improves productivity and computational performance? Continue reading “Why I Program in Go”

MySQLdb Leaks Memory

Whenever people search for a Python library for MySQL, they get directed to MySQL for Python. However, there are some nasties hidden in it. Searching for “mysql python memory leaks” results in a few links which suggest that using Unicode causes memory leaks with the library.

Today, however, I found another cause for MySQLdb memory leaks, while debugging a leaky Python daemon at work — database errors.

Use this script:

import MySQLdb
options =   {
   "user": "user",
   "passwd": "p455",
   "db": "somedb",
   "connect_timeout": 1
}

while True:
    try:
        MySQLdb.connect(**options)
    except MySQLdb.Error:
        pass

Make sure MySQL is up and it’s possible to connect to it without failures using the above credentials. Then run this script and watch its memory usage. It’ll be rock steady for as long as you care to run it.

Now stop mysqld or do anything that would cause errors during connection and rerun the script. Watch it gobble up meg after meg as the errors continue. Any MySQL error, like unreachable server, missing database or tables, malformed query, etc. would trigger the leak.

I need to check if the recently released (13 days ago) MySQLdb 1.2.3 does better in this regard. MySQLdb 1.2.3 does fix the memory leak in this case.