Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Stupid Emotional Programmer Attachment, anyone?

by talexb (Chancellor)
on Oct 31, 2003 at 15:20 UTC ( #303569=perlmeditation: print w/replies, xml ) Need Help??

At last night's Toronto Perl Monger's meeting, Richard Dice talked about a gee-whiz piece of code that he cooked up using the three modules CGI::Application, Class::DBI and HTML::Template. But the reason for today's meditation is about something he mentioned during the presentation: his (somewhat irrational) pride at the code he'd written, to which he referred as Stupid Emotional Programmer Attachment.

As soon as he uttered those words, I understood what he was talking about .. when we as software developers rise above the mundane and create something really brilliant, don't we get attached to it?

My examples are not all Perl, but they include

  • A piece of C code that maneouvered robotic arms around so they didn't crash into each other. Because of the geometry involved, they had to swap roles (and I had to reverse the voltage) for some configurations. So amazing to watch the arms move.
  • A piece of C code that was the communications subsystem for a Point of Sale system: it ran under both DOS (as a Terminate and Stay Resident program) and PC-MOS (as a seperate task), and handled transactions either via 3201 (poll select) or dial modem, all from a single binary. A state machine, arrays of function pointers, object orientation, the works. Beautiful.
  • One of my first Perl scripts that translated memory model information into chunks of SQL, complete with checks that the foreign keys format matched the original table index, and checks that tables were declared only after the tables they referred to had been declared. Very, very cool.
Anyone else have favourite bits of code of which they're inordinately proud?

--t. alex
Life is short: get busy!
  • Comment on Stupid Emotional Programmer Attachment, anyone?

Replies are listed 'Best First'.
Re: Stupid Emotional Programmer Attachment, anyone?
by perrin (Chancellor) on Oct 31, 2003 at 16:29 UTC
    Hmmm, my take on this is totally different from yours. When I hear "Stupid Emotional Programmer Attachment" I think of cases where I have been too proud of a particular chunk of code to see that the problem could be solved in a much simpler way. If you look for it, you will see hundreds of examples of this all around you -- situations where people were too proud of their homegrown HTML parser to use a CPAN module, too proud of their custom data persistence system to use a relational database, too proud of their XML skills to use a key=value config file. It's not a positive thing. To be a really effective programmer, you have to be able to shut down your ego now and then and accept that the coolest approach may not be the best way to get things done.

      Interesting .. yes, guilty of that one too. It can be hard to let go of a piece of code that works really well but looks .. erm .. rather hacked. It's harder still when someone shows you a much cleaner way to get the same thing done .. in half the code.

      --t. alex
      Life is short: get busy!
Re: Stupid Emotional Programmer Attachment, anyone?
by jZed (Prior) on Oct 31, 2003 at 16:37 UTC

    if( s/Stupid/Expectable/) { $i_know_what_you_mean };

    It's this sort of "I am god, look what I can do". For me it lasts a few hours or a few days after I'm done coding, then my eyes unglaze and I start seeing that a) the thing can use some improvement and/or b) well yes it's cool, but there are so many other things laying around that need fixing.

    The Buddhist metaphor for attatchment is a monkey who gets caught because he reaches into a jar to get a nut, then his fist is too big to get out of the jar without letting the nut go. The fact that we all reach for the nut is only natural, we're hungry monkies. It's when we forget to let it go when we need to that it becomes a problem.

    The fact that most employers and society at large don't understand or appreciate what we do (especially in these economic times) means that if we want pats on the back, we have to give them to ourselves. That's why stuff like acknowledging people in Changes logs and such is important - if we don't recognize each other's brilliance, who will? And that way too we remind ourselves that we are such far-seeing geniuses because of the shoulders we stand on, not because we were born tall.

    Which code am I most proud of? Whatever piece I just got done writing :-).

