4 ms·
With regard to strings, they give a good example in Lua, but oh boy wait until this person hears about Perl (: There's a whole section in the manual [1] for st
by turtledragonfly 4y ago
With regard to strings, they give a good example in Lua, but oh boy wait until this person hears about Perl (:
There's a whole section in the manual [1] for string quoting operators (qq, qw, qx, ...)
In general, I feel like Perl is one of those languages that has a high amount of these "quality of life" syntactic features, and helps make it enjoyable to write, once you get over the learning curve.
[1] https://perldoc.perl.org/perlop#Quote-Like-Operators https://perldoc.perl.org/perlop#Quote-Like-Operators
- mncharity 4y agoRaku (once Perl6) generalizes quoting as a Q , followed by optional "how should this behave" adverbs, and text bracketed by anyish unicode bracket pair. So Q:w <foo bar> is a list of two words. And has Perl-like qw/foo bar/ as sugar. Heredocs are Q:to/THEEND/ ... \nTHEEND . I'm unclear on whether you extend this without defining your own Q-like thing? Julia allows[2] defining your own non-standard string literals. foo"bar"hee and qux`...` desugar as macro calls foo_str("bar","hee") and bar_cmd("..."). But lack the bracket flexibility. http://rigaux.org/language-study/syntax-across-languages.html#Strng http://rigaux.org/language-study/syntax-across-languages.htm... briefly sketches other languages. [1] https://docs.raku.org/language/quoting https://docs.raku.org/language/quoting [2] https://docs.julialang.org/en/v1/manual/metaprogramming/#meta-non-standard-string-literals https://docs.julialang.org/en/v1/manual/metaprogramming/#met...
- dariusj18 4y agoThat's actually a great point. Perl has so many syntactic sugars that it is a poster child for too much variety in ways you can write things. Making it much harder to read someone else's code.
- masklinn 4y agoPerl has so much syntactic sugar it's the poster child for syntactic diabetes, really.
- jodrellblank 4y ago"Syntactic sugar causes cancer of the semicolon." ― Alan J. Perlis
- turtledragonfly 4y agoYeah, it's a trade-off that's not discussed enough, IMO. Most general programming advice is directed at "programming in the large", involving many people, over a longer period of time, and the maintainability issues that go with that. But you give up something to get benefits in those areas. Making use of the expressive power of something like Perl is a wonderful sensation. The barriers between thought and making it happen are lower, and so you can be remarkably productive. It is also just more fun, I find, which has subtle and under-valued long-term benefits. But yeah, agreed that comprehending someone else's Perl-fueled vision quest can be ... rough (:
- hbrn 4y agoqw was great. Even in Python I sometimes write: usernames = ''' foo bar baz hello world '''.split() # instead of this, which needs too many keystrokes usernames = ["foo", "bar", "baz", "hello", "world"] Interestingly, Python named tuples have similar interface for fields: # all of these are equivalent EmployeeRecord = namedtuple('EmployeeRecord', ['name', 'age', 'title']) EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title') EmployeeRecord = namedtuple('EmployeeRecord', 'name age title')
- culi 4y agoRuby was inspired by Perl and also has this. Pretty great
- ilyt 4y agoIt does! Till you hit the code of someone that didn't really care about readability that much and you're in for ugly mess.