Thursday, August 4, 2011

Simplicity And Longevity

Nothing lasts forever — but simple things generally last a long time.  Why?  Because the more moving parts a thing has, the more subject it is to breakage and eventual death.  Even some smaller, simpler things don't last too long. But these can be enjoyed again and again because they're simple — easy to reproduce.  Travelling into outer space, walking on the moon, surviving re-entry — this an incredibly complex trip, disaster-prone and unlikely to happen to the same person twice in a lifetime.

Classic cars — the vettes, the chargers, the 57 chevs.  They're beautiful machines by any measure.  They're also simple by today's automobile standards.  Could it be that simplicity alone has driven these classic cars into the future?  Could this concept have any bearing on the longevity of software?

Maybe going back several decades — to the early days of Bell Laboratories — might help shed some light on simple software.  This was during the development of both Unix and the C programming language — two systems that are still hugely relevant today.

The C programming language, designed by Dennis Ritchie has a long and interesting development history.  What I find particularly intesting about the C programming language is that it still beats newer languages in popularity, and in overall usage.  Why?  It's not as though C has some superset of features, derived from an earlier variation on the language.  I think it's for this exact reason — the lack of features — that C has been so successful, so widespread, and so relied upon for almost any software system.

Portability wasn't a concern to Ritchie during the early days of C.  However, portability came almost naturally to the language as a result of the minute number of pieces, the underlying mechanisms unique to each hardware architecture.  Again, few moving parts means that simplicity alone made this possible.

I think the real measure of C's simplicity is outlined by the mere fact that nothing like it has been invented in all these decades — nothing came along and simplified C.  And through these times, amongst all the fabulous software, there were, and are today, dozens of brilliant computer scientists just like Ritchie — none of whom took C and made a simpler version of it.  To me, that says a simpler version of the language doesn't exist.  For that power it brought, it was as simple as it gets.

The art of longevity by means of simplicity doesn't end with C.  Python is another example of this phenomenon.  Also with a long history, the Python programming languages takes simplicity to another level.  Just as C simplified logic (relative to it's B predecessor), by introducing types, Python simplified it's programs by making types dynamic.

Python isn't a better simplification of C — the two languages solve different problems.  They are related though — Python is written in C.  This is exactly the type of task C excels at — implementing other programming languages.  The lower-level, system-based things where performance is important.  At least much more so than in domains where interpreted languages prevail.

Python is has quickly transformed itself into a language for the web because it has strong network library support and because the syntax is easy to learn.  I think the greatest insight Guido van Rossum had with Python was that code should better resemble English.  That is, you should have a general understanding of what the code is doing at a glance.

This is a drastic shift from what C is all about — performance.  A lot of the performance gained by C applications is due to the direct sacrifice of readability.  Rather than telling the computer what to do, with C, you also had to tell it how to do so efficiently.  This level of control is an absolute must for programmers developing system software.  But is it a requirement for all applications?

Python sacrifices performance for readability.  The fact that we're able to write software so fast with a language such as Python means we're able to invest more time in other activities — like testing it.  Maybe this had something to do with Python becomming one of the dominate forces of the web.  It's there, it's got the libraries, all you need to do is write some code.

Even with cool languages like Python, one can't help but notice there are certain domains — like stuff on the web — where patterns are repeated, again and again.  Even if we're able to cheaply crank out Python code because it is so simple, it's still monotonous and labour intensive.  It'd be nice to use a framework that takes care of at least some of these common tasks.

And this is arguably a problem with Python — it's such a good web language that there's an overpopulation of Python web frameworks.  It's good in a variety sense, but bad for standardization.  What is the default framework for the programming language of the web?

Django wins for simplicity — probably longevity too.  Django aims to simply only the common stuff that no web developer wants to take care of.  Things like database connections, template rendering and loading, URL-view mapping.  I'm obviously over-simplifying everything that Django does.  But a key Django hallmark — one I find other developers sometimes miss is that it gets out of the way.  I think this is an important trait for web frameworks.  With such a rapidly evolving medium, we do not have room for giant tools that try to espouse the whole development process.  Think small, think standard.  This is what Django does, and it does it well.  I think it'll be the default Python web framework for some time to come.

These are just three software systems that come to mind when I think about simplicity and longevity.  There are probably hundreds of things exhibiting this phenomenon — both in the software world and in day-to-day life.  If something is going to last a long time, that is, be of practical value to a large group of people, then it should be simple.  Engineer your software to be "as simple as possible, but no simpler" as I'm sure Einsten would have done.