Ravi Mohan's Blog

Thursday, December 18, 2003

The Thinking Programmer

I was reading Edward de Bono 's Serious Creativity yesterday. The key insight that occured to me is that deBono discusses "thinking tools" which are formal structure one uses for thinking through a problem or focus area.

Later i wrote some code for the Ruby port of HotDraw (implementing double buffering to eliminate the nasty flicker when Figures move on the DrawingView). When iwrote a test and then wrote teh supporting code, it struck me!

Programming is thinking too.

You "think in" a programming paradigm/language combination instead of in a human language but is is still thinking. And every one of deBono's thinking tools should be applicable to programming. .

And when you are programming without needing to think, then you are basically doing "manual labor".

I need to investigate this idea further ...

And today , I am doing some really dumb XML->XSL->PDF transformations,inspecting the finished doc visually to make sure that every dot is where its is supposed to be.Yes i know someone needs to do it but it'snot really very exciting work(to say the least).

Yuck, back to work....

Thursday, December 11, 2003

The Five Levels Of Programming

Just a mental exercise to distinguish multiple "levels" of programmers.

Some of the observations are India and Bangalore specific but the various "types" should beidentifiable everywhere.

Level 1 : the Novice/the Charlatan At the very bottom we have the "great unwashed hordes" - people who studied computer science because "they said that's the best way to get a job" ".The focus for these people are to get into "better " companies (where "better" is defined as "bigger") and move up the career ladder to become a manager as soon as possible.This is the person who seriously believes in iso 9000/cmm level 5 etc as "improving productivity". .On the brighter side this level also include s a lot of people just out of school and who love to program. and are eager to change the world.

Level 2 : the expert This is the guy who knows everything aboout one particular piece of technology . It could be jsp, weblogic,C++ /the PIC microcontroller/whatever. This is the guy who'll tell you what's happening when a particular problem occurs with the technology he is an expert in.("oh just go to a config file foo and change blah to baz" ).Unfortunately in India, even this level of expertise is pretty thin on the ground. Not surprising when you see that most "IT" jobs don't want really intelligent people. (A friend's HR Manager actually asked him to select the "less talented people" when he conducted interviews beacuse the "hacker types won't like our company". Not very surprising when you get a job because you are cheap(er) than because you are good.) The distinguishing characterisitic of the expert is when people in his team /company say " hmm That's a difficult problem let's call in Mr.x "

Level 3 : The Thinker People at this level think about what they are doing and ask a great number of intelligent questions. Most often they use the simple "why" and other "dumb questions" to investigate . This stage is also marked with growing dissatisfaction about the state of the world and a feeling of "I could do better than that " when they see a piece of sub optimal code/design. (This is similair to how a lot of writers start their careers - they read some tripe and say to themselves "this idiot got published? Why I could do better.").In my experience though a lot of otherwise excellent people "freeze" at this stage and never complete the leap across the chasm that separates them from

Level 4:The Hacker This is the person who has gone beyond wishing to actually writing some code , or perhaps writing a book about what he knows.What distinguishes him from a true guru is that his expertise is narrower in scope and he often does not redefine software programming (or a sub area thereof). The charcteristic that distinguishes hime from the "lower" level is that he is well known within his area of expertise. A good example of this type of person are the tech leads of open source projects like Hibernate or the author of a book like "Regular Expressions".These are true "bearers of light".

Level 5:The Guru These are the Martin Fowlers, the Peter Norvigs , the Stallmans and the Torvalds, the von Rossums and the Larry Walls. What they do profoundly changes the world of programming and influences how the rest of the world programs.

'Nuff said

Wednesday, November 19, 2003

What If You Couldn't Program?

I think this is a question every programmer needs to ask himself. Suppose for a moment that you got hit by a cosmic ray that removed the "programmer muscle" from your cerebrum.What would you do ? Let me see... I hate marketing so that takes out a whole slew of professions. Practically anything would require extensive retraining / re certifications.A bit too old too back to school. I got it! I will be a writer! the kind that tells stories... Once upon a time there was a whole country of people who were "hackers" but most of them wanted to move on and become Project Managers .... sounds familiar somehow......

