431 points · by codetrotter · 5y ago · 163 comments
I once wrote an entire CMS in Perl.
I still wake up, screaming, sometimes.
[UPDATE] It appears as if my flippant remark caused upset. I am sincerely sorry that this was the case. No offense was meant.
@peteretep, you have my sincere apology. It was a flippant remark. At the time I wrote it (mid-1990s), Perl was the best way to write portable server-side code. I took the time to learn it, and got fairly good at it. Since then, I have found my muse in other languages, but I sincerely did not want to give offense. I doubt that deleting the comment would help.
I rewrote it in a couple of hours in 393 lines of perl and 6 OS installed (so stable for the life of the OS) libraries.
Master Foo once said to a visiting programmer: “There is more Unix-nature in one line of [Perl] script than there is in ten thousand lines of C.”
The programmer, who was very proud of his mastery of C, said: “How can this be? C is the language in which the very kernel of Unix is implemented!”
Master Foo replied: “That is so. Nevertheless, there is more Unix-nature in one line of [Perl] script than there is in ten thousand lines of C.”
The programmer grew distressed. “But through the C language we experience the enlightenment of the Patriarch Ritchie! We become as one with the operating system and the machine, reaping matchless performance!”
Master Foo replied: “All that you say is true. But there is still more Unix-nature in one line of [Perl] script than there is in ten thousand lines of C.”
The programmer scoffed at Master Foo and rose to depart. But Master Foo nodded to his student Nubi, who wrote a line of [Perl] script on a nearby whiteboard, and said: “Master programmer, consider this [Perl one-liner]. Implemented in pure C, would it not span ten thousand lines?”
The programmer muttered through his beard, contemplating what Nubi had written. Finally he agreed that it was so.
“And how many hours would you require to implement and debug that C program?” asked Nubi.
“Many,” admitted the visiting programmer. “But only a fool would spend the time to do that when so many more worthy tasks await him.”
“And who better understands the Unix-nature?” Master Foo asked. “Is it he who writes the ten thousand lines, or he who, perceiving the emptiness of the task, gains merit by not coding?”
Upon hearing this, the programmer was enlightened.
Adapted from: http://www.catb.org/~esr/writings/unix-koans/ten-thousand.ht...
>Now you should be very careful that the outer bracket type is a round one, that is, a parenthesis. That's because you're assigning to an @array, so you need parentheses. If you wanted there not to be an @AoA, but rather just a reference to it, you could do something more like...
Still pretty tricky!
EDIT: verb tense changed
This is rarely ever the intention, and I'm 100% certain wasn't the intention of the poster here.
The tools you use shouldn't be your identity. Chill.
He’s basically ribbing GP by purposefully misinterpreting the comment, so that what gave GP nightmares was his CMS rather than Perl itself.
Which all goes to show people clot up into tribes over any silly thing; and that its better not to wrap your identity too much around your tools.
After reading Programming Perl from cover-to-cover, I suddenly felt like I had superpowers. I probably would have felt the same if I'd taken the time to learn bash scripting, but that's not how it worked out.
I tried to automate everything in my life with Perl. I'd walk to class in the morning and a script had already scraped and downloaded my lecture materials and sent a print job for me. It emailed me if it couldn't find notes for one of my scheduled classes. Others would manage my assignment submissions. I wrote scrapers to detect what events on campus might offer free food.
This was the first time I felt like I could write programs that actually had the power to improve my life. It changed my perspective on what I had the power to do as a programmer. I'll always be grateful to Perl for that.
I also learned how to quickly develop a thick programmer skin by asking questions on comp.lang.perl, but that's another topic altogether.
I missed the Perl boat by a few years, riding the Python2/Java wave at Uni instead, but I did encounter it a few times in legacy (read: 5-years old) code and could only marvel at its string manipulation capabilities.
I like to think of it as the extended bash that I never took the time to learn
Is there something about gaining scripting power that requires such poor usability? I resisted it for a while, but I just write all my workaday scripts in Python now, and I'm honestly a little baffled as to why I stuck with bash for so long.
It is possible to write lucid, maintainable Perl, something I have occasionally managed. It is easy to write ugly, unmaintainable Perl, and that I have too often done. If one looks at the Perl found on CPAN or in various good books on Perl, you can see how to do the former.
Some of them are not even paint:
https://www.mcmillen.dev/sigbovik/splatters/646f93a2d62ad819...
(You would of course want a “proper” scientific study to be more rigorous about these things.)
Edit: Also, the programs in the article appear to be mostly special characters?
But if someone said "95% of paint splatters OCR as Welsh words" and it turned out that's because the OCR is looking for words, it doesn't say much interesting about Welsh like the title implies.
> Edit: Also, the programs in the article appear to be mostly special characters?
Look at the whole gallery though. Most of the OCR results are just a string of letters or a number. Those being valid is very mundane.
Edit: Actually if you want to make the analogy super precise, you could say "oh yeah those strings of letters are just proper nouns, which makes them valid Welsh, and of course numbers are valid Welsh"
I think it depends on the claim, right? IMO, a more analogous statement might be "95% of paint splatters OCR as grammatically-correct Welsh sentences." Unless the software is using something like GPT-3, that finding would be notable regardless of software tuning. Even if it tells us more about Welsh grammar than it does paint splatters.
> Look at the whole gallery though. Most of the OCR results are just a string of letters or a number. Those being valid is very mundane.
Yes, thanks, my mistake!
I assume you mean the 4 listed in the "Errata" section?
The full list is here: https://www.mcmillen.dev/sigbovik/splatters.html
combined with -T, it's given me a lot of peace of mind, which I miss when using PHP.
I'm seriously contemplating writing my own SetConst and GetConst functions. (Lately I've been finding a lot of sense in immutable variables.)
use const name => value;
Though ... I'm not sure why you'd need a "set" constant, as constants should be immutable, and set once ... use constant name => value;
Albeit `Const::Fast` might be considered preferable for several reasons (deeply readonly structures, variables which you can interpolate rather than barewords, etc).Are consts not allowed to be set at runtime?
Try Hack? It's not too bad and the typing can be added piecemeal.
Nobody is going to bother with your language when it's full out there of solutions as good as yours that people can install in one second.
I suspect this dates back to the Perl4 -> Perl5 transition, when they removed the requirement to call a subroutine using an ampersand, like &somesub could just be somesub.
Unlike, say Python, Perl doesn't require subroutines to be defined before they are called.
For reasons I don't fully understand, barewords preceded by '-' are still allowed, even with "use strict". Also allowed as hash keys like $foo{bar}=1 or (foo => "bar").
This - the fact, rather than any justification - is documented in `perldoc perlop`:
Unary "-" performs arithmetic negation if the operand is numeric, including any string that looks like a number. If the operand is an identifier, a string consisting of a minus sign concatenated with the identifier is returned. Otherwise, if the string starts with a plus or minus, a string starting with the opposite sign is returned. One effect of these rules is that -bareword is equivalent to the string "-bareword".
Typically Perlish, that means you can do stuff like the following because, I dunno, reasons?
$ perl -E ' use strict; use warnings; say - -foo' # or -(-foo)
+foo
> Also allowed as hash keys like $foo{bar}=1 or (foo => "bar").Quoting `perldoc perlop` again:
The "=>" operator (sometimes pronounced "fat comma") is a synonym for the comma except that it causes a word on its left to be interpreted as a string if it begins with a letter or underscore and is composed only of letters, digits and underscores. This includes operands that might otherwise be interpreted as operators, constants, single number v-strings or function calls. If in doubt about this behavior, the left operand can be quoted explicitly.
I believe the primary motivation for this is so you can pass argument lists to subs in a key => value format without having to quote the key. For example:
someSub( -opt1 => $opt1val, -opt2 => $opt2val );
[edited for formatting, which I never seem to get right the first time]> The "=>" operator (sometimes pronounced "fat comma") is a synonym for the comma except that it causes a word on its left to be interpreted as a string if it begins with a letter or underscore and is composed only of letters, digits and underscores. This includes operands that might otherwise be interpreted as operators, constants, single number v-strings or function calls. If in doubt about this behavior, the left operand can be quoted explicitly.
> Otherwise, the "=>" operator behaves exactly as the comma operator or list argument separator, according to context.
If that's what all the kids are doing then it seems that's what a kids activity has become.
I used to play with neighborhood kids quite a bit when I was younger. Now my nephew plays Fortnite almost every day with 5ish different friends. He gets way more experience socializing than I ever did.
Ultimately (I think) kids need to learn to socialize with their peers. That means they need to participate with their peers doing what their peers are doing.
Poeple in general are extremely bad at generalizing situations to match their own experiences. People get old, see younger people playing differently (new toy, new technology, new societal framework), and fail to notice that the new kind of play is still mostly the same module/class of play they had, just with a different coat of paint.
E.G. In the 80s' we used to play with k7 recorders, recording singing, pretend news casts and comedy shows. Now kids are doing youtube and tiktok, and that is exactly the same module of play, it is not some brand new thing.
Having said that, I'd like to point out that, although for the kid it is basically the same kind of play, the fact that is more public (k7 had a limited reach, just neighborhood friends, but the internet has unlimited reach) means bigger stakes, so parents should be more vigilant, it is even more crucial now that parents get involved in the kids activities to keep an eye out.
Ubiquitous socialising can be good but it cuts both ways, especially in an environment where you have no plausible deniability. In my opinion, people should be free to have their own thoughts, potentially get blasted for them, and move on with their lives the next day with minimal consequences. Certainly there should be no consequences coming from people that were not actually there, but just heard about it from some social media platform.
Granted if a kid were to just upload fun videos... have comments off ... not interact with the community, then maybe they'd be ok? But I think all of that is not super likely as my son's friends want to be youtube stars.
When I was 10 or so, I uploaded some dumb little skits with my friends to YouTube. The videos accumulated about 2k views total, and are all gone now, and no one will ever recognize me from them.
I think the problem is that the original tweet seems to think that "coding" is only a vocational skill, and it's definitely not. When you're that age, coding is just another form of expression and exploration. It can make something useful, but it's just puzzles and fingerpaint.
Anyways, I agree. It's another form of expression. Just like Math or Music.
But I do also agree, in part with her point, that kids should explore possibilities and be kids instead of having to worry about their vocation so young and being put on a track to become something.
"That lady" is Adrienne Porter Felt, who started as an engineer working on Google Chrome security a decade or so ago, and is now a Director of Engineering who manages a sizable chunk of the Chrome team.
I never worked with her directly, but she has a reputation as a good manager and I'm pretty sure she knows how programmers work.
Yeah that's a really tough line to track. At some point they're going to develop a sense of purpose and I have no idea when or where or what or how I can nurture it.
ANXIETY
Programming is great for self expression, exploring new ideas, amusing people. These are great goals for kids.
If you teach a kid to program, probably they're gonna put it to use in Minecraft or Roblox, not by writing accounting software. That's good! That's no more professional software development than kids building with Legos are doing engineering.
For us, it started at me - I had to make some big changes. When she was very little, I caught myself pushing her on a swing with my nose in my phone. Once I caught myself doing that, I broke the habit - now when we’re spending quality time together, my phone doesn’t exist.
This gives us space to do things outside, go on adventures and use our imaginations.
Devices are a huge part of her world so at other times, we either share one device and I let her quarterback or we spend an hour in bed on our own devices. I’m open about what I do on my device and she’s open about what she does on hers. In some cases, this creates an opportunity for me to teach and model. In other cases, it gives her an opportunity to teach me.
The last part has been especially important. As my girl has taught me things about her world, I’ve learned that some of my ideas about kids being kids are based on my own prejudice. I’ve caught myself expressing an overly rosy view of ‘when I was a kid’ and have tried to project that world upon her. Thankfully, my kid and I have the kind of relationship where she’s more than comfortable to tell me that I’m wrong.
I saw someone mention summer camp, some kind of structured mechanism to do it would help a lot i think.
Oldest one is 6 now, so not sure what that will be like going into their teen years. I feel like that's when it will be harder to get them offline but we will see
93% of Paint Splatters Are Valid Perl Programs - https://news.ycombinator.com/item?id=19576425 - April 2019 (132 comments)
93% of Paint Splatters Are Valid Perl Programs - https://news.ycombinator.com/item?id=20834351 - Aug 2019 (7 comments)
Also this, recently:
The four noisy horsemen of Perl hate - https://news.ycombinator.com/item?id=27902296 - July 2021 (51 comments)
But any language that detects random string as a valid program is under suspicion of allowing more bugs than valid programs.
It may be easier to write in a language that isn't as strict, but it's going to take more effort to produce a *correct* result.
By the way, the first Raku Conference is happening in a few weeks, Aug. 6–8 https://conf.raku.org
on edit: actually how many country fences are valid brainfuck.
Spoken like someone possessing the supreme programmer's virtue of laziness.
i.e. a fun April 1st paper.
What I liked about Perl when I started using it was dictionaries, lists, regexes and CPAN. Coming from a statically typed language like C or Pascal it was freedom. Writing modules was weird, objects weird - so that meant messy code. And when they did implement something, it was always a sophisticated flavor of some rarely used programming concepts.