Object oriented programming is nice, but it’s not the best thing forever and ever. So why is it so popular? I think it can be ascribed to three reasons – two obvious and one not:

  1. It allows you to use an algorithm generically very easily
  2. It’s often nice to get your data to manipulate itself (those two were the easy ones)
  3. The syntax makes it so that things are done in the order which you read them

Syntax again.

I was looking at some code I had written, and I saw

text = open(REPOSITORY + item).read().strip()

That’s code that does not need to be object oriented. It would be just as easy to write

text = strip(read(open(REPOSITORY + item)))

but to read that code, we have to maintain an internal stack. The way most people read code like that is “Dammit, why didn’t they use a temp…” and then they scan the line of code right and then left. OO syntax with its dot notation allows us to simply read the line of code.

I’ve been mentally playing around with the idea of designing a new programming language. It seems like everyone (meaning me) wishes they had a language that was as powerful as lisp while being just a little more readable. Me, I like the whitespace thing, but it’s not everyone’s cup of tea, particularly it makes generating code and calling “eval” quite involved. But it seems like we could get a really nice and clean language if we made the base item the associative array instead of the list. That way we could still use algol/c++/java/python/ruby-type syntax to be introspective, but access to the parse tree would be much cleaner than for, say, python.

To do this right, I’m going to have to find out what the deficiencies of Lisp are though, so the first step is learning lisp. It doesn’t seem too hard, and is very conceptually clean, but the syntax is a bit odd…