in reply to how do you express coding-pleasure?

Solving bugs is nice, but for me, the greatest pleasure in coding is reserved for those occasions when you suddenly see a way to simplify a piece of existing, working code.

I was recently working on a piece of code that operated on overlapping substrings of a string, involving two nested for loops and 3 position counters. Getting it to work right took an inordinate amount of time trying to cater for all the overlaps and edge cases.

Then the realisation dawned that Perl's habit of padding shorter arguments to match the longer ones in many of it built in routines and operators meant that all my carefully crafted edge detection and correction was unnecessary. I removed it and everything still worked. That was a distinct pleasure.

Somemonk, I forget who, has or had a sig. that said something about knowing that you were moving in the right direction when you were throwing stuff away. That was the case here. Perl's default behaviour meant that a bunch of complicated tests and corrections could be eliminated.

I like that. And it happens much more in Perl than any other langauge I've ever used. (With the possible exception of PL/1 (actually PLS-86) which had more options to every library call than any other I ever used, and most of them had defaults that usually meant you could skip them. The only trouble was trying to remember which optional arguments had which defaults)


Examine what is said, not who speaks.
"But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
"Think for yourself!" - Abigail        "Time is a poor substitute for thought"--theorbtwo         "Efficiency is intelligent laziness." -David Dunham
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
  • Comment on Re: how do you express coding-pleasure?

Replies are listed 'Best First'.
Re^2: how do you express coding-pleasure? (notable quotes)
by grinder (Bishop) on Nov 28, 2004 at 17:55 UTC
    moving in the right direction when you were throwing stuff away

    That would be princepawn/metaperl, whose sig says "Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality".

    I think this is a basic tenet that comes up time and again in human endeavour. Antoine de Saint-Exupéry said "You know you have achieved perfection in design, not when you have nothing more to add, but when you have nothing more to take away."

    Going back earlier in time, Blaise Pascal said, of a letter he had written, "I have made this longer than usual, only because I have not had time to make it shorter."

    - another intruder with the mooring of the heart of the Perl

      Indeed, and thanks for doing the legwork. I especially like the last(first) version.

      I have made this longer than usual, only because I have not had time to make it shorter."

      For me, that kinda sums up one of the best things about coding for oneself, instead of a client or company. One has the time to make things shorter.

      There are other pleasures (as well of plenty of downsides--mostly financial :() derivable from programming for the sake of it. Others include:

      1. No deadlines.
      2. No contradictions (barring Me and Myself arguing with I:).
      3. No onus to complete.
      4. The joy of be able to pursue interesting side issues. Even if they are ultimately dead-ends.
      5. Answering all those "what-ifs" that crossed your mind during interminable meetings (with clients or bosses), but went unanswered for fear of embarassment.
      6. The ultimate joy, is that of knowing you are wasting nobody's time, but your own.

      Examine what is said, not who speaks.
      "But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
      "Think for yourself!" - Abigail        "Time is a poor substitute for thought"--theorbtwo         "Efficiency is intelligent laziness." -David Dunham
      "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
Re^2: how do you express coding-pleasure?
by jplindstrom (Monsignor) on Nov 28, 2004 at 17:40 UTC
    Along those lines, I find it nice to have such well-factored code that adding a new feature involves a tiny code change, like it was just waiting to get expressed.

    /J