Language archeology (europython keynote, Bruce Eckel)

Tags: europython2009, europython

Bruce Eckel has always tried to figure out programming languages: why they do things, why they don’t do other things. He’s best known for thinking in c++ and thinking in java. At the time those languages helped productivity, but now they’re holding programmers back. So he’s frustrated with those books now. A GUI he advises after looking at a large number of them: Adobe’s Flex. He’s also written a book on it.

Bruce created the PyCon conference’s tshirt: “elegance begets simplicity”. A previous shirt “life is better without braces” was based on a comment by him to Guido.

C was invented to make software portable: get rid of programming in assembly language. Goal: away from the machine, but not too far away as you need to stay close to the machine for speed reasons. ANSI C added static typechecking to pre-ansi C which prevented a lot of common low-level bugs. This improvement made static typechecking look more like the solution to all ills than it warranted.

C++ was community designed. Well-designed, but hampered by the design restriction to keep backward compatibility with plain C. It is a big language and when he re-reads old C++ examples he wrote for his books, he notices that he even forgot parts of the core language. The language itself is SO big.

Java’s goal was to improve C++. So it looked a bit like C++. It popularized garbage collection, virtual machines (bytecode) and standardised error handling. Java’s problem is the backward compatibility with all the old java versions: new features that are added are often crippled. This has bogged down the language. One reason is the death-grip that Sun has/had on the language.

Ruby. His original reaction when he first looked at it was “bad rip-off of python”. Probably findable in an old blog entry. He says he was wrong. And Ruby on Rails was positively great for everyone. It showed everyone what you can do with a dynamic language. Bruce: Ruby is a smalltalk that is as practical as perl. Great quote. Ruby took all smalltalk’s object oriented purity and made it practical.

Python. Bruce loves python. Python looks at features in isolation. Does this particular feature make sense? It is handy? What is the best way to do this feature? So with every feature you can be sure that it is useful and working pretty well. And python is one of the few languages that dare to correct mistakes. When something doesn’t work well, it gets fixed. Sometimes a standard library component gets replaced. That results in minor incompatibilities, but it is handled just fine by python’s users. It makes the language great. Compare it with java’s unattractiveness in this regard.

Python is clean and minimal: almost no unnecessary syntax. It acknowledges the limitations of programmer brains. Those brains are smaller than we think. In C++ you can do c = Cat("mittens") to create a new object on the stack. On the heap, you need an extra new keyword. Python always allocates on the heap, so you don’t need the distinction. So python left out the new keyword and frees up more room in your brain for other things. Ruby still has the new keyword as they mimic smalltalk in that regard. Java has the new keyword as it has primitives that are stack-allocated for efficiency’s sake. That was a mistake. They did it for performance reasons and crippled the language for it. In python, the language is always elegant. If in some spot you could need something more efficient, there are ways (slightly less elegant) to do it the efficient way via a back door.

Garbage collection and destructors. c++ had a problem with stack and heap objects again. The stack cleans up automatically, but you must remember to call delete on heap objects. All of them. You’ll lose control somewhere. Garbage collection makes memory leaks a non-issue. Java popularized this. There are different ways to handle garbage collection. Java and ruby use a non-deterministic one that doesn’t catch everything. Python’s reference counter garbage collector works better. One change in recent versions (the with clause) is to split memory management and resource management. Resource management means for instance automatically closing files once their class is garbage collected. This is an improvement.

Common error reporting: exceptions. C++ introduced it, but also supported all C error reporting mechanisms, which made it less useful. Java, ruby, python, c# and so on all use exceptions exclusively.

C++ had templates. Well-designed, but the first implementations were bad. Java generics are far less powerful than the C++ templates. Basically java got it wrong for backward compatibility reasons. In dynamic languages, generic/templates aren’t a real problem. Duck typing. You write your code generically and just raise an exception at runtime if you did something wrong. Static type checking cannot every catch every error anyway.

tshirt text logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):