in reply to On elegant coding...
in thread Just thinking ...

The novice hesitates and then cautiously responds...

Many of your thoughts strike chords with my personal development style (paraphrasing):

However, do you not hold a rather unique position in the community? You are held to a higher standard because your code is often seen as a standard to follow. As a leader, a columnist, and a mentor, you are one of the sources for "how it should be done."

Yes, your code should be elegant as time, energy, and editors will allow.

Yes, our code should as elegant as possible. But, does not the ability for elegance come with experience? I don't expect my daughter's watercolors to match the quality or the simplicity of master artists. So, too, the quality of my perl will not match yours for a period of years (if ever).

As possible is the key. As a leader and mentor, please don't forget that some do not yet have skills that match yours. They have the potential, just not the experience.

In the short time I've been slouching about, I've found perlmonks to be a community interested in helping folks improve their knowledge and skills, as opposed to other communities where knowledge and ideas are hoarded for some questionable tactical advantage. I personally appreciate that very much.

I would ask, though, that "elegance" be gently taught. After all, there are many that need to do their work very quickly, without the luxury of extended research, review, or analysis. A regrettable portion of our positions as programmers is that we're given too little time and resources to do our work properly.

This is, as you well know, why there are so many hacks in "finished" software. One quote that comes to mind, though I confess I cannot properly attribute it, is, "Software is never finished; it's just abandoned."

Also, elegance, to some degree is in the eye of the beholder. For example, I recognize that the standard is to use this:

   if (cache_is_good()) {
      show_cache_and_ext("current");
   }

However, you will almost always find my code expresses it as:

   if ( cacheIsGood() ) 
   {
      showCacheAndExit( "current" );
   }

Does that make my code less elegant? To you, perhaps...however, I find it:

That's just my personal preference. It works for me and I do not claim it works for anyone else.

I would hope that in your quest to improve the elegance of our code, you would recognize that and not vote me down because I format my tokens differently that you do.

In my opinion, good programmers continue to look for ways to improve their skills, even though previous efforts cannot (or will not) be revisited. They also recognize that "coding standards" should be guidelines and not straight-jackets. In my opinion, that's where the artistry comes in.

Replies are listed 'Best First'.
RE: RE: On elegant coding...
by PsychoSpunk (Hermit) on Oct 12, 2000 at 23:25 UTC
    Seems to me that you're looking to heavily on the brushstrokes and not enough on the theme when referring to the blocks.

    (Disclaimer: This is not a rant on either footpad or merlyn). What I note from merlyn is that one does not simply reach a point where everything is elegant. This is either comforting or a complete disappointment. I'm not sure which, yet. I appreciate the sentiment; that much is clear.

    footpad, the mistake I notice in your post is that you give a higher credence to merlyn. Possibly more than other monks, but he is, after all, 'just another perl hacker'. I guess what I'm saying is that I agree with the overall concept being discussed here: there is a good quality about treating code as an art. (Here's the potential fire, but I've tried my hardest to put the bucket of water right in front of you) Just because someone is considered a "master" in their field of art does not mean that their work is good. I think merlyn is a good artist, but it is because what he does is important to himself, not that it is important to you.

    I don't have a cool quote from anyone famous, but I'm certain that someone probably said something like this in the past (Probably Howard Roark): You can't create art for anyone but yourself. If it happens that your work reaches others, then they can only take from it what they want to take from it. This will be dependent on their personal path that has led to this moment. It will be theirs only, and even as the artist, you will not have any claim to ownership of that which they get from your work.

    ALL HAIL BRAK!!!

      PsychoSpunk,

      Interesting. I wasn't necessarily speaking completely for myself, but through things I've observed. Merlyn is placed higher than many and for good reason. Also, his RN is extremely recognizable with respect to perl. He's written books; he's a columnist in a few different magazines, and he gives much to to community. How can people not listen when he speaks?

      I wasn't disagreeing with him either. Code should as elegant as possible. It's easier for him (and perhaps even more important) for him to write the best code possible.

      In the other community I'm involved with, I'm very careful to not judge the validity of a poster's question or the elegance of the solution they've reached. As I mentioned in an earlier post, I have found that I learn much from those who have less experience than I do.

      And please don't misunderstand my intention; I appreciate everything he's given to the community and respect and appreciate those contributions highly. And I do pay attention...

      What made me pause was the possibility that some would take his post as suggesting that elegance should be the only consideration for code. (FTR, I honestly don't think that's what he was actually trying to say.) I wanted to highlight the idea for discussion....just in case...

      I hope no one thought I was trying to slam merlyn; I honestly wasn't. I respect him too much to even consider doing so. if that's how that post came across, I apologize.

      -- f
        You'll note that I gave you a ++, since I did find that your post was interesting. My whole point was to make sure that merlyn wasn't being singled out due to his name. I give you the example of the baroque movement as my argument. If you only like baroque because others have said you should like it, then you miss the point. I can say that baroque is crap, but that doesn't diminish its value as an art form.

        I recognized early on in your post that you respected merlyn, but I wanted to actually vilify anyone who would simply respect the name without reason. To the point, merlyn has given the community probably much more than he can ever get back, but given the intro to the Llama, I'd guess that we can never fully get as much from the community as he gets.

        So, while I was sounding harsh, it was more for the onlookers than anyone else I primarily addressed. It's just my style, I guess. I think what made me branch my reply from your post was the comment about block style. It made me feel like you were approaching from a vanity, instead of the message. Note my first paragraph in the initial response. That was actually the only part that I truly wanted to address to you, but I also felt that if I stated it such that I used examples from your statement that could be misconstrued as simple "hero worship", I would effectively make my point.

        After all, we're all just perl hackers.

        ALL HAIL BRAK!!!

RE: RE: On elegant coding...
by el-moe (Scribe) on Oct 13, 2000 at 00:12 UTC
    I was just scanning some of my code to see how I do it and I notice that if the block contains a single statement, I almost always code like this:
    showCacheAndExit("current") if cacheIsGood();
    That way it reads the same way I would say it in English. But that's just me and I am FAR from considering myself an experienced Perl dude.

    -It's snowing in Mammoth!!!