31 December 2005

Have you done your code kata today?

Scheme, ADA, Prolog,...

As I was reading Joel Spolsky's last post and the following discussion, I was reminded of my own education where I had to learn Scheme. So many parenthesis,...

I had a go at the test sample that Joel was referring to. It wasn't hard at all. But I realized why. At school, we were given so many exercises of money change management that anything like the sum of squares is a breeze:
  • can you write in Scheme an algorithm that gives the change for a given amount of money having w 1 cent coins, x 2 cents coins, y 5 cents coins, z 10 cents coins?
Yes, I remember blowing one or 2 neurons off!

What's left from that? Frankly, I don't know. I certainly don't exercize this kind of ability each day. However I think it gives me a kind of mental agility that's fine to use when needed.

The other languages we were taught were SQL, Prolog and ADA. ADA mostly. With ADA, the emphasis was on implementation hiding, abstraction, data types. Basically the survival kit for doing some kind of design.

Give me OO, but keep me down on earth!

The other language that we should have learned was Smalltalk. No object-orientation in 1992?! Luckily, I had to cope with an object library for geometry in C++ as my first internship.

My first big project was also in C++, then I jumped on the Java bandwagon. What a relief, no more pointers/memory management! I could at last focus on object analysis, design patterns and so forth. Too easy my friend,...

The law of leaky abstractions strikes again. As an object zealot, I like to live in a world where everything is an object. Yet this is not the real world! I also live in a world where I have to manage memory for any non-trivial system.

I learned it the hard way,... My first financial system was full of small objects representing financial parameters. The server RAM was full of them too! Here come lazy loading strategies, careful collections selection and garbage collecting. Why wasn't I taught all these? Superficial teaching? Maybe the reason is that teachers don't have to learn it the hard way,...

The bottom line is that learning Java in CS courses is certainly ok, even if it presents a limited approach to programming. It is ok if you also learn the subtleties of java, not to be an expert, but at least not to fool yourself.

Learning Ruby

I specially liked Joel's post since I started learning Ruby this month. First of all the syntax, then the API (no more code completion!), then what?

I remembered an idea from the pragmatic programmer's book (I think): code katas.

Code katas are small programming/designing exercises. Each of them aims at developping a specific ability that useful in programming:
  • Business analysis
  • Data munging
  • Data sorting
  • Estimating size or speed
  • ...
I would certainly add other katas to Dave's list:
  • Threads management
  • GUI building
  • Memory management
  • Network communication
  • ...
The nice thing about katas is that they are written in a way that you have to think about how you solved the kata and what did you learned from that. High education is not the end of it at all. We have to much to learn to grasp software, from technique to business. And we have so much to learn about how we learn (take a look at the Dreyfus model for instance)!

Again, martial arts as a metaphor for programming is pretty interesting:

-Sensei, I practised my code katas today
-Well, well, Eric-san, the spirit of software will flow through you. Now, wax-in, wax-out!