
93% of Paint Splatters Are Valid Perl Programs - thaumaturgy
http://colinm.org/sigbovik/
======
unixpickle
> Also, ImageNet’s website was down on the day that we decided to perform this
> research. We therefore paid an unemployed person to download 100 examples of
> paint-splatter artwork by searching Pinterest using the query “paint
> splatter wallpaper”.

Such brutal honesty would be welcome in other papers.

~~~
kyrra
The author recently quit Google[0], so I believe he's unemployed. I think
that's the joke (also, he really likes his memes).

[0]
[https://mobile.twitter.com/mcmillen/status/10863837264504053...](https://mobile.twitter.com/mcmillen/status/1086383726450405376)

~~~
Gaelan
There's a footnote on "unemployed person" with the text "the first author."

------
puls
I love this footnote so much:

> This feature does enable a neat quine: the Perl program “Illegal division by
> zero at /tmp/quine.pl line 1.”, when saved in the appropriate location,
> outputs “Illegal division by zero at /tmp/quine.pl line 1.” The reason for
> this behavior is left as an exercise for the reader.

~~~
275qaz
It's trying to divide "Illegal division by zero at /" by "tmp/quine.pl line
1." and "tmp/quine.pl line 1." evaluates to 0?

~~~
benj111
Or "quine.pl line 1." Evaluates to 0?

Or should that be 0.0???

~~~
yellowapple
Yeah, I think it's both divisions. Both 'perl -e "in /tmp"' and 'perl -e
"tmp/quine"' result in the same division-by-zero error.

------
et2o
Because of the frequency I see undecipherable strings like this in actual Perl
code, I don't like Perl the programming language. However, I love Perl the
project. Take a look at the config file for Perl and how many systems and
architectures it accommodates:
[https://github.com/Perl/perl5/blob/blead/Configure](https://github.com/Perl/perl5/blob/blead/Configure)

It's clearly such an incredible labor of love by Larry Wall et al. that I'm
sad for them it isn't more popular. Just a mammoth amount of work by nice,
passionate people.

In my world (bioinformatics), it was initially the go-to language. Even today
I very occasionally run across something using BioPerl, requiring me to
stumble through CPAN again. I get pretty nostalgic thinking about it.

~~~
orev
Perl gives you as much rope as you want to hang yourself. If you can develop a
style, and try to avoid being too clever, it can be just as readable as any
other language.

~~~
ndnxhs
And then someone else tries to read your code. One of the things I love about
ruby dev is its not about providing 10000 ways to do the same thing but about
making sure that given a simple problem, every developer will solve it in
pretty much the same way.

~~~
kiaulen
What? With ruby, there are at least 4 ways to find out how big something is
(.size, .length, et al). You want to loop over something? You can use python
style for in loops, .each, and several other ways. Your block could be a
block, or it could be a symbol with an & in front. Want a bit of code without
a name? You have blocks, procs, and lambda. Want a string? You have string and
symbol, and ne'er the two shall cross paths.

Ruby is specifically designed as a replacement for perl, and keeps a lot of
the same warts ($igils, and globals like $?, $1, etc). While I agree it's
better than perl for readability, it's not because there's only one way to do
any given thing.

------
ricardobeat
I recently wrote a little program that will create a Markov Chain from on our
perl codebase, generate a few sentences and check against `perl -c`. It takes
less than 10 attempts to generate a bunch of lines of [very funny] valid Perl
code.

~~~
snazz
Hey! I did that too! Except my version ran the Markov chain against its own
source code, which was padded with a bunch of meaningless subs that did were
never called but were valid code. It also ran in an infinite loop, which
worked well. I had to kill it after a few minutes because I was afraid it
would start running shell commands.

~~~
true_tuna
And the terrible truth is this is how we got skynet.

------
ksherlock
Perl can return the favor.
[https://metacpan.org/pod/Acme::EyeDrops](https://metacpan.org/pod/Acme::EyeDrops)

------
pwason
93% of random OCR outputs are valid Perl programs. The paint splatters are a
distraction.

~~~
heavenlyblue
There’s at least an infinite number of infinitely long inputs to Perl. Which
proportion of these will terminate without an error?

~~~
benj111
Trick question.

An infinitely long input will never finishing reading, so we'll never find out
:)

------
yellowapple
> We manually filtered out all images with any form of overlaid or watermarked
> synthetic text, because the Perl program (?) “iStock by Getty Images” is not
> particularly interesting.

It's also not a valid Perl program:

    
    
        bash-4.3$ perl -e "iStock by Getty Images"
        Can't locate object method "Getty" via package "Images" (perhaps you forgot to load
        "Images"?) at -e line 1.

------
telesilla
I miss Perl. Why did PHP win again, in the late 90s? (though I'm mostly Python
these days and shan't complain, there was a good 10 year stretch of PHP there
I'm not proud of).

~~~
onion2k
PHP won because it was easy to install and restrict (by memory usage) on
shared servers, as well as the fact that writing a PHP script was as simple as
renaming an .html file to .php so web designers who wanted some dynamic
functionality could use it really easily.

As bad as some aspects of PHP were, making it so trivial to install and make
available on a server was a brilliant move that lots of languages could still
learn from today.

If you have a project you want to become popular putting real work in to the
initial onboarding is vital.

~~~
saidajigumi
The parent nailed it. It's easy to complain about PHP from various standpoints
both pragmatic and PL-centric, but it has an amazing superpower which might be
summed as "serverless for the web, v0".

~~~
paulgb
No deployment setup will ever match the pure joy of dragging a .php file into
WinFTP, watching the little blue progress bar, and refreshing your browser.

~~~
owl57
Yes! But not exactly relevant: this deployment technology is supported by
Perl/CGI just as well.

~~~
paulgb
Definitely. I wasn't trying to be relevant so much as I got nostalgic at the
mention :)

------
waynecochran
Do any of the splatters generate a "use strict;" at the beginning?

~~~
thaumaturgy
It would be interesting to reverse-engineer this to figure out which paint
splatters reliably produced "use strict;".

~~~
kevin_thibedeau
Presumably one could have AFL fuzz determine the input needed to generate any
desired outcome if splatter generation is automated.

------
AceJohnny2
Quite against my better judgment, I've made the transition from Perl-hater to
Perl- er... -tolerator.

I found myself arguing yesterday with another person in the team about the
proper use of Perl references, which I cursed and spat on for 2 days when I
first had to use them.

I once read that my current position mirrors that of most Perl users.

(my boss has a self-confessed "irrational" hatred of Python because of
semantic whitespace. Which is ironic, because they're the one who pushed for
using YAML, which also relies on semantic whitespace (at least in the way we
use it))

~~~
shstalwart
I kinda agree with you boss. I don't hate python, but I find semantic
whitespace both tyrannical and error prone. Interestingly, Makefiles also have
semantic whitespace, which seems to be much more commonly despised than
python's.

~~~
collyw
What do you find error prone in it? As I just posted above, it solves the
problem of loosing braces when moving code blocks around.

------
cafard
So who's going to write the app we can carry on our phones into MOMA and
evaluate the Jackson Pollocks?

------
penagwin
> source code not available yet because i am bad at GitHub

I had to chuckle at that. The whole this is so ridiculous and it's wonderful
:D

~~~
fixermark
The paper is part of the SIGBOVIK "conference" that takes intentionally funny
computer science papers (of varying degrees of rigor) every year. This paper
is in good company alongside "Aumann agreement by combat", "Survival in
chessland" (an investigation of what chess piece you want to be to minimize
your chance of being captured in a game), "NaN gates and flip FLOPS" (re-
representing binary operations as valid floating-point logic on NaN and inf,
then building a hardware implementation of a machine that computes on that
logic using standards-compatible floating-point representations of those
values), and "Need more RAM? Just invent time travel!"

