News for hackers. Stuff that matters.
Re:The Fall Of Perl, The Web's Most Promising Language by guelo on Sunday February 23, 2014 @11:54PM (#7289159)
In terms of expressiveness I think Python falls closer to Java than Perl. People make fun of Perl's sigils but I think Python's magic underscores and 'self' everywhere are much uglier in a verbose way. And no one will ever convince me that significant-white-space and not having block enders are good ideas, it makes refactoring and copy-pasting code hazardous. And I don't understand why every language hasn't added Perl's native regex syntactical sugar, it's a huge win for many problems.

But yea, Python won.

Re:The Fall Of Perl, The Web's Most Promising Language by thirsteh on Monday February 24, 2014 @12:03AM (#7289186)
To your last point about regexes: I think the general idea is to discourage their use, at least as a default. It is so easy to use them in Perl that they are used way too much, e.g. when you could do a regular (and faster) string search.
Re:The Fall Of Perl, The Web's Most Promising Language by Renaud on Monday February 24, 2014 @01:27AM (#7289383)
But isn't that a crime of premature optimisation? Perl's integration of Regex makes them easy to use and they fit naturally in the language, a lot more than in most implementations.

Being able to use Regex easily is a plus in my book. Yes they are lower than some dedicated string search or some state machine ad-hoc implementation, but you can document Regexes and they pack a lot of punch.

If a Regex is causing a concern in term of performance, then it may be time to review that code and optimise it, otherwise why even bother?

When people talk about Regex being bad and they say you can often use string manipulation instead they only talk about the most trivial uses of Regex.

As soon as you go beyond that, using a Regex is almost always going to be cleaner than spewing lines of codes and building state machines to achieve the same functionality.

Re:The Fall Of Perl, The Web's Most Promising Language by maxerickson on Monday February 24, 2014 @08:57AM (#7290714)
It's more a matter of different design taste than it is an optimization.

(I don't think it is controversial that Python has a relatively simple language definition/grammar/etc; regex as language syntax would expand all of that quite a bit)

Re:The Fall Of Perl, The Web's Most Promising Language by DougWebb on Monday February 24, 2014 @01:20AM (#7289360)
That's a lousy reason to not include them. Cars are used to much and people really should walk and bike and take the bus more, but we're not about to make cars more difficult to use because of that.

Perl's embedding of regexes into the language syntax is a fantastic feature, as is the way captured groups can be assigned to a list. No other language comes close to making regexes usable. Javascript, which at least has a literal syntax for regex, is still awkward. And the other language I use the most, C#, has such a bad interface for getting captures that I get it wrong and have to look up the documentation EVERY SINGLE TIME I USE IT.

I would compare regex as an add-on library in most languages to be as awkward as OOP as an add-on to Perl 5 was. At least Perl has corrected that; besides Javascript, have any other languages taken steps to make regexes easier to use?

Re:The Fall Of Perl, The Web's Most Promising Language by pyre on Monday February 24, 2014 @01:53AM (#7289461)
> At least Perl has corrected that

Perl hasn't really corrected that. Moose is an external library (with downsides, such as load-time last I checked). When it becomes part of the core Perl language, I'll consider Perl to have corrected it.

Re:The Fall Of Perl, The Web's Most Promising Language by pyre on Monday February 24, 2014 @01:50AM (#7289449)
IIRC, they were not included because Guido's opinion is that Regex should be a library, not a core feature of a language.
Re:The Fall Of Perl, The Web's Most Promising Language by einhverfr on Monday February 24, 2014 @12:37AM (#7289280)
> And I don't understand why every language hasn't added Perl's native regex syntactical sugar, it's a huge win for many problems.

The one language which didn't for a very good reason was Rebol. The reason is that Rebol has different syntactic sugar for recursive descent parsing.

Re:The Fall Of Perl, The Web's Most Promising Language by pyre on Monday February 24, 2014 @01:48AM (#7289441)
> People make fun of Perl [...] but I think Python's [...] are much uglier

Do you really expect this to end well? There are endless flamewars raging across the Internet about the 'correct' way to place braces with both sides claiming that the other side's solution is 'uglier.'

> And no one will ever convince me that significant-white-space and not having block enders are good ideas

Insightful discussion doesn't usually stem from the phrase 'no one will ever convince me.'

> it makes refactoring and copy-pasting code hazardous

I see this bandied about a lot, but I'm curious if people actually run into this issue. I certainly haven't run into this issue, nor have I come across anyone who has had this issue.

A couple of points:

1) This comes across to me sort of like the arguments against git due to the user's ability to rewrite commits (e.g. "I can't use git because you can rewrite commits; therefore when someone fixes a bug they will rewrite the commit that introduced the bug rather than patch the current state of the repo"). Arguments that are theoretical, rather than practical. Similar to the other top-level poster claiming that significant whitespace will run into issues with all of the Unicode whitespace characters.

2) When you copy-paste Perl (or C, or Java, etc) code, do you not reformat that code anyways? I shudder to think of the code base where refactoring efforts rely on copy-pasting code without any sort of a consistent style since "it's between the braces, so we're all good."

3) This seems to be an argument that runs along the lines of static-vs-dynamic typing. One side argues that static-typing is "better" because you don't have to worry about type errors cropping up at runtime, since they are resolved at compile time. You're arguing that it's 'hazardous' to copy-paste or refactor code because you could mess up the indentation, but you don't have to worry about these things 'for free' when you have more concrete start- and end-block semantics.

Re:The Fall Of Perl, The Web's Most Promising Language by pronik on Monday February 24, 2014 @09:17AM (#7290829)
> 2) When you copy-paste Perl (or C, or Java, etc) code, do you not reformat that code anyways?

