Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^2: pissed off about functional programming

by merlyn (Sage)
on Apr 24, 2005 at 13:18 UTC ( #450943=note: print w/replies, xml ) Need Help??

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

It obviously happens with human languages!

And because we call that "speaking with an accent", I use that same term with some Perl coders. "You're speaking Perl with a C accent." "I'm coding Perl with a LISP." (The word "accent" there is optional.)

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

  • Comment on Re^2: pissed off about functional programming

Replies are listed 'Best First'.
Re^3: pissed off about functional programming
by Roy Johnson (Monsignor) on Apr 25, 2005 at 12:27 UTC
    In your opinion, is there a "Perl accent" that one might write other languages using?

    Caution: Contents may have been coded under pressure.
      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.


      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?
        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.
Re^3: pissed off about functional programming
by Anonymous Monk on Apr 25, 2005 at 22:49 UTC
    I used to speak perl with a very C accent. But lately (many years down the road), my perl is becoming much purer, and full of more native perl idioms, while my C still looks like C. I think this is a sign that I'm beginning to be a nearly-native speaker, as opposed to some guy who took a berlitz course just before a trip overseas.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://450943]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2017-06-23 04:02 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (533 votes). Check out past polls.