Archive

Archive for December, 2010

Say Something Nice About Every Language You’ve Used

December 8th, 2010 50 comments

In Michael Easter’s recent post, I was struck by his comment that Guy Steele like all languages. Seems like a pretty chill way to live a programming career. So I wondered, do I like all languages? Can I say something nice about every language I’ve used? As the saying goes, “If you can’t say something nice, don’t say nothin’ at all.”

Let me give it a try in rough chronological order of the first time I used each language in anger:

  • Pascal – Ouch. My memory is so fuzzy I can’t even think of something bad to say about it. So we’ll count “no comment” as nice and move along …
  • C++ – Another toughy, but this time because my memory is so sharp. Hmmm. Uh. C++ has a really nice personality. Next.
  • Matlab – Pretty cool array slicing notation. I don’t know if Python stole this from Matlab, but when I first learned Python I was like “Hey, this is Matlab!”
  • Common Lisp – Generic functions and multiple dispatch are cool.
  • Visual Basic 6 – Seemless integration with COM and built-in support for the observer pattern.
  • C – As Linus has pointed out, you need almost no context to understand a random chunk of C code. It is what it is and nothing more.
  • Java – It’s simple enough that really powerful, reliable tools can be built for it. If you change the signature of a method in Eclipse, you can feel confident that it actually worked. (unless you’re doing reflection…)
  • Tcl – The entire language is expressed in 11 simple rules and it’s homoiconic. Once you accept that everything is a string, you’ll enter a zen-like trance and every atom of your being will vibrate in harmony with Tcl’s interpreter. Or something. Finally, whenever you write a quick test script, you get to name it “test.tcl”
  • Python – Python taught me about list comprehensions and bound methods. It’s stupid, but I also always liked that you could multiply a string by a number to repeat it.
  • Soar – Fast, rete-based pattern matching is cool. Everything that’s really easy in a procedural language is hard in Soar, but some things that are hard are easy.
  • JavaScript – Taught me that objects are overrated and started my reptilian, OO brain down a brighter path.
  • Ruby – I think blocks are a neat bit of syntactic sugar. I like that everything, including nil, is an object.
  • Scala – Introduced me to implicit typing and opened my eyes to how much I actually have to type when I’m coding Java.
  • Clojure – It’s fun, has a nice cross-platform VM, persistent data structures, a good concurrency story, and is apparently saving Lisp from itself.

Wow, I feel really great now.

Note that every one of these could have easily be extended with “even though”, “except for when” or “but sometimes”, but I resisted the urge, mostly.

Can you think of something nice to say?

Programming Etudes

December 6th, 2010 3 comments

Can you implement a stack off the top of your head? How about a simple hash table? A recursive descent parser? Can you do it without thinking about it?

These are a few programming “etudes“. Musicians have a tradition of etudes designed to teach fundamental lessons about playing their instrument. They practice them (usually as children) until they can play them perfectly from memory. Just like with the programming examples above, a musician doesn’t play these etudes in “the real world”. They’re technical exercises so that when they get on stage they can make an artistic statement rather than worrying about fingerings.

A pianist practicing an etude may focus on alternate fingerings, dynamics, tempo. What are equivalent variations you could try while doing a matrix multiplication “etude”? Elegance? Performance? Generality? Obfuscation?

Build your own set of programming etudes. Practice them. They’ll make you a better programmer. Now repeat in another language.

Can you minimize key strokes in your editor? Try it in a different editor?

Can you design a series of etudes that build on each other? Maybe it’s like programming a fugue? Linked-lists + a hash function becomes a hash table. What’s next?

Can you think of etudes in your favorite framework? The “fifteen minute blog” is one. See, it doesn’t have to be all about data structures and algorithms and clever interview questions. It’s about getting the tools of your trade under your skin.

What else?

Now go read Dave Thomas’ CodeKata.

Practice, practice, practice!!