Re: Stupid Emotional Programmer Attachment, anyone?
by barrd (Canon) on Oct 31, 2003 at 16:25 UTC
    Anyone else have favourite bits of code of which they're inordinately proud?
    Too bloomin' right ;)

    Back in '95 myself and a friend working for a London based company had been told by several companies that what we were proposing was "JUST NOT POSSIBLE". I won't go into the semantics and back then I was a complete novice but I listened to these supposed experts and said "nah, they're talking ****".

    Three months later we proved them all wrong - it took a *nix box, an Apple Mac and a NT server, and it was a gluing app that I wrote that connected all three to do the job that we needed. The Mac provided the security, the *nix (Slackware) box the connectivity and the NT box the background functionality to get the project off the ground using {pleeugh} VB.

    Apart from the VB everything else was written in perl (inc. the Mac using V.8.x and MacPerl). It was secure, robust and some elements are still running to this day.

    That was my proudest moment when several months later the same 'experts' from all the companies were in a room with us both and they all apologised and wanted to know how the hell we had done it...

    "Perl" was my reply :)

•Re: Stupid Emotional Programmer Attachment, anyone?
by merlyn (Sage) on Oct 31, 2003 at 23:54 UTC
    I've been writing code for over three decades.

    I've discovered that there is a "time factor" for all of my code: the time between when I write it, and when I become disgusted with it. Sometimes it's mere minutes, sometimes it's years. But it always hits eventually.

    So, while I can point to some very clever code I've written, I'm pretty sure that it's just too early in the sliding time window for me to be disgusted with it instead. Caveat Programmer. {grin}

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      Hey Merlyn, I'm with you.

      Over 30 years of coding has taught me that no mater how much I thought I knew at any given pojnt in my existence, I can pretty soon prove it wasn't much!

      In fact I find it very difficult to revisit code. Usually because I will see so manythings that I would do differently now. Especially with Perl as the size of the toolbox gets bigger and bigger by the week! I have done some things that I am instantly proud of, especially when they get accolades from the client. But self-disenchantment soon sets in and eventually I will only look at it if I am paid to or badgered sufficiently that looking is the only way to peace.


Re: Stupid Emotional Programmer Attachment, anyone?
by theorbtwo (Prior) on Oct 31, 2003 at 17:42 UTC

    In my case, the one great example I can think of this wasn't exactly well-written so much as quickly written. At the last Lancaster County Linux Users Group meeting I was at, somebody wanted to run two tethereal processes at once, and have one output in green and the other in red. (For incomming and outgoing packets on a firewall.) A professional programmer across the table from me started to say how hard it would be. I just said "I can do that in one line of perl" -- and then proceded to do it, with help from a manpage (to get the escape code), and a peice of paper.

    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Re: Stupid Emotional Programmer Attachment, anyone?
by gjb (Vicar) on Oct 31, 2003 at 15:54 UTC

    In fact, I try not to since it makes it harder to see room for improvement.

    Only yesterday I noticed that a parser I'd written and which took about a page of Java code (yeah, right, the evil empire ;-) could actually reduced to something like 10 lines. The parser is a piece of code I wasn't especially proud of, but it did a good job. Had I been very proud of it, I might not have questioned the code and seen the shortcut.

    Just my 2 cents, -gjb-

Re: Stupid Emotional Programmer Attachment, anyone?
by samtregar (Abbot) on Oct 31, 2003 at 19:34 UTC
    I'm proudest when I fix a tough bug. Writing code is largely a matter of imagination and syntax, but bug hunting is serious analytical work. I get a rush everytime I nab a really nasty one. It doesn't seem to matter if I'm the one that wrote the buggy code, which I suppose qualifies as stupid!

    Lately I've been thinking about another kind of Stupid Emotional Programmer Attachment - the attachment to a favorite language. As the freak that wrote a Perl SDK for Quake 3, I know all about choosing the wrong tool for the job. I've been reading about 3d game programming again and I just can't stop thinking about doing it with Perl. That's just plain dumb. First, Perl performance simply not up to the task. And more importantly, I can learn a lot more from the tons of high quality C/C++ 3d game code if I'm working in the same environment instead of hacking around in an backwater. Smarten up, me!


      Good grief man! Everyone knows that you're thinking just *can't be done*!

      heh heh heh ... won't be seeing ol sam for while .... oh, ahem, is this thing still on? ...

