Why Python and I click

Oorspronkelijk geschreven op 23/12/2010 - 17:16

...it can't be just Monty, can it?

I've often thought back about why of all the modern languages I chose Python to be my favourite.

When I worked at a kind of general IT support department at my company, I encountered Python when we had decided to inform each other about common terminology we didn't know much about. The company at that time was largely COBOL based and was slowly moving a bit in the Java direction.

So, not knowing about this stuff other than that it was about languages, I chose to enlighten my colleagues about "Perl, Python and Ruby", all of which turned out to be used in server-side web scripting. I looked a bit at Perl, which looked a lot like the KornShell gibberish my girlfriend had to put up with at her work (she didn't write the stuff, just had to use it sometimes), so I didn't look at it too much. I looked a bit at Python, which appealed to me for the lightheartedness and humour with which the stuff I read was written and the fact that you didn't need to declare your variables or end-delimit your constructs. And I looked a bit at Ruby, which after Python was a bit of a letdown: as far as readability was concerned it fell somewhere between the other two and at the surface it just didn't seem that interesting.

The other languages I knew about  at that time were Pascal (from a television course I sporadically followed), BASIC (from the subsequent Commodore 64 and 128 and Amiga we owned), C (from an introductory course and compiler on the Amiga), Java (from an introductory course I followed a few years before) and of course COBOL.

COBOL was about the first computer language I learned apart from some assembler basics that were part of a course I took to have some more professional skills - before that I was in diploma terms just another high school graduate. COBOL was also part of that course but I didn't really grasp it until I got a programmer job and had to follow another course that made me actually use it.

Java I mostly understood from a theoretical level - OO theory and the way it was implemented in the language. The course was mainly a promotional tool for a "visual designer environment" and what code I saw was almost hidden by the include statements at the beginning. The main thing I remember from it was the technique to TRY something and then handle the exception if it went wrong, a technique I'm told Java Programmmers are now taught to avoid.

Pascal was something I never saw much of anymore after the television stuff, but what struck me was the nice buildup of enclosed structures: START something and END something. What I remember most of it is an exercise in recursion - which hadn't so much to do with the language, apart from the possibility to define a function.

This used to be a blog post on a different site, to be continued with some ramblings about what I did with C, Basic and Javascript, perhaps even Euphoria, but I seem to have lost my point with that... oh I realize now, it's because it doesn't have so much to do with Python. Maybe I wanted to tell why other languages didn't click that much.

C for instance, appeared to have very little syntax - just some control structures and for the rest lots of functions defined in lots of libraries of which I thought that I could get to learn them once I started writing programs. Only I never really started because I couldn't think of anything nice to write - Python made that easier by not having to first define all kind of low-level stuff.

Back to Python, then.

I already mentioned the relief I felt at not having to include variable declarations and end scope delimiters. Another nice feature is the absence of clutter like private , static , 'const`,  final and so on. These things are inferred from the way stuff is used, and if you want to use it differently then you just can. This is the dynamism of Python and for me it lifts the burden of having to think about these things instead of thinking about the actual problem I'm solving.

Readablity is another thing. COBOL is also very readable, but with pretty low level operations so you end up with a lot of code. Python knows nifty ways of constructing these into short blocks of code that can still be easily understood.

Trefwoorden: programmeren, Python