When I first started writing simple Perl programs, I should admit I didn’t take Perl all too seriously. In the back of my mind I used to associate Perl heavily with the word ‘hack’. Here’s one of the ways in which this word is being defined at
http://www.dictionary.com:
1. To cut irregularly, without skill or definite purpose; to notch; to mangle by repeated strokes of a cutting instrument; as, to hack a post.
Having originally come from C++/Java roots, to uninitiated self programming Perl in fact meant “hacking”. I had friends (err.. still do) who used to apply the word “hack” in a similar context too. Hack! There are a number of websites dedicated to nerds/programmers such as
SlashDot.org and
codingstyle.com where the word is a common occurrence.
I recall back the days when writing a true “hack” made me somewhat proud of myself. I would feature the word prominently in my code just before where the true ‘masterpiece’ (aka ‘hack’) was placed. For example, take a look at this snippet:
# HACK
# see if current time field value exceeds its maximum (reminder of % o
+peration is greater than 0);
# if true, add reminder to
($time_date[$i+1], $time_date[$i]) = ($time_lim != -1 && ($rem = $time
+_date[$i]%$time_lim)) ? (($time_date[$i] - $rem) / $time_lim, $rem) :
+ ($time_date[$i+1],$time_date[$i]);
# equivalent (not HACK)...
# if ($rem = $time_date[$i] % $time_lim) {
# $time_date[$i+1] += ($time_date[$i] - $rem) / $time_lim;
# $time_date[$i] = $rem;
# }
Compare the ‘HACK’ portion of the code with an equivalent and render your own judgment. Well, revisiting my old code, sticking with the community of fellow monasterians, and reading various articles/books on proper software coding practices made me rethink a lot of old notions and ideals I once cherished and now came to despise. Having had to maintain my old code and deal with seemingly childish ‘hacks’, I became increasingly frustrated by any mentioning of the word ‘hack’ in the context of programming (especially Perl). In my conversations with fellow developers, I try to use the word with extreme caution and very very seldom. I’m trying to be careful not to excite any other developer (especially junior type) into writing a lot of ill hacks that I might eventually have to deal with later in my work.
Have you had similar bad experiences in your career as a Perl programmer? Did you ever have to deal with stubborn ‘hackers’ or haunted by the shadows of certain ‘hacks’ you had implemented in the past?
UPDATE: Or is my interpretation of 'hacking' invalid? ;)
_____________________
$"=q;grep;;$,=q"grep";for(`find . -name ".saves*~"`){s;$/;;;/(.*-(\d+)
+-.*)$/;
$_=<a HREF="/index.pl?node=%22ps%20-e%20-o%20pid%20"> "," $2 </a>;`@$_
+`?{print"+ $1"}:{print"- $1"}&&`rm $1`;
print$\;}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.