Re: Stupid Emotional Programmer Attachment, anyone?
by Abigail-II (Bishop) on Oct 31, 2003 at 15:36 UTC
    I've some JAPHs of which I'm proud. And I've a program that generates a regex. It's not the program that makes me proud, but the regex does. Does that count?


      Does it count? Absolutely. Any piece of code that puts a silly grin on one's face counts.

      --t. alex
      Life is short: get busy!
Re: Stupid Emotional Programmer Attachment, anyone?
by castaway (Parson) on Oct 31, 2003 at 17:46 UTC
    Guilty too. (Currently of im2 - cos lots of people seem to like it, and a telnet client in perl which probably isnt anyones dream but mine.. ).

    I wouldn't call it stupid though. It's what keeps us going at times, when we want to get the damn thing working, are too proud to give up, etc. What irks when someone suggests a simpler or better solution (or a module which does what we just laboured hours to do), is that we don't want to admit the time spent was wasted. Which we'd have to, if we accepted that there were better ways of doing it.

    As someone else said, that can be a bad thing too, especially in work situations where it would be better to have maintainable/portable code, than whichever spaghetti we don't want to improve..

    You live and learn though.. I'm on the 3rd (or is it 4th) incarnation of one of my programms, and it's still improving, sometimes you just have to throw the whole thing away and start again..


Re: Stupid Emotional Programmer Attachment, anyone?
by etcshadow (Priest) on Oct 31, 2003 at 19:29 UTC
    How about a program which can beat me at chess? It runs in 640K on DOS (as well as on unix). With the "difficulty" set high enough to school me, it can generate a typical move in about 30 seconds (on a 220MHz celeron). With the difficulty set high enough to beat my father (a class-C-ranked chess player) it took about 2 minutes per move. And all without an opening book!

    (Sorry folks, written in C++ (the kind that relies heavily on C).)

    Not an editor command: Wq
Re: Stupid Emotional Programmer Attachment, anyone?
by mcogan1966 (Monk) on Oct 31, 2003 at 19:53 UTC
    In a word, yes.
    I've written a few good pieces of code of which I'm very proud. And it's even more sad when you have to give it all away beacuse it's for $client. It's almost like watching a child leave the house (though I wouldn't really know this as I don't have kids). It's hard to justify making a 'copy' of some code that is brilliant, pretty, or otherwise cool in your book, just so that you can keep it with you. Even moreso when $client doesn't like the idea of any copies of said code existing outside of their ownership.
      Copies for yourself are useful for reminding you what you learned, for improving your methods, for historical preservation, and for covering your backside in case of future litigation.

      Quantum Mechanics: The dreams stuff is made of

        But there is sometimes and issue between that and terms of a contract. Espeically when working for $gov_agency. They tend to get a little peeved when code you write for them is 'copied' anywhere else. Even if it's in Java, Perl, or any other 'open source' style language. And even if it's only some core code. That has always been a bit of an issue for me. So I try to keep something aside somewhere I can reference while I'm still working. Some kind of "Book O' Coding Goodness" that I can pull off a shelf while I'm employed there.
