Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^3: pissed off about functional programming

by Roy Johnson (Monsignor)
on Apr 25, 2005 at 12:27 UTC ( #451155=note: print w/replies, xml ) Need Help??

in reply to Re^2: pissed off about functional programming
in thread pissed off about functional programming

In your opinion, is there a "Perl accent" that one might write other languages using?

Caution: Contents may have been coded under pressure.
  • Comment on Re^3: pissed off about functional programming

Replies are listed 'Best First'.
Re^4: pissed off about functional programming
by dragonchild (Archbishop) on Apr 25, 2005 at 12:41 UTC
    Only if those languages have the facilities Perl provides. I once tried writing some C with a Perl accent and it was ... ugly. The first thing I tried to do was abstract away my memory management. (Reading the Perl source helped here, but doubly-indirected variables scare me on so many levels.) The second thing was to redesign, given I didn't have hashes. (I was using ANSI C.) At that point, I kinda gave up, rewrote the damn thing in Perl in about 20min, verified that it still ran in under 2 milliseconds, and walked away.

      Im pretty sure I write C with a Perl accent. The most obvious example of this is that I almost never use statements where blocks are allowed.


Re^4: pissed off about functional programming
by BrowserUk (Pope) on Apr 26, 2005 at 12:23 UTC

    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 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:

    typedef void*[ char[] ] Config;

    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?
Re^4: pissed off about functional programming
by merlyn (Sage) on Apr 25, 2005 at 14:51 UTC
      I can certainly understand Perl-flavored syntax errors, but I can't very well see a Perl accent in writing valid code in other languages. I think an accent comes from moving from a less feature-rich language to a more feature-rich language, and not using the new features. Because Perl is so feature-rich, and especially because of TIMTOWTDI, there is no Perl accent. Instead, a Perl programmer might exhibit a C accent or a shell-scripter's accent.

      Caution: Contents may have been coded under pressure.
        I think an accent comes from moving from a less feature-rich language to a more feature-rich language, and not using the new features.

        While Perl is a nice wide language it still has it's restrictions, corners and peculiar mind set. I know I have to unbend my mind from Perl when I wander off into other languages. Some examples of my Perl accent include:

        • I keep forgetting about meta-classes when I amble over to Python or CLOS.
        • I have to remind myself that macros are useful in Lisp
        • I have an awful temptation to sling everything into the local equivalent of a hash even when more appropriate data structures are available.
        • Since currying is such a pain in Perl I tend to forget to use it in languages that support it nicely.
        • etc.

        (define print display) (define $scalar 9) (define @arr #(4 3 2)) (define %hash '((a . 1) (b . 2))) (define (main args) (print (+ $scalar (vector-ref @arr 1))) (newline) (print (assoc 'b %hash)))
        Macros to turn @arr[1] into (vector-ref @arr 1)) are left as an exercise to the reader.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://451155]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2020-10-20 17:53 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (210 votes). Check out past polls.