12 ms·
93% of Paint Splatters Are Valid Perl Programs (2019)
- qalmakka 5y agoSometimes I forget how insane Perl was before `use strict;` became commonplace.
- forgotmypw17 5y agouse strict; has basically eliminated typos or variable-related errors for me. 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.)
- hpcjoe 5y agoFor Perl use const name => value; Though ... I'm not sure why you'd need a "set" constant, as constants should be immutable, and set once ...
- forgotmypw17 5y agoWell, perhaps I should've said SetImmutableVariable? Are consts not allowed to be set at runtime?
- throwanem 5y agoIt sounds like the confusion might be in declaration vs. initialization, which for language-supported consts of course have to happen at the same time. Retrofitting the concept into a language without native support for immutable bindings, you'd of course need some kind of setter on whatever object or similar you're using to encapsulate the binding and ensure it never does actually change.
- forgotmypw17 5y agoI'm combining my lament about lack of "you are using a variable you didn't declare yet" error in PHP and my newly arrived at understanding of the benefits of immutable variables, and then adding to the confusion by using the "constant/const" term, which typically means "set at compile time"
- throwanem 5y agoIn languages with a compilation step, this is true but a side effect. Really, what "const" denotes is an association between a name and a value (ie a binding, in this case an assignment, although there are other kinds of binding such as naming positional arguments in a function signature) which has to be performed when the name is declared, and which cannot be changed once made. (Hence for example in Javascript why properties of an unsealed object can still be modified even via a const binding - what's immutable isn't the value, but the association of that value with the const-declared name.)
- darrenf 5y agoNitpick: 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).
- hpcjoe 5y agoAgreed. I tend to use syntactic sugar like use constant true => (1==1); use constant false=> (1==0); in many of my codes. It lets me use them as barewords, and makes the logic it appears in, saner. But this is a style/taste thing.
- benlivengood 5y ago> combined with -T, it's given me a lot of peace of mind, which I miss when using PHP. Try Hack? It's not too bad and the typing can be added piecemeal.
- qalmakka 5y agoThe main issue I have with Hack is that it is a big PITA to install. Like, there's no HHVM in ArchLinux repositories (or in no other distro's repositories either), and building it is super messy. That's also why I think almost nobody is using Swift on Linux. 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.
- jschwartzi 5y agouse English; is handy for making the special global variables something you can actually google search.
- bmn__ 5y agoGoogle improved their negligence in 2019. https://encrypted.google.com/search?q=%24_ https://encrypted.google.com/search?q=%24_
- athenot 5y agoPosted 2019-04-01 i.e. a fun April 1st paper.
- nemetroid 5y agoThe paper was accepted into SIGBOVIK, which always runs on April 1st.
- krylon 5y agoSo... next we should try feeding random traffic noise through voice recognition and see what Perl makes of that? (SCNR)
- tsegratis 5y agoAlexia is this in reverse
- ChrisMarshallNY 5y agoThat's a fun read. 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.
- peteretep 5y agoI’m sorry the code you produced made you so unhappy EDIT: verb tense changed
- ChrisMarshallNY 5y agoAny particular reason for the insult? I don't recall saying anything bad to you.
- danielheath 5y agoJust a wild guess, but perhaps they read your hyperbole literally?
- ChrisMarshallNY 5y agoI doubt it. I looked them up (because I care about people, and don't actually want to hurt them), and it seems that Perl is a big part of their repertoire. Perl means a lot to them, and my flippant comment was probably taken as "calling their baby ugly." So, @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 CGI 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.
- 5y ago
- lucideer 5y agoThis is obviously just a bit of fun, but looking at the output examples, I think the OCR used may be flawed in that it's heavily optimised to produce characters used in natural language (alpha & spaces) rather than to produce e.g. operators common in code. The number of "special characters" output is extremely small. This will bias it heavily toward producing identifiers, which will be valid in most common programming languages.
- thomasahle 5y agoThe examples at the bottom of the page are mostly special characters, like the valid program `;i;c;;#\\?z{;?;;fn':.;, `
- hcrisp 5y agoReminds me of the joke: "Perl is the only programming language which looks the same before and after encryption."
- gpderetta 5y agoplease, perl ha nothing on q
- maximus-decimus 5y agoq reads like prose compared to J.
- Wowfunhappy 5y agoI don’t think that’s a flaw! The study is “95% of paint splatters” not “95% of random strings of ASCII characters”. If common OCR programs are optimized to produce letters and spaces, fair game! (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?
- 5y ago
- codesections 5y agoI wonder what the equivalent result would be for Raku (aka, the language formerly known as Perl 6). By the way, the first Raku Conference is happening in a few weeks, Aug. 6–8 https://conf.raku.org https://conf.raku.org
- qalmakka 5y agoGiven that Raku's design originally stems from the "strict" subset of Perl 5, this would never work. This only works when Perl runs in non-strict pre-5 mode (which is the default before 7.0).
- codesections 5y agoYeah, I bet you're right. My first thought was that all the different ways Raku has of letting you start entering a string literal might make up for that but, on second thought, those all need to have a corresponding closing pair so that wouldn't really help.
- granshaw 5y agoCan we talk about the original tweet some? How DO we let kids be kids in this age where all the other kids wanna do is be on YouTube and TikTok?
- OGWhales 5y agoI don't have kids myself but my I have nieces and nephews. They all play outside and do normal kid stuff. They get a little bit of screen time but their parents limit it. 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
- jugg1es 5y agoSummer camp has worked really well for us this year. The 6 y/o comes home absolutely filthy with knowledge of ground bees.
- jedimastert 5y agoI have kids of my own, and I think it's absolutely possible to do both. My daughter is 4 now, and loves to splash in mud and do all of that stuff. At the same time, she loves doing puzzles and art, which is still normal kid stuff. 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.
- racl101 5y agoThat lady probably thinks programmers are the way they're depicted in Dilbert lol. 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.
- jedimastert 5y ago
- leoc 5y agoThis is another problem which was already solved in the '70s on the PDP-10. https://en.wikipedia.org/wiki/TECO_(text_editor)#As_a_programming_language https://en.wikipedia.org/wiki/TECO_(text_editor)#As_a_progra... ;) So you're keen on making invalid states unrepresentable ? Boy do I have the technology for you.
- skydhash 5y agoI once had to learn Perl to implement an algorithm for a proof of concept. It was weird as I was only used to C like programming (and a little bit of assembly)
- w0m 5y agoI love (writing) Perl.
- biztos 5y agoAs a Perl programmer and painter I must point out that the programs show in this article are not smeared, and not on a wall. Nor on a Wall. Some of them are not even paint: https://www.mcmillen.dev/sigbovik/splatters/646f93a2d62ad81932f2971a0d50e03e.jpg https://www.mcmillen.dev/sigbovik/splatters/646f93a2d62ad819...
- ablu 5y agoThe "future work" section of the paper covers the smearing part! The authors acknowledge that it is unknown whether the results translate to smeared paint.
- tvirosi 5y agoI feel bad about upvoting this given that I kind of agree with the tweet that this sort of responds in an inappropriate tone to (if you resonated with the message).
- TchoBeer 5y agoIs programming a purely vocational skill to you? Do you not find it fun? Exciting? Interesting?
- belval 5y agoIn a way aren't all vocational skills possibly fun, exciting and interesting? I don't really like the idea that there are "bad things" to teach. I can have fun cooking, woodworking, plumbing and even filling my taxes.
- TchoBeer 5y agoThat's an excellent point. Maybe the point where it stops being "a fun thing to teach to kids" and becomes "teaching them a job" is when you force them to learn it even when they aren't having fun and don't want to because you think it will help them with a career.
- noisy_boy 5y agoRecently I had to do some simple flat file parsing and aggregation - for some reason, I picked up Perl for a it and it was as easy and performant as ever. It just felt natural and got the job done in a few lines of code. For all the hate Perl gets, I think for specific tasks like these, it is pretty much only rivalled by Python (and compared to Perl even with strict on/avoiding magic variables etc, Python still feels verbose).
- alleged 5y agoPerl is excellent for string parsing/text manipulation (makes sense as that was its original design goal). I agree on Python; "the Pythonic way" of doing things seems to result in lots of useless boilerplate.
- bryanrasmussen 5y agoWell that's nice, but what percentage of paint splatters are valid APL? on edit: actually how many country fences are valid brainfuck.
- blackhaz 5y agoWe should run a random number generator connected to a Perl script driving a small tentacle, set a fit function of Global Peace in the Universe, and let machine do the rest.
- bryanrasmussen 5y ago>and let machine do the rest. Spoken like someone possessing the supreme programmer's virtue of laziness.
- dang 5y agoDiscussed at the time: 93% of Paint Splatters Are Valid Perl Programs - https://news.ycombinator.com/item?id=19576425 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 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 https://news.ycombinator.com/item?id=27902296 - July 2021 (51 comments)
- self_buddliea 5y agoToday I learned Jackson Pollock was a perl programmer.
- tyingq 5y agoMost of this appears to be Perl's tolerance for "barewords" if you don't "use strict;". 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").
- nocman 5y ago> For reasons I don't fully understand, barewords preceded by '-' are still allowed, even with "use strict". 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]
- gnubison 5y agoYou don't have to quote the LHS of the => operator, even if "use strict" is on. (That's the only way that it differs from a regular comma.) > 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.
- darrenf 5y ago> For reasons I don't fully understand, barewords preceded by '-' are still allowed, even with "use strict". 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.
- miga 5y agoThis says more about OCR than Perl... But any language that detects random string as a valid program is under suspicion of allowing more bugs than valid programs.
- LorenPechtel 5y agoThis. The stricter the compiler the more likely a mistake will be trivially caught by the compiler rather than be a bug that has to be hunted down in the output. 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.
- debo_ 5y agoIn university, I learned Perl out of curiousity. It was the first scripting language I tried; I was only familiar with Java, C and Scheme at the time. 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.
- tetris11 5y agoThat is what bash/pipeline programming felt like for me the first time I mastered it. 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
- wutbrodo 5y agoI'm not super familiar with Perl, but I gather that it shares much of bash's, er, ergonomic hurdles. 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.
- deleted 5y ago[deleted]
- lenkite 5y ago
- deleted 5y ago[deleted]
- marzell 5y agoWell, as fun as this is, I think it really has more to do with how the OCR happens to interpret watercolor splashes as mostly characters of a charset that parse into strings in Perl. They are not "programs". Basically, anything that outputs randomish strings of ascii seems to be parseable as string values in Perl.
- z3ro 5y agoAre these Hunter Biden Originals?
- bialpio 5y agoPublished on April Fool's, caveat lector.
- visarga 5y agoGood thing I gave up Perl5 years ago (after 15 years) and switched to Python. I can't even read the new Perl code, it's so obtuse. Now I like Python, it's much easier to parse because there aren't 1000 ways to do a simple thing. Perl was a write only language. 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.