Re: Stupid Emotional Programmer Attachment, anyone?
by bradcathey (Prior) on Nov 01, 2003 at 14:38 UTC
    I haven't been at Perl long enough to write something to really be proud of over the long haul, but I think each one of us is proud of/pleased/happy with stuff we write every day, even, as Merlyn says, it's just for a few minutes. Otherwise, why crawl out of bed in the morning!? Even when I finish a little CGI form processor, and the client says, "Wow, cool" (because they think it's all magic), I'm proud, or at least pleased.

    Guess I'll have to take my pride in small increments. Then later, I can write stuff that will feed the poor, bring peace to the world, etc. But for now, I'm proud finish something that uses strict and checks for taint.

    Not to patronize any monk in particular, I'm often proud, by association, of a clever piece of code I've seen in a reply to a SoPW question. My reaction is to just chuckle out loud (strange looks from the family) and wish I had thought of it.

    Write on, monks.

Re: Stupid Emotional Programmer Attachment, anyone?
by Marza (Vicar) on Oct 31, 2003 at 18:41 UTC

    Absatutly! I would guess for most it is the first "serious" script they produced. Mine was a mail list manager for sendmail. It is not as good as it could. People could ripe on it but I am still proud of it since it was used(and is still used) by many people.

Re: Stupid Emotional Programmer Attachment, anyone?
by theorbtwo (Prior) on Nov 01, 2003 at 06:51 UTC

    (Yes, I am repling to this twice.)

    I saw a nifty new thing on the other day, and didn't have anything purticular to search on, so searched on "theorbtwo", and found this. Somehow, Star light / star bright. had managed to get onto what appears to be a dutch chat board focusing on postmodernist poetry... and that makes me proud.

    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Re: Stupid Emotional Programmer Attachment, anyone?
by The Mad Hatter (Priest) on Nov 01, 2003 at 01:38 UTC
    I'm very proud (even though I could have used an existing solution) of my discussion board / weblog software, which other people and myself use daily at The Public Mooseboard and my personal blog Windlicht. I guess the pride stems from the amount of work I've put into it as well as the great feeling I get when someone else uses and enjoys what I've done regularly.

    This type of pride isn't limited to programming either; I've been quite proud of some of the more complex, but still degradeable, CSS designs I've created in the past.

Re: Stupid Emotional Programmer Attachment, anyone?
by WhiteBird (Hermit) on Nov 02, 2003 at 00:55 UTC
    The Medical Staff office where I work purchased an expensive bit of software to help them keep track of the credentials of the physicians who work at the hospital. It's based on an MS-SQL database and works well enough for the people that use it. However, they wanted to tap into the database and make the physician information available to the entire staff of the hospital. When it came time to implement that particular piece of the project they found that it required purchasing many, many more software licenses and having a tech install it on every PC in the establishment--a large and expensive proposition.

    While the other analysts were standing around scratching their heads, I dabbled around with some Perl code and SQL programming and built a nice little interface that displays the information on our Intranet. It works well--people use it--and it cost the hospital exactly nothing in actual dollars for software.

    It's not so much the code that I'm proud of--it's the ability that Perl has of being able to do much-with-little. And the fact that while I'm considered to be a bit of an odd-duck here, I was able to pull up a solution for a problem that no one else knew how to solve.

Re: Stupid Emotional Programmer Attachment, anyone?
by DaWolf (Curate) on Nov 02, 2003 at 12:50 UTC
    Well... I'm a humble web developer (I haven't developed anything that runs outside a browser YET) but damn me if I'm not guilty too.

    Under Perl I've developed a banner randomizer a few years ago and now I'm finishing my IRC bot - well, it will be my first non-browser app :)

    Under PHP (that I've been developing with in the past two years) I've made a text parser that analyzes a news feed to search and highlight over 10.000+ words, all based on RegEx knowledge that I've acquired with Perl. And damn, man, this script is as fast as it can be :)))

    I think that when you do something that solves a pretty nasty problem or achieve a goal with a large amount of effort you should be proud!

    Just my two cents. :)

    my ($author_nickname, $author_email) = ("DaWolf","erabbott\") if ($author_name eq "Er Galvão Abbott");
Re: Stupid Emotional Programmer Attachment, anyone?
by Ryszard (Priest) on Nov 03, 2003 at 09:50 UTC
    Nice thread, its interesting to see other peoples perspectives..

    Back in the day, my 1st real job was doing a bunch of data entry into lotus 123 spread sheets. how i hated that with a passion.

    We upgraded from the old 386's to 486's with MS Office on them, which meant we had to re-engineer all the spreadsheets.

    I got to thinking that these bloody bits of dead tree had to come from somewhere, i mean being they werent hand written and all..

    At the time i worked for $large_corporation with about 25k employees, and given these reports used to magically appear at the begining of each month it was a task at tracking down where they came from..

    Eventually i began getting the reports electronically, and to make a medium story shorter, without any programming experience, i managed to (as i know it now) parse the electronic files, put data in the correct sports and turn two weeks of solid data entry into only a few minutes work.

    No it wasnt perl, yes it was VBA, yes the code really sucked (the following year i went and started uni, and realised how crap the code was), but it was really a proud moment for me to say to my manager, hey, check this out, what's next on the list of automation?

    PS: I ended up writing a reasonably featured hex editor in Excel.. It's amazing the innovation that can occur when yoru machines are locked down tighter than a drum :-)

Generic HTML Form Validator
by YAFZ (Pilgrim) on Nov 03, 2003 at 14:49 UTC
    Well, mine isnīt in Perl, C/C++, etc. but I like it ;-) It is written in JavaScript (anybody who says ECMAScript? ;-) and is a generic HTML form validator which lets HTML designers use nothing except their HTML skills to create forms that validate themselves.

    The idea is to use the utility of user-defined-HTML-attributes-on-the-fly and thus get rid of tackling with JScript at all.

    The idea is explained (only in Turkish, if anybody is interested I can translate it into English) here: Generic HTML Form Validation You can download the JS package and the sample web page. It is compatible with Mozilla, Netscape, Internet Explorer. The difference between this system and the others is that they need the programmer/designer to modify the JavaScript in one way or the other.

    I'm sure Perl has got nice solutions to this frequently encountered problem but in case you donīt use Perl in every Internet project, I think this tool can help you in a valuable way ;-)
      Umm, no matter what the client side does in terms of validation, the server side needs to validate. There is no way to ensure that all input into the server side will come through your javascript. I usually do some of each - trap what errors I can in JavaScript and check *everything* in Perl anyway.
        I have no arguments against that. All I wanted to do was to ease the coding and package frequently used code into a tiny and compact system that can be used in different projects, pages, etc.