Wednesday, October 29, 2003

A long road

I just did a thought experiment on what one would need to know be a guru in programming and how long it would take.

Of course that raises the question of what it means to say someone is a guru ?

And how does one measure someone's "degree of guruhood" ?

To keep things simple, I chose books as the unit of measurement because it is simpler to measure knowledge that way. If a person has mastered the content of book X, where book X is one of many books a guru has to master (remember books are being used as units of knowledge) then he is that far ahead in being a guru.

Going further I estimated how long it would take Joe Programmer(ok ok , me) to master a book, multiplying the number of chapters in the book with a number of " ideal days " required to finish one chapter.

As my first topic of mastery i selected compilers . I would expect a compiler guru to have mastered the content of (at least)
  1. Programming Language processors in Java (or any other "newbie" book) -- 10 ideal days
  2. Essentials of Programming Languages -- 48 ideal days
  3. Lisp in Small Pieces -- 32 ideal days
  4. A Retargetable C Compiler : Design and Implementation -- 36 ideal days
  5. Advanced Compiler Design and Implementation -- 36 ideal days
giving a total of 162 ideal days .multiplying by a factor of 3 that gives me 162 *3 = 486 real days.

And that is just compilers.

which means it would take Joe Programmer almost one year and 3 months of full time work to become a compiler guru!

No wonder we don't have to many of those around!

Thursday, October 09, 2003

Ruby vs Scheme vs Java ... and the winner is ..

Well the loser is java .

Some context

Martin Fowler was kind enough to send me some ruby code he had written to generate his website. Since I didn't know anything about Ruby, I had to learn it fast in order to understand what the code was doing. I learn best by doing. So the moment I understood a little bit of what he was trying to do , I immediately wrote it out in Scheme, language i did know.Later I tried writing it out in java , just to see how much of a difference there really was in code size.

The java code came to about 300 lines , the ruby code had about 70 lines and the scheme code had around 20.The scheme code "cheats" a bit bacause i used a tree walker macro i have been working on for sometime.Since a macro "expands" at runtime, the scheme code when fully expanded would be about 50 odd lines ...Also I am sure the ruby code could be much shorter but i am a novice @ Ruby Programming ! Eclipse was Java's key advantage, but on a code base this small, an ide is not too important. More than "number of lines" both the scheme and ruby code were very clear and the java code had lots of casts,enumerations, iterators etc. which put a barrier between your mind and the code. I didn't really believe it when Paul Graham said "Succinctness is Power" but I am slowly veering around to this view, even though i still don't think macros are the best ways to provide succinctness .

If Ruby or Scheme or Lisp ever get the kind of awesome refactoring and debugging support Java gets from eclipse,software would be much more fun. That reminds me i need to look into how exactly Eclipse plugins work .....

More importantly, I learnt a number of things from Martin's code.

First, keep it simple.Where i would have used XPATH to navigate an xml tree, Martin used simple recursive tree descent.Lesson learned == Don't use a library just because it's there.

Second, when learning a new language,it is much better to modify/otherwise extend an excellent piece of code rather than start with "Hello World". You get to pick up the idioms (and other "good practices" of the language )faster this way For eg : I extended Martin's code to use a templatefile (a series of template files actualy one for the main site layout and one each for each"document type") ,instead of directly rendering to html, mainly because I can't "think in html" ! Lazy coder that i am got my friend Manoj to whip up a template "look and feel" for me and i just point at the template from my code, and i did this keeping a copy of Andy Hunt's ruby book at my side to clear any ruby road blocks.

Third, read read good code. Programmers, even the good ones don't read as much code as they should.I ,for one, have decided to read at least 10-25 lines of code a day, in addition to writing code daily.

This seems to be one of those blindingly amazing (in retrospect) ideas,that hit you over the head so hard you wonder how you never thought of it. Tomorrow, i'll add an RSS feed to the blog.I need to refactor the code a lot too .