6 ms·
I am trying really hard to approach Perl 6 with an open mind, but my gut reaction to most of the code I see is negative. It seems like the guiding principle wa
by CuriouslyC 11y ago
I am trying really hard to approach Perl 6 with an open mind, but my gut reaction to most of the code I see is negative.
It seems like the guiding principle was to create a language that gives you incredible freedom in terms of how you do things. While that is great in theory, in practice mentally modelling that expressiveness reduces the amount of attention I can devote to the specific problems being addressed by the code. Maybe if I put a lot of time in that would change; I don't see a big potential payout though, so I'm not going to bother.
With that being said, grammars look well designed. If all I was doing was parsing/transforming text, I would definitely consider using Perl 6.
- bane 11y agoIt turns out lots of things make sense to parse using grammar like constructs: various binary formats, JSON, CSV, etc. I have a feeling that community writing decent parsers for once will make perl's parsing ability across the board pretty amazing and less fussy than just about anywhere else.
- ktRolster 11y agoPerl has always been really good at parsing, it's one if its strengths. In fact, you can usually distinguish people who like perl from those who don't based on whether they understand regular expressions or not. Another thing I like about perl is a lot of the standard library functions take an array of inputs, or a single value; and return an array or a single value.
- carlivar 11y agoNot sure about that, Ruby took the good parts of Perl regex parsing, such as the conditional format: var =~ /regex(match)/ With $1 and so on for each match.
- adrusi 11y agoRegular expressions are improved in perl 6, using a syntax that allows better readability through whitespace and comments (previously the x modifier) and new features that make the regular expressions more like PEG grammars.
- groovy2shoes 11y agoPerl has always been really good at enabling cargo-cult parsing -- the vast majority of "parsers" I've seen in Perl 5 have been ad-hoc, buggy, slow, and informally-specified. The nice thing about grammars as a language construct is that you get formal specification for free; this aids in understanding the parser. When it comes to parsing, grammars really are the right way to go, either as a built-in or as a library (Elisp, for example, has a few parsing libraries available in MELPA, and there's always good ol' LPeg for Lua). When all you have are regeces, there's a tendency to model a parser as a finite automaton where transitions are labeled with regex matches, but given how frequently programmers deal with extracting information from text, I think there's a solid argument for grammars or parser combinators being readily available in a language. Really, any text processing task more sophisticated than grep calls for tools more sophisticated than regular expressions.
- smacktoward 11y ago> It seems like the guiding principle was to create a language that gives you incredible freedom in terms of how you do things. While that is great in theory, in practice mentally modelling that expressiveness reduces the amount of attention I can devote to the specific problems being addressed by the code. In defense of Perl 6, you could say more or less the same thing about Perl 5 and every Perl that came before it. Perl has always been optimized for cleverness, in the sense that it's much more interested in making it easier for people to write code than it is in making it easier for anyone (even the person who wrote it) to read it.
- Roboprog 11y agoI used to really like Perl, but endless operator-obfuscation nonsense a la C++, Perl 6, Scala REALLY makes me appreciate Lisp (should I ever get to use it again outside of 80s college work). Every function has a plain old name, no magic symbol operators, inner parens evaluate first. No bullshit.
- ktRolster 11y agoIt's kind of amazing to me, after learning all kinds of abstractions and syntaxes, how much I just come back to the function to organize my code. And over and over, that seems like the most flexible and powerful way to do that.
- Roboprog 11y agoThat does work really well for me in my Javascript code. Java is getting increasingly painful to look at (even without operator overloading), and most of our work is still Java (due to the need to write so much of it???)
- mjn 11y agoI go back and forth on that. I like both Perl 5 and Common Lisp, and am investigating Perl 6 now. Perl has more operator magic, but it also makes many things a lot less tedious to write, and for common tasks I quickly figure out a nice way of doing things. Common Lisp is more uniform but somewhat clunky and verbose for a lot of common things. And when it's not, it's because you created a nice little DSL using macros (maybe even read macros), which then starts looking more like Perl-style magic (except done with metaprogramming, not built in). As far as heritage, I think Perl's love of magic and concise operators is influenced more by the awk/sed/sh trio that it originally borrowed a lot of its syntax from, rather than by C++.
- deleted 11y ago[deleted]
- zvrba 11y ago> endless operator-obfuscation nonsense a la C++ C++? Ever looked at some "advanced" Haskell code?
- tracker1 11y agoI always appreciated the expressiveness of perl, and ruby for that matter... however, reading perl you've written a while ago, of even after not writing any for some while is a lot of mental hurdle...
- jandrese 11y agoI hear this a lot, but I have gone back to plenty of my old scripts and have no trouble parsing them. This is something I worried about several years ago when writing some fairly hairy code, but it really has not panned out. I do have trouble reading other people's code sometimes, but that's true in any language. It's easy to get thrown for a loop when someone uses a language feature that you've never seen before.
- zoffix222 11y agoInteresting observation. In practice, I found coding in Perl 6 is much faster than in Perl 5, for example. One of the programs I converted was half as short. On the contrary, it's expressiveness let's me focus on the problem instead of trying to figure out whether my large loop of code is in order. English is an expressive language as well, but I don't become paralyzed writing this comment.
- CuriouslyC 11y agoI do agree that abstractions that reduce the amount of code you have to write can allow you to devote more brainpower to the code at hand. I would argue that global abstractions are generally inferior to local abstractions for this purpose though. If you make the language locally more complex (via defining terms i.e. functions) you can leave that complexity behind when you don't need it. If your language grammar is naturally complex you have to deal with that all the time. As for English... Writer's block and futile rewriting cycles are real issues that basically every writer grapples with. On the other hand, coder's block isn't really a thing, and refactoring occurs infrequently compared to writing.
- usrusr 11y agoWell, it would not really be Perl if it allowed reason to take precedence over the inclusion of yet another confusing feature, right? And I don't mean that in a negative sense, unbounded expressivity already is the central reason to use Perl and any changes to the language should respect that.