93% of paint splatters are valid Perl programs (2019)

(mcmillen.dev)

512 points | by zenincognito 16 hours ago ago

49 comments

  • snitty 15 hours ago

    SIGBOVIK papers are almost always a delight

    EDIT: From their 2026 publication

    >Permission to make digital or hard copies of portions of this work for personal use is granted; permission to make digital or hard copies of portions of this work for classroom use is also granted, but seems ill-advised

  • layer8 16 hours ago

    Tangentially related, the only way for a Java properties file to be invalid is if it contains an invalid Unicode escape sequence (“\u” not followed by four digits, and not preceded by an odd number of “\”). After resolving Unicode escapes, any character sequence is a valid properties file.

    • hyperman1 9 hours ago

      I've had a program where some R code stuffs some input in an URL, fires it at a server, then reads the returned CSV. No error handling or validation is attempted.

      As it happens, basically anything is a valid CSV.

      If the input is wrong, the server responds with an XML error. This got interpreted as a CSV. Every line became a record, but no column headers were found so every expected field is null/NA. All these nulls get nicely sorted and processed, which causes more string errors, etc ... Mayhem ensues when thst stuff ends up in a database.

  • gnabgib 16 hours ago

    Popular in:

    2024 (515 points, 125 comments) https://news.ycombinator.com/item?id=40197013

    2021 (431 points, 165 comments) https://news.ycombinator.com/item?id=27929730

  • zenincognito 16 hours ago

    The actual paper is also highly entertaining - https://www.mcmillen.dev/sigbovik/2019.pdf

    • heresie-dabord 13 hours ago

      From the paper:

      "An interesting thing about these images is that they’re not particularly Perl-specific; for example, the program shown in Figure −3 also evaluates as the number −3 in Python (and presumably several other programming languages.)"

      We live in the age of Python, which I use every day. But I still also use Perl when it's the better tool for the job. And it often is!

    • Amorymeltzer 16 hours ago

      In particular, I like "Figure − 3. − 3 ." as a good little easter egg.

    • 0xbadcafebee 15 hours ago

        The remainder of the valid Perl programs are mostly valid due to a Perl
        language feature that is not commonly present in most programming languages.
        Namely, Perl has a feature called “unquoted strings”, in which a sequence
        of alphanumeric characters by itself is parsed as though it were a quoted string.
        As an example, Figure 5 is read by OCR as the text ME, which evaluates to the
        string “ME” even though the ME isn’t quoted. This would result in a syntax
        error in most other programming languages.
      
        (To be fair to Perl, when perl is run with the -w flag to enable warnings, it does
        helpfully inform the user that at some point in the future, the Perl developers
        will most likely pick gggijgziifiiffif as a new reserved word:
            Unquoted string "gggijgziifiiffif" may clash
            with future reserved word at - line 1.)
    • comboy 7 hours ago

      For those who do not enjoy reading scientific papers this one is worth reading.

  • ideasphere 11 hours ago

    I’m more interested in how the OCR missed that ‘Stitch & Shutter’ watermark in the third one.

    • michaelt 7 hours ago

      It looks like the author used Tesseract, a traditional OCR image with lineage going back to HP flatbed scanners in the 1980s [1]

      Obviously, it's been improved a lot since then - but traditional OCR is mostly about black text on white backgrounds. Or at least, the text being high-contrast relative to the rest of the document.

      Light gold text on a white background, while there are black splatters? That's the sort of thing it would struggle with for sure.

      [1] https://static.googleusercontent.com/media/research.google.c...

    • bozdemir 11 hours ago

      Hahahhahah good catch.

  • rurban 5 hours ago

    That's with the flexible perl5 parser with a dynamic lexer, which allows everything. For my new faster perl backend perl11-p2 I am using a PEG parser, similar to raku, which needs static rules for everything. So I bet it will not accept most of the noise. But I still can run only 50% of all perl programs.

  • baron3dl 14 hours ago

    i loved programming perl. both the act, and the book. i long since gave it up, but i am still awed by how it could both be completely unceremonious and absurdly ceremonious. my $self = shift; for instance.

  • jacquesm 14 hours ago

    Someone should reverse that and see how many paintings can be made to execute as Perl and what those programs do when invoked.

    • kmoser 13 hours ago

      You could kill two birds with one stone by entering them in the Obfuscated Perl Contest, were it still being held.

  • idlewords 14 hours ago

    A whole new twist on "Hackers and Painters"

  • isolay 5 hours ago

    > fruitful procrastination

    It is so rare to find proper appreciation for this creative skill.

  • charcircuit 8 hours ago

    This is more about a bad OCR than about paint splatters. They also tried multiple OCR settings until one worked. If you used more accurate OCR this would be very different.

    • michaelt 7 hours ago

      More accurate OCR would recognise the images have no text

        $ touch temp.pl; perl temp.pl; echo "exit code $?"
        exit code 0
      
      which is a valid perl program. And that one image with the watermark "stitch & shutter" ?

        $ echo "stitch & shutter" > temp.pl; perl temp.pl; echo "exit code $?"
        exit code 0
      
      Also valid perl.
  • SoraTakai 11 hours ago

    It all depends on which OCR to use and therefore meaningless. It is especially more meaningless since they do not establish the baseline (OCR "pass" % on random input).

    • ashton314 11 hours ago

      I think you’ve missed the point…

  • dukoid 2 hours ago

    Now I wonder if that holds for Objective C programs, too....

  • notorandit 9 hours ago

    The problem is the ocr, then.

  • xenic 9 hours ago

    Perl is such a ride. I wrote and maintained a nms/statistics/alerting stack around 2003-2004, ended up being around 200k LoC iirc. Just heard it is still in use at that company. My condolences to whoever has had to maintain that monster.

    I was somewhat pleasantly surprised a few days ago when an LLM out of the blue decided to use perl, not python, for some simple scripting. There is hope in the world yet…

    • maxlybbert 4 hours ago

      And Perl from 2003-2004 was especially bad. It took amazing effort to pass a file handle as a subroutine parameter. I once took a look at the Perl code behind Bugzilla, and quickly decided that it was better to let sleeping dogs lie.

  • brisket_bronson 15 hours ago

    Figure 6 represents the string “gggijgziifiiffif”, which by pure coincidence happens to accurately represent the authors’ verbal reaction upon learning that “unquoted strings” were a feature intentionally included in the Perl language

    • omoikane 12 hours ago

      There is a gem in the footnote right below gggijgziifiiffif, where it says it's possible to make a perl error quine by writing this line to the right location:

          Illegal division by zero at /tmp/quine.pl line 1.
      
      I just tried this perl 5.42.0, and any file name starting with a '/' will work.

      See also:

      https://news.ycombinator.com/item?id=40202182

      https://news.ycombinator.com/item?id=19576872

      https://codegolf.stackexchange.com/a/48394

    • larsonian an hour ago

      Unquoted strings are the default in shell languages, and one of the design goals of Perl was to be a more powerful replacement for shell scripts. It's not a particularly surprising feature, really.

      For anything more complex than a one-off script, Perl is pretty much always written with `use strict`, which disables unquoted strings and certain other (mis)features.

    • lta 15 hours ago

      I'm afraid I have to tell you you lack the soul of a poet to truly appreciate the brilliant design . Perl is magic (like litteraly). I'm fairly sure it's one of the untold inspiration of the Harry Potter books

  • trpaslik 10 minutes ago

    perl is a write-only language ;-)

  • polarsanel 13 hours ago

    93% of Perl Programs are valid Paint Spatters too.

  • sadboi_fandango 16 hours ago

    Jackson Pollock was writing perl code all along

    • HeckFeck 15 hours ago

      My Stone Roses album cover is actually a bonus Perl program?

    • kmoser 13 hours ago

      No, when Pollock spattered paint on a canvas, it was generally on the floor, not the Wall.

  • silvandeboer 8 hours ago

    The modern version would be to input the image without further context into an LLM and constrain the output to valid Rust.

  • criemen 15 hours ago

    > Apparently in the brave new world of neural nets, Anything Goes™

    Quite some foresight indeed!

  • spwa4 5 hours ago

    Luckily with AI, that has since increased to 100% with a small prompt ...

  • _doctor_love 12 hours ago

    I don't need to read the article because the headline is true.

    A mentor taught me that you can also roll your face on the keyboard to produce a valid Perl program. It's easy and fun to try!

    • lisper 11 hours ago

      A cat walking across the keyboard works too.

  • NoMoreNicksLeft 12 hours ago

    I thought perl was finally dead enough people would stop mocking it. I'll wait til next decade.

    • theonemind 9 hours ago

      History in reverse: first you win, then they mock you, then they ignore you

    • kqr 9 hours ago

      Perl is not dead! Its popularity has merely reached dotcom level! https://entropicthoughts.com/what-killed-perl

    • HackerThemAll an hour ago

      Perl requires more brain power than most coders have, especially nowadays.

      Perl has never disappointed me. Many years ago during just 2 weeks I'd written a few clever automations and orchestrations in Perl that had lasted with 100% availability for a decade after I changed that job. Even though my superior, the self-proclaimed "top coder manager all-in-one god" despised it (and me), he was incapable of comprehending and rewriting that. It was not because I obfuscated the code, but because of what I wrote in the first sentence above. In the end he hired a consultancy and got a monstrous solution in Java. But finally it was "his".

  • TMWNN 16 hours ago
    • fractorial 11 hours ago

      I think this is the first time I’ve seen a TikTok link on HN.