Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: The Future of Perl 5

by ajs (Novice)
on Aug 19, 2018 at 14:46 UTC ( [id://1220636]=note: print w/replies, xml ) Need Help??


in reply to The Future of Perl 5

Typing sounds like a good thing. It's almost always not. Why? Because we get lost in the idea of "correctness," and so what looks like:
sub fibonacci (PositiveInt $n) { return 1 if $n <= 1; return fibonacci($n-1) + fibonacci($n-2); }
actually reads more like:
sub fibonacci ($n ... # Wait, wait... hold on a second! What is this $n thing you claim # to be sending me?! Is this a thing? Is it the kind of thing that # I approve of? What about my friends? Will my friends respect # this thing? Let's ask them... Hold on, now, do I trust my # friends? Maybe not. Better take some precautions... # Time for some state management in the form of eval. That's light # weight, right? # Also, now is a good time to pre-format some error messages just # in case. Okay, I think this $n thing is up to snuff, but just in # case, I'm going to do some state management. Hold on a bit... ) { return 1 if $n <= 1; return fibonacci($n-1) + fibonacci($n-2); }
What I'd rather see is the ability to quickly validate, completely under my control, and completely duck-typed. For example:
sub fibonacci($n {$n >= 0 && int($n) == $n}) { return 1 if $n <= 1; return fibonacci($n-1) + fibonacci($n-2); }
Where this expands to something more or less like:
sub fibonacci($n) { die '$n failed check "$n >= 0 && int($n) == $n"' unless $n >= 0 && + int($n) == $n; ... }
I have no problem with typing as a shorthand that people can use if they want, where
sub fibonacci(PostiveInt $n) {
is equivalent to
sub fibonacci($n {$n = PostiveInt->new($n)}) {
But in that case, I've opted in to a potentially very expensive type construction from my potentially very simple value.

Replies are listed 'Best First'.
Re^2: The Future of Perl 5
by tobyink (Canon) on Aug 20, 2018 at 10:13 UTC
Re^2: The Future of Perl 5
by Anonymous Monk on Aug 19, 2018 at 15:44 UTC
    I love any efforts to advance Perl and all involved but Ovid does this charming and polite self-deprecating thing I see a lot online in the language wars that seems contradictory and counter productive in terms of rhetoric and mindset.

    Perl is criticized for being too verbose and hard to read.

    Perl is then compared to some other less potent language with no sigils or lexical variables or lots of other cool features that require traditional language concepts such as punctuation.

    Perl is then berated for being longer and more complex than the perl-for-idiots reinvented-wheel that has been completely golfed, making it easier to read for an expert, but potentially much harder to understand in practice--due to increased cognitive load of having to keep all the missing punctuation in your head so the language can appear to be "pretty" like makeup or plastic surgery for your brain!

    Almost every common criticism of Perl can be turned around and touted as the feature it actually is.

    Run this 3 point program to turn this thing around, in your head, and in reality:
    1. Perl's verbosity, and lack thereof, enhances understandability. 2. Perl sigils are the best invention since rn and patch; Because they are so meaningful and context dependent; Beautiful symbols everyone knows and loves: $, @, %. 3. Perl 5 is PERFECT (but there's always room for improvement)!
Re^2: The Future of Perl 5
by raiph (Deacon) on Aug 19, 2018 at 23:10 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-24 12:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found