6 ms·
I loved Perl when I first learned it. I loved it for the same reason I love Python now. It's very easy to express ideas I have in mind without worrying about
by hangonhn 11y ago
I loved Perl when I first learned it. I loved it for the same reason I love Python now. It's very easy to express ideas I have in mind without worrying about the details. It's a great prototyping (as in prototyping ideas, not as in the type system) language. It was my introduction to "higher level" languages. That said, Perl suffers from having too many magical operators that makes it hard to reason about a snippet of code. I feel Python strikes the right balance.
Your comparison to Javascript is apt but I think a lot of us also find Javascript to be a bit of a horror. Recently I learned that Javascript doesn't handle modulus on a negative number correctly among other things.
- deleted 11y ago[deleted]
- raiph 11y ago> [lang X] doesn't handle [basic math] correctly among other things. From a recent talk[1], what are x, y, z in the following? x = 7 ÷ 2; y = -7 ÷ 2; z = .1 + .2 - .3 x y z 3.5 -3.5 0 # human 3 ? tiny number # c89; ? depends on compiler 3 -4 tiny number # ruby 3 -4 tiny number # python 2/3 3 -3 0 # bc 3.5 -3.5 tiny number # perl5 3.5 -3.5 0 # perl6 ---- It isn't just basic math. How "long" is the following string? ปฏิบัติจริง 7 characters # human len("ปฏิบัติจริง") = 33 # python 2 len("ปฏิบัติจริง") = 11 # python 3 "ปฏิบัติจริง".length = ? # ruby (For Ruby, I've found "the core language does not provide a way to count [human perceived characters]". [3] Is that still correct or out of date?) ---- > Perl suffers from having too many magical operators that makes it hard to reason about a snippet of code. I feel Python strikes the right balance. To quote Larry Wall, "Perl 6 ... has been rethought and rebalanced on every level".[4] It might be interesting for you to pick a couple Perl 5 operators that you consider too magical; then we could look at the merits and demerits of those ops in Perl 5 and their equivalents in Python and Perl 6. > It's very easy to express ideas I have in mind without worrying about the details [of Python, now, and Perl, back in the day] This, of course, has explicitly been a deliberate focus of all the Perls. Part of the point of Perl 6 was to remove the bits in Perl 5 that were problematic (including some "too cute/weird" stuff) and to introduce much nicer higher level abstractions (eg grammars instead of just regexes[5]). ---- I've long encountered vocal folk who underestimate or misunderstand Larry Wall and Perl to an absurd degree. Perl has been focused for over two decades on making it easy to get the right results when doing basic practical things (like integer division and counting characters) and, imo, that ought to be obvious to anyone who looks at the matter carefully. ---- [1] http://www.slideshare.net/Ovid/perl-6-for-mere-mortals http://www.slideshare.net/Ovid/perl-6-for-mere-mortals and https://www.youtube.com/watch?v=lpu-3UF_b48 https://www.youtube.com/watch?v=lpu-3UF_b48 [2] http://www.reddit.com/r/perl/comments/2szv7m/beginner_programmer_here_looking_for_help_for_an/cqzk3hi http://www.reddit.com/r/perl/comments/2szv7m/beginner_progra... [3] http://unicode-programming.readthedocs.org/en/latest/count-characters/ruby/ http://unicode-programming.readthedocs.org/en/latest/count-c... [4] http://www.infoworld.com/article/2882300/perl/perl-creator-larry-wall-rethought-version-6-due-this-year.html http://www.infoworld.com/article/2882300/perl/perl-creator-l... [5] https://github.com/moritz/json/blob/master/lib/JSON/Tiny/Grammar.pm https://github.com/moritz/json/blob/master/lib/JSON/Tiny/Gra...
- hangonhn 11y agoWow. This is such a fantastic comment; I am very impressed. I think my experience with Perl ended at Perl 5 so my comment is a bit dated but the sentiment stayed with me, which I admit is unfair. I also forgot to give Perl credit for another thing: introduction to regex. Perl was a great language for me to learn and I should revisit my sentiments about it.
- raiph 11y ago> I think my experience with Perl [is] a bit dated In some ways, contemporary Perl 5 (eg this year's 5.22 release) is quite unlike older Perl 5s. For example Moose -- which first arrived in 2005 -- is a powerful and relatively clean OO and "roles" system which has matured in to a huge ecosystem of its own within CPAN. (It was/is a kind of back port of the Perl 6 OO model which itself built upon the notions found in systems such as CLOS.[1]) But my personal focus is Perl 6. > I also forgot to give Perl credit for another thing: introduction to regex. Perl 6 unifies "regexes", PEGs, and lexical closures. [2]. > Perl was a great language for me to learn and I should revisit my sentiments about it. Anyone who joins the freenode IRC channel #perl6 and says hi will be welcomed.[3] If you visit, feel free to paste a link to my comment. :) ---- [1] https://en.wikipedia.org/wiki/Common_Lisp_Object_System https://en.wikipedia.org/wiki/Common_Lisp_Object_System [2] https://en.wikipedia.org/wiki/Perl_6_rules https://en.wikipedia.org/wiki/Perl_6_rules [3] https://kiwiirc.com/client/irc.freenode.net/perl6 https://kiwiirc.com/client/irc.freenode.net/perl6 (today's log at http://irclog.perlgeek.de/perl6/today http://irclog.perlgeek.de/perl6/today)
- raiph 11y agoSomeone just pointed out that I missed a line in the bit about string length: "ปฏิบัติจริง".chars = 7 # Perl 6
- raiph 11y agoAnd someone else just pointed out that the python line should instead be the two lines: 3 -4 tiny number # python 2 3.5 -3.5 tiny number # python 3
- adrusi 11y agoPerl suffers from having too many magical operators that makes it hard to reason about a snippet of code. Certainly a matter of personal preference, but a sprinkling of operators isn't so bad once you're acquainted with the language. Yes it's possible to weave a mess in perl, but most of the time you're just dealing with code that might have a few sigils preceeding an identifier, not ASCII soup. I'd say the real issue is weak typing (implicit conversions between primitives, using strings for many things where some more specialized data type would have been more appropriate) and variable scope problems. These can lead to hard to locate bugs. Worse is the culture in the perl community of manipulating the VM's internals and generating code at runtime and all kinds of other extremely dynamic behaviors. It's amazing what perl lets you accomplish there, but when some package you got off CPAN does something weird and then something goes wrong, it can get really weird. Recently I learned that Javascript doesn't handle modulus on a negative number correctly among other things. That's not really true. Javascript doesn't have a modulus operator, it has a remainder operator, and it is completely valid as a remainder operator. The "%" operator is usually called the modulus operator, but it originated in C where prior to C99 its behavior on signed integers was undefined, and on signed integers modulo and remainder are equivalent. So javascript didn't want undefined behavior so they picked one definition and ran with it, it just so happens that C99 chose the other definition and it stuck.
- jbert 11y agoI'm interested in the details of the variable scoping problems are. I'd have thought that perl's explicit declaration of lexicals with 'my' was better than "declare at first use" of javascript/python/ruby. [There's a class of mistake where you typo a variable name which you can make in those languages which gets caught in a language where you have to declare variables.]
- SwellJoe 11y agoI share your confusion over that assertion. I actually miss Perl's excellent block scope capabilities when working in almost every other similar language. I imagine most other languages have gotten it, by now, but a few years ago when I was using Python for a few years for a client it didn't have block scope and I missed it. A brief googling actually hints that maybe Python still doesn't have block scope, which is pretty weird, so I assume I'm googling wrong. But, perhaps discussion of scope problems in Perl is just when talking about very old code. Perl had some scope atrocities back in Perl 4 and some weirdness in early Perl 5 days. But, for the past 15 years or so, it's been very predictable and has improved (like the syntactic sugar of "my" declarations in foreach or while expressions).