Skip to content.

plope

Personal tools
You are here: Home » Members » chrism's Home » What's Great About Python
 
 

What's Great About Python

Lately, I've been doing some C and Scheme programming. Don't ask. Using these languages reminds me of what's great about Python.
  1. No inconvenient simplifying assumptions. In Lisp/Scheme, it's considered of utmost importance that the code itself is represented in the same syntax as its data structures. This is convenient for interpreter and compiler-writers, but it certainly makes for some pretty ugly-looking application code. In C, you are required to think of all of your data in terms of the storage it occupies. This is also convienent for compiler writers, but it's a harsh demand on application programmers. I like to think of Python as a "no-excuses" kind of language. It doesn't make as many simplifying assumptions on behalf of its implementors, but makes lots of them on behalf of its users.
  2. No static type checking. I think Paul Graham said it best with we need a language that lets us scribble and smudge and smear, not a language where you have to sit with a teacup of types balanced on your knee and make polite conversation with a strict old aunt of a compiler. Static type checking fans: get over yourselves. It's not helping you.
  3. Almost everything is a first-class object. Need to pass a function around? Go ahead. A method? No problem. A class? That's fine. A module? Whatever. Python doesn't care. Elaborate pointer manipulation can get you a lot of this in C, but it's pretty painful.
  4. Scaling. Python allows you to start out writing simple code to do simple things, ala "print 'hello'", which makes it great for "scripting". But it is consistent enough to allow you to carry all of the knowledge you gain this way into larger more complicated tasks, such as creating and using classes and other more OOish things. Lisp makes you learn about cars and cdr and conses right away; you can't walk too far in C without bumping into a pointer. Java makes you treat everything as a class. Yikes. All I wanted to do was print hello. That said, when I do want to define a hello class, Python will let me do it gracefully and in a way that's not very unsimilar to the procedural scripting way. I can reuse my knowledge of the language as I take it further.
  5. Built-in data structures. Who really doesn't need an associative array type builtin? A dynamically-sized mixed-member vector?
  6. Interactivity. Wow, is it nice to be able to enter in an expression or even a short program into the Python command-line prompt and see output right away without needing to compile. Of course I like this about Lisp/Scheme too.
Created by chrism
Last modified 2004-01-17 02:15 PM

Scheming away

I've done a bit of Scheme (MIT Scheme and PLT Scheme). In fact I've done more Scheme than Python, but I'll change that this year. In my view, the key thing that Scheme has over Python is the availability of compilers. Hardcore Scheme advocates would probably also mention things like full tail recursion and first-class continuations, but those things are meaningless to most programmers.

I'm curious, which Scheme implementation(s) was you using?

scheme..

I am using guile to play around with Scheme. All I'm really doing is messing with GNUCash (which is written mainly in Scheme, AFAICT) in order to be able to define a new kind of invoice type.

FWIW, I still don't understand tail recursion, after having it explained to me by several people. I understand continuations better now, but still don't understand the distinction between "first class" continuations (as you say exist in Scheme) and the continuations that exist in Python. Could you shed a bit of light on that, just for my edification?