3 ms·
I think you should revisit perl. My first job writing perl was in 2005 or 2006, and it was not a good language for an eager idiot without guidance. After a co
by SuspiciousSwan 6y ago
I think you should revisit perl.
My first job writing perl was in 2005 or 2006, and it was not a good language for an eager idiot without guidance. After a couple years, I started getting it, and it became one of my favorite languages.
I think it was my coworker who told me to read https://hop.perl.plover.com/ https://hop.perl.plover.com/ and it blew my mind and made me start to rethink how I was approaching code. With the languages that I'd been using previously, the game was to fit the problem into what the language wanted you to do. HOP would likely be boring to you now, and wouldn't do much for me, but at the time, it showed me that perl was a language in which the same problem could be solved in multiple different ways, and both be just as right as the other.
Fetishizing that freedom, just like anything else, leads to self indulgent trash. I've seen it in every language, but perl allows for so much freedom it is easy to misuse.
It clicked with me that the best perl code was code that did what I intuitively thought it should do when I used it, and did what I thought it would do when I looked at it. Perl, compared to every other language that I've used, gave me tools to accomplish that.
Perl's object system is Python's, just in its raw parts. I still miss aspects of Moose that are impossible or ugly to use in other languages. Regexps are easy to misuse, but grammars allowed me to cleanly express what something did better than I've been able to in any other language. Mixing in functional ideas, where appropriate, made my code easier to reason about, instead of the debugging hell that I've seen it add to languages like Java. When I learned the concepts from perl, I learned when to use them in other languages.
I don't use perl much anymore, and I don't think I would push it on a team, and I really don't think that it is a good language for beginning programmers, unless there are good mentors around. Most of the beautiful code that I've ever written has been in perl.
- alexchantavy 6y agoDo you have a good link to learn about grammars in perl?
- lizmat 6y agoPerl does not have grammars (at least, not built-in). Raku (formerly known as Perl 6) does: https://docs.raku.org/language/grammar_tutorial https://docs.raku.org/language/grammar_tutorial
- blindluke 6y ago> Perl does not have grammars (at least, not built-in). That's not true since v5.10 (2007). Here's a sample that matches a subset of LaTeX markup: $matcher = qr{ (?&File) (?(DEFINE) (?<File> (?&Element)* ) (?<Element> \s* (?&Command) | \s* (?&Literal) ) (?<Command> \\ \s* (?&Literal) \s* (?&Options)? \s* (?&Args)? ) (?<Options> \[ \s* (?:(?&Option) (?:\s*,\s* (?&Option) )*)? \s* \]) (?<Args> \{ \s* (?&Element)* \s* \} ) (?<Option> \s* [^][\$&%#_{}~^\s,]+ ) (?<Literal> \s* [^][\$&%#_{}~^\s]+ ) ) }xms It's nowhere near as advanced as Raku grammars (not much is), but it's there, and it's built-in.
- SuspiciousSwan 6y agoStart https://perldoc.perl.org/perlre.html#Extended-Patterns https://perldoc.perl.org/perlre.html#Extended-Patterns . I was trying to find an article from many years ago, but either my google skills fail me, or it is dead. Perl's regular expressions haven't been regular expressions for a long time. Beyond that, the ergonomics of perl make them much more useful for things like flow control than in other languages. It's similar to how you can do type matching in Java, but it's ugly, versus a language like Haskell where using type matching simplifies the code. Perl 6 (as lizmat pointed out), has more powerful rules. I don't know a ton about them.
- jes5199 6y agoit looks to me like HOP is mostly teaching traditional LISP concepts. I could write those same functions in Javascript, and they'd be more readable
- snapdangle 6y agoWith which JavaScript version? At the time HOP was written I remember JavaScript still doing all it's for loops in C-style and there was certainly no arrow syntax to make anonymous JS functions manageable. There were also no functional methods available, as related by the restriction to C-style for loops. (Array Iteration methods didn't appear in the spec until 2009, so I don't see how you could have map or select or anything else functional).