|Perl: the Markov chain saw|
Re^4: pissed off about functional programmingby BrowserUk (Pope)
|on Apr 26, 2005 at 12:23 UTC||Need Help??|
I'd have to say yes. D has hashes, which is great, but the first thing I wanted when I started coding in D was a generalised structure for holding configuration and command line parameters. Something akin to Perl's Config.pm. A hash is the perfect structure for this, but hashes in D have typed values. They can be anything, but each hash can only contain values of the specified type. That is dashed inconvenient when one is used to having polymorphic hashes.
So about the first thing I did was to define polymorphic hash class that used void* to bypass the type checking:
Of course, the D guru's would view this as "typical of someone coming from 'scripting' languages", and could be viewed as writing D with a Perlish accent.
One day I'll get around to re-writing it using templates and mixins to do away with all the explicit casting, but for now, almost every non-trivial D program I write uses that first attempt to handle command line arguments and configuration. I did add persistance to the class so that I avoid having to specify every parameter every time--it just remembers the values from last time I specified it.
That also allows a degree of self-configuration. Each run of a program can remember things like the number of instances of a particular class that it used this time and average that with the number record in it's configuration. Then the next time the program runs, it can pre-allocate space for this number of instances when the class initialises which avoids a bit of thrashing and GC runs for highly dynamic classes.
Using Perl for an extended period of time has certainly affected the way I code in a whole range of ways. For a while now I have been looking around at the features and facilities of several other languages and comparing both the features and implementations. Even when other languages have equal or greater feature sets, Perl always comes out on top for ease of use and the way it manages to blend those features together into the langauge. Perl 5 has lots of weird nooks and crannies and inconsistencies, but it still manages to blend it's features better than most other languages I've looked at.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco.
Rule 1 has a caveat! -- Who broke the cabal?