Yes, with Perl::Tidy and one keyboard shortcut bound to it. With Python I have to manually and very carefully block-indent the pasted fragment and then figure out how it fits into existing code. Even if there were a proper Python code formatter (hint: there isn't anything even close in functionality to Perl::Tidy) it wouldn't be able to figure out the code, since whitespace is significant. No such thing in Perl -- paste, tidy, rinse and repeat.

Re:The Fall Of Perl, The Web's Most Promising Language by ptx on Friday March 07, 2014 @06:55PM (#7363539)
> Yes, with Perl::Tidy and one keyboard shortcut bound to it. With Python I have to manually and very carefully block-indent the pasted fragment and then figure out how it fits into existing code.

No need to do it carefully or manually. The indentation within the fragment will be internally consistent, as will the indentation in the existing code you're pasting it into. So you just have to figure out the difference in indentation level between the two and use whatever keyboard command your editor has (e.g. C-c < and C-c > in Emacs) to shift the whole fragment.

> Even if there were a proper Python code formatter (hint: there isn't anything even close in functionality to Perl::Tidy) it wouldn't be able to figure out the code, since whitespace is significant. No such thing in Perl -- paste, tidy, rinse and repeat.

Right, but in Python there is no such thing as reformatting. The information about the structure is already encoded in the indentation, so it's neither possible nor necessary to reconstruct it from other formatting characters.

In other words, whereas in Perl and C-like languages you would 1) edit the braces so that they're correct and then 2) automatically reconstruct the indentation to match the braces, in Python you simply 1) edit the indentation so that it's correct.

Re:The Fall Of Perl, The Web's Most Promising Language by collyw on Tuesday February 25, 2014 @02:20AM (#7296158)
Yes, you have to think a bit more when reformatting Python, but it is worth it as you never get the missing brace problem that you can get when moving Perl blocks around. Its enough of a benefit for me.
Re:The Fall Of Perl, The Web's Most Promising Language by pronik on Friday March 07, 2014 @03:10PM (#7362450)
The point is: I don't have to think at all. Reformatting code with Perl is a matter of a save hook in the editor or a pre-commit hook in your VCS. No thinking necessary, it just works.
Re:The Fall Of Perl, The Web's Most Promising Language by chromatic on Monday February 24, 2014 @02:04AM (#7289490)
When you copy-paste Perl (or C, or Java, etc) code, do you not reformat that code anyways?

Sure, but you don't have to worry about reformatting making code that was correct suddenly and subtly incorrect.

Re:The Fall Of Perl, The Web's Most Promising Language by pyre on Monday February 24, 2014 @02:15AM (#7289512)
When I use C, I don't have to worry about subtle type errors cropping up at runtime. Should we all ditch dynamic-typing for Haskell?
Re:The Fall Of Perl, The Web's Most Promising Language by chromatic on Monday February 24, 2014 @02:24AM (#7289534)
I don't understand this analogy, unless either C or Haskell allows invisible characters copied and pasted incorrectly to cause semantic errors. (I've used both Haskell and C for non-trivial purposes and can never recall that to be the case.)
Re:The Fall Of Perl, The Web's Most Promising Language by pyre on Monday February 24, 2014 @03:48AM (#7289749)
> reformatting making code that was correct suddenly and subtly incorrect

and

> invisible characters copied and pasted incorrectly to cause semantic errors

are two different issues. Reformatting doesn't insert (unexpected) invisible characters[1].

As to copy-pasting, this issue already exists in other forms with other languages. How long would it take most people to find the error here:

  my $variable = “(#`д´)ノ”;

[1] I guess I should specify "if you are using a decent editor".
Re:The Fall Of Perl, The Web's Most Promising Language by Mithaldu on Monday February 24, 2014 @07:24AM (#7290391)
Perl points that out very nicely:

    C:\Users\Mithaldu>perl -e "  my $variable = “(#`д´)ノ”;"
    Unrecognized character \x93; marked by <-- HERE after ariable = <-- HERE near column 18 at -e line 1.
Re:The Fall Of Perl, The Web's Most Promising Language by pyre on Monday February 24, 2014 @11:07AM (#7291508)
That may be, but this thread seems to be "Python is a language with serious deficiencies because whitespace!" If that's the case, then people are pitting Python up against all other languages, not just Perl.

That being said, even with the helpful Perl error message, the less experienced developers may have issues trying to determine why Perl doesn't like their double-quote before they figure out what the real issue is.

I guess I should be clear, that I'm not hating on Perl. It's more that I see the "OMG! Semantic whitespace in Python!" argument as a bit of a red herring if that's your only reason for not using the language.

Re:The Fall Of Perl, The Web's Most Promising Language by collyw on Tuesday February 25, 2014 @02:14AM (#7296144)
Perl to Python convert here. At first I hated the whitespace, but when I went back to Perl, I moved some code about and "lost" a brace. You never get the unmatched brace problem in Python.
Re:The Fall Of Perl, The Web's Most Promising Language by thetrb on Saturday March 01, 2014 @07:06PM (#7326893)
Getting that message is not a bad thing as it tells you there's a problem as opposed to just silently doing something you didn't want it to do.
Re:The Fall Of Perl, The Web's Most Promising Language by collyw on Monday March 03, 2014 @09:20AM (#7333801)
Yes, but its just as likely you pasted in the wrong place. Python makes you a little more disciplined when cut-pasting bits of code around.
Re:The Fall Of Perl, The Web's Most Promising Language by mixmastamyk on Monday February 24, 2014 @03:23PM (#7293206)
> significant-white-space

In my experience it's been a problem about five times in the last 10-15 years, but the conciseness pays dividends every single day.