Full proceedings document for this year:
[http://sigbovik.org/2019/proceedings.pdf](http://sigbovik.org/2019/proceedings.pdf)

------
leoc
100% of TECO
[https://en.wikipedia.org/wiki/TECO_(text_editor)](https://en.wikipedia.org/wiki/TECO_\(text_editor\))
inputs are valid programs, or so the story goes.

~~~
baud147258
"a common game for TECO fans was to enter their name as a command sequence,
and then try to work out what would happen"

------
Macross8299
I wonder how much of Perl's decline can be attributed to the Duke-Nukem-
Forever-tier delay in releasing perl6.

It seemed like so much of the web ran on it in the late 90s and early 2000s
that it would have at least as much traction as PHP does today.

~~~
cygx
Perl6 was a reaction to Perl's loss of mindshare, not its cause.

One can speculate what might have happened if focus had been put on evolving
Perl5, or getting Rakudo production-ready as-is instead of going through yet
another round of 'tinkering' (eg making the compiler backend-independent, the
New Object Model refactor, creation of MoarVM, the Great List Refactor, ...) -
however my crystal ball seems to be broken and just continues to display 42 no
matter the question...

~~~
peteretep
> The design process for Perl 6 began in 2000

I don’t remember Perl losing mindshare around that time; quite the opposite.

~~~
earenndil
Perl6 wasn't _released_ until 2016, though.

~~~
bmn__
You mean, 1.0 of the _spec_ was released then. Don't pretend it wasn't
perfectly possible to write and run useful Perl6 programs for a good ten years
prior.

[https://en.wikipedia.org/wiki/Pugs_(programming)](https://en.wikipedia.org/wiki/Pugs_\(programming\))

[https://github.com/viklund/november/](https://github.com/viklund/november/)

~~~
earenndil
For some definition of 'perl6'. I have a perl6 book from o'reilly from 2006,
and I flipped through it recently. It bears almost no resemblance to modern
perl6. There were a _couple_ of things that were still the same (and not just
vestiges from perl5 like sigils and function calls looking like function
calls), but by and large it was something completely different.

------
pnw_hazor
Still my favorite language.

~~~
yellowapple
This has, in fact, reinforced my sincere belief that Perl is God's chosen
language.

~~~
cygx
[https://xkcd.com/224/](https://xkcd.com/224/)

~~~
yellowapple
There it is.

------
jonathanhd
I strongly recommend that you read the linked paper also.

------
anonlapwarmer
Interpreting a Banksy as Perl should hack the DNC and GOP to give all their
money to charities.

~~~
btown
Or it should output an
[https://en.wikipedia.org/wiki/Illegal_prime](https://en.wikipedia.org/wiki/Illegal_prime)

------
_sveq
I like Perl. It is magic.

~~~
hnick
It's by far my preferred method of turning thoughts into code quickly, though
I don't know what that says about my thoughts.

The free form nature is amazing to spec out an idea and see what happens.
Where it falls short for me is static analysis - a simple question like 'if we
change this module, how many scripts will be affected?' is very difficult or
impossible to answer due to the number of ways you can abuse Perl. Though in
most cases, we get by.

------
yellowapple
For additional fun, try piping random characters into perl:

    
    
        $ chars='A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~'
        $ </dev/urandom tr -dc $chars | head -c 10 | tee random.pl | perl
    

Usually you'll encounter a syntax error, but sometimes it does execute without
errors. Usually the successful ones are successful only because Perl finds an
errant octothorpe and skips over all the other literal line noise after it.

Regardless, fun to know that

    
    
        L8vw>@ksSU
    

is a valid - useless, but valid - Perl program.

------
jtms
The irony is that the readability of 93% of actual Perl code is equivalent to
the paint splatters

~~~
godelski
The logic doesn't follow the other direction. It isn't a necessary condition.
We're doing (93% paint splatter -> perl code) but that isn't equivalent to
(93% perl code -> paint splatter). The first could be valid AND the following
can be valid (0.1% perl code -> paint splatter)

~~~
fourier_mode
Aren't 100% perl code -> paint splatters. For each code there exists a paint
splatter i.e. image of the code itself.

~~~
godelski
I'm just saying the logic doesn't follow. Given the claim does not necessarily
require the opposite to be true. I don't actually know much about this perl
being paint splatter and why that even makes sense.

Your statement might make sense, but what I'm saying is that the claim in the
title doesn't equate to the claim you made. That's all I'm saying.

~~~
jtms
You’re super fun at parties I bet

------
xrd
My first programming was done with Perl. Those first attempts at programming
definitely resembled a monkey throwing paint at a wall, so this does not
surprise me.

------
endymi0n
No way. I've been known to joke to people around me for a decade that 90% of
speech bubbles of cursing comic characters contained valid Perl code. I don't
believe someone actually set out to prove it (or something very similar at
least). Things like these are why I love HN.

------
ozzmotik
ah, a nice and absurd sigbovik presentation. everything I hear from that
convention has been simultaneously silly and amazing (especially the stuff
that Tom7 did like having a printed program with only printable characters
that is a valid and compiling c program)

~~~
pronoiac
Um. He made an _executable_ using only printable characters.

------
bradleyjg
If you never worked in perl, you might think people are being a bit mean and
want to take a contrarian position. It really was that bad. You'd come back
from lunch and need to pull out a notepad and start diagramming to understand
the code you are written an hour earlier. The only language I've ever seen,
outside of joke languages like brainfuck, where the typical program was less
readable is APL.

~~~
kbenson
> You'd come back from lunch and need to pull out a notepad and start
> diagramming to understand the code you are written an hour earlier.

I think this says more about your skill level in programming Perl or
programming in general at that time than it does about Perl. Or at least the
influences that you learned Perl from.

It's possible to write nearly unreadable code in any language. It's easier to
do so in Perl, since it's pretty freeform. It's also not that hard to write
very clear code. But you're complaining about your _own_ code. I think perhaps
blaming the tool at that point is looking in the wrong place.

~~~
bradleyjg
I was certainly not a good programmer back then. But when I started writing
java (1.1!) instead my bad code was a lot less bad.

While I’m sure it’s _possible_ to write maintainable perl I’ve never heard
anyone say “we had 10,000 lines of perl and it was a joy to work with.” Ever.

~~~
kbenson
The Java version puts the prior comment in perspective. I agree even most Perl
programmers would not want to work on a codebase from this Era. The problem is
that Perl was the de-facto web programming language at the time, and large
swaths of the internet was written by Perl neophytes and programming amateurs.
The code generated by this population was necessarily problematic.

By the same token, PHP codebase of the early 2000's were a horrible mess.
There is a downside to being among the popular and accessible languages of a
period. It takes a while for the general community skill level to increase and
best practices to trickle down to new people. Javascript of a few years ago
wasn't all that different, except for a large amount of experienced
programmers from other languages also being involved because of its privileged
place as the language of web browsers.

These days, I wouldn't imagine most codebasse of 10k lines in Perl being
noticeably worse than in Python or Ruby.

------
captainbland
But what I want to know is what percentage of perl programs could be
represented as paint splatters?

------
knolax
Wonder what it would take to transform, as an one to one function, any random
text into a syntactically correct program of any language. Off the top of my
head, enclosing the text in a string literal would work, but are there more
interesting methods out there?

------
fourier_mode
Why not just generate random strings and then see how many of them are valid
Perl programs. Pretty sure it will land around the same number. The image
->OCR->Perl is making a boring statement fancy for no reason.

------
mikorym
How can one grab the output? The following (first line) saves nothing to the
file as is seen in the second line and with the program in the third line:

~$ ./perltest | tee output.txt

~$ cat output.txt

~$ cat perltest

#!/usr/bin/perl

eval(";i;c;;#\\\?z{;?;;fn':.;");

------
barryp
Not surprising, I often felt you could roll your face across the keyboard and
it'd be a valid perl program.

------
OrgNet
is it true with all OCR engines

------
nixpulvis
I LOL'd at "TLDR: read the paper and view the gallery of pretty Perl
programs."

------
Hamuko
Perl is a mess.

~~~
yellowapple
Perl is art.

~~~
seangeo
Art is Perl.

~~~
jpfed
Well, about 93% of it at least.

~~~
mikorym
93% of a sample space of 100 splatter artworks is.

