|Keep It Simple, Stupid|
Craftierby snax (Hermit)
|on Dec 14, 2000 at 16:28 UTC||Need Help??|
Hanging out here at PM is an enjoyable thing, as I'm sure the regulars would agree. Fun, friendly, informative -- what more could you want?
What's better is that it has actually markedly improved my "craft" in employing the oddly-shaped tool we know (and love?) as Perl.
It's also helped me to think more "perlishly" about things. Before hanging out here, I would use perl to solve problems because it was a quick and accessible tool -- but my designs were, to echo meryln's comments elsewhere, too BASIC-like. Now I begin to think about lists and contexts as I prepare algorithms. I also believe I am more prone to consider some of the OW in TIMTOWTDI.
Example: I was browsing through comp.lang.perl.misc recently and saw a cry for how to remove unwanted whitespace. Now, this is a FAQ, but I've come to enjoy using the construction
which came to me a while back (after becoming a monk) because I thought it was cool how the list propagated, and how I had pushed the whitespace worry into perl (i.e. I made split worry about it). So I posted this solution just to share the different perspective. (Note: you need to use $x = join ' ', split ' ', $x; if your string isn't in $_.)
Turns out this is pretty efficient, too -- japhy (in his real world persona) ran and posted some benchmarks that show it is as (or more) efficient than the FAQ solution and faster than some naive regex solutions. That's somewhat beside the point, though -- I had shared my solution because (1) it was a different perspective from the usual approach and (2) there was something "perlish" about it that appealed to me. Perl, and the craft thereof, has been getting under my skin. I lay this at the feet of the Monks here :)
Another example: I recently had to write a checksum checking routine, where the last digit is a checksum digit based on an algorithm applied to the other digits (no surpises there). I used this:
to grab the check digit and prepare the remaining string ...a solution that would never have occurred to me a couple of months ago (Monks have me reading the docs, and merlyn's stance on void contexts has had me thinking about return values of late) and would likely have led me to use a couple of less than appealing (to me) substr calls. It's not a huge thing, but aestethically I find it more appealing. Wait a minute -- aesthetically? It's over for me now, I'm afraid :) No longer is it enough to get code working; it has to appeal to me as well.
As a final example, also from my checksum routine just mentioned (which was a very cool problem since you had to think about the whole number both as a string and a number, a very natural thing to do in Perl), a basic part of the checksum routine invloved substituting numbers (10..35) for the letters A-Z before doing anything else. I solved this with
...and what's better is that this was the first solution I thought of. I wrote it, in that haze of concentration you can only get while coding, and afterwards looked at the solution and said -- hey, that's pretty cool!
Well, that was pretty long winded when all I really wanted to convey was that I like it here, and my experience here has broadened my enjoyment of programming.