But yea, Python won.
But yea, Python won.
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?
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.
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.
(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)
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.
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.
Sure, but you don't have to worry about 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". C:\Users\Mithaldu>perl -e " my $variable = “(#`д´)ノ”;"
Unrecognized character \x93; marked by <-- HERE after ariable = <-- HERE near column 18 at -e line 1.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.
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.
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.
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.