Re: Stupid Emotional Programmer Attachment, anyone?
by Helter (Chaplain) on Nov 03, 2003 at 16:33 UTC
    Written in a combo of C/Assembly, my senior design project was a RC Tank converted to be driven by a micro-controller. Mounted in the "turret" was a IR sensor. Using 3 beacons it could determine it's position, and would travel a pre-programmed path.

    The path was programmed by clicking on a grid display on a PC, then was downloaded as coordinate pairs.

    Fully battery powered, and the tank moved 3 ft in 1 second from a dead stop.....which is why the sensors for object avoidance were not good enough to work correctly (1.5 ft of view..., so momentum would carry it through the object, although then it would go "around" the object and continue on it's path...).

    It was amazing to put it down in the area in any random place, and it would navigate just by swinging it's turret around.... And all that code fit into 640KB....
Re: Stupid Emotional Programmer Attachment, anyone?
by allolex (Curate) on Nov 04, 2003 at 07:35 UTC

    You're referring to one of the Perl cardinal virtues: Hubris. Here is an example of code reuse (a minor virtue) from the Camel book (glossary):


    The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful, and document what you wrote so you don't have to answer so many questions about it. Hence, the first great virtue of a programmer. Also hence, this book. See also impatience and hubris.


    The anger you feel when the computer is being lazy. This makes you write programs that don't just react to your needs, but actually anticipate them. Or at least that pretend to. Hence, the second great virtue of a programmer. See also laziness and hubris.


    Excessive pride, the sort of thing Zeus zaps you for. Also the quality that makes you write (and maintain) programs that other people won't want to say bad things about. Hence, the third great virtue of a programmer. See also laziness and impatience.


    Perl and Linguistics

Re: Stupid Emotional Programmer Attachment, anyone?
by tsee (Curate) on Nov 04, 2003 at 12:18 UTC
    As others have noted, this sounds much like the third "virtue". Personally, I have found myself guilty of such S.E.P.Attachment with some of my modules in which I thought I'd done something really clever. File::Stream comes to mind, or Math::Symbolic. Steffen

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://303569]
Approved by broquaint
Front-paged by Enlil
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2022-07-06 10:16 GMT
Find Nodes?
    Voting Booth?

    No recent polls found