12 ms·
93% of Paint Splatters Are Valid Perl Programs
- pwason 8y ago93% of random OCR outputs are valid Perl programs. The paint splatters are a distraction.
- waynecochran 8y agoYes, but it is a fun distraction and kept me from my work for a few minutes.
- heavenlyblue 8y agoThere’s at least an infinite number of infinitely long inputs to Perl. Which proportion of these will terminate without an error?
- benj111 8y agoTrick question. An infinitely long input will never finishing reading, so we'll never find out :)
- UncleMeat 8y agoIts sigbovik. The entire conference is a distraction. That's the whole point.
- cafard 8y agoSo who's going to write the app we can carry on our phones into MOMA and evaluate the Jackson Pollocks?
- jonathanhd 8y agoI strongly recommend that you read the linked paper also.
- waynecochran 8y agoDo any of the splatters generate a "use strict;" at the beginning?
- thaumaturgy 8y agoIt would be interesting to reverse-engineer this to figure out which paint splatters reliably produced "use strict;".
- kevin_thibedeau 8y agoPresumably one could have AFL fuzz determine the input needed to generate any desired outcome if splatter generation is automated.
- shawnz 8y agoHow would you prevent it from finding "paint splatters" which are just renderings of the actual text in question?
- telesilla 8y agoI 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).
- cure 8y agoYeah... Ruby's very nice and feels Perl-ish sometimes.
- freedomben 8y agoYep, if you like Perl you've got to spend some time with Ruby. It shares a heritage. Many of the people I used to Perl with moved over and were (and are) very happy. That said many of the "perl-isms" in Ruby are looked down upon by the community, but you can still use them ;-)
- tluyben2 8y agoI programmed Perl for many years and Ruby as well; I see the similarities but I very much prefer Perl and find idiomatic Ruby not very pleasant to read or write. Matter of taste ofcourse.
- bdcravens 8y agoThat's intentional. https://www.ruby-lang.org/en/about/ https://www.ruby-lang.org/en/about/ "Ruby is a language of careful balance. Its creator, Yukihiro “Matz” Matsumoto, blended parts of his favorite languages (Perl, Smalltalk, Eiffel, Ada, and Lisp) ..."
- roberto 8y agoThe name "Ruby" is also a play on "Perl" ("pearl").
- ars 8y agoBecause for anything you wanted to do there were 6 different ways to do it in Perl, making it rather hard to learn Perl. Perl also looks like line noise, which makes it hard to read. PHP also won because you can take a .html file add <?=$x+1?> and it's a valid PHP program. Perl was harder.
- puls 8y agoI 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 8y agoIt'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 8y agoOr "quine.pl line 1." Evaluates to 0? Or should that be 0.0???
- yellowapple 8y agoYeah, I think it's both divisions. Both 'perl -e "in /tmp"' and 'perl -e "tmp/quine"' result in the same division-by-zero error.
- barthold 8y agoI think it's equivalent to something like Illegal::division(by::zero(at/tmp/quine . pl::line(1.)))
- fanf2 8y agoIt is slightly more complicated than that :-) https://fanf.dreamwidth.org/131318.html https://fanf.dreamwidth.org/131318.html the actual parse is division->Illegal( zero->by( ((“at” / “tmp”) / “quine”) . line->pl(1.0) ))
- nanis 8y ago$ perl -MO=Deparse -e "Illegal division by zero at /tmp/quine.pl line 1." 'division'->Illegal('zero'->by('at' / 'tmp' / 'quine' . line'->pl(1))); -e syntax OK
- unixpickle 8y ago> 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 8y agoThe 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/1086383726450405376 https://mobile.twitter.com/mcmillen/status/10863837264504053...
- Gaelan 8y agoThere's a footnote on "unemployed person" with the text "the first author."
- harrumph 8y ago> We therefore paid an unemployed person > Such brutal honesty would be welcome in other papers. To say nothing of the commitment to employment fairness!
- nixpulvis 8y agoI LOL'd at "TLDR: read the paper and view the gallery of pretty Perl programs."
- Hamuko 8y agoPerl is a mess.
- yellowapple 8y agoPerl is art.
- anonlapwarmer 8y agoIt's modern art and worth millions. And I hear Jim Carrey is submitting packages to CPAN now.
- penagwin 8y ago> 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 8y agoThe 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
- anonlapwarmer 8y agoInterpreting a Banksy as Perl should hack the DNC and GOP to give all their money to charities.
- yellowapple 8y ago> 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.
- pnw_hazor 8y agoStill my favorite language.
- yellowapple 8y agoThis has, in fact, reinforced my sincere belief that Perl is God's chosen language.
- cygx 8y agohttps://xkcd.com/224/ https://xkcd.com/224/
- yellowapple 8y agoThere it is.
- curmudgeonal 8y agoWell, curmudgeonly, I'd have preferred if the splatters were interpreted with a greater degree of codified structure than OCR. I mean, OCR doesn't guarantee consistent output, and furthermore, it's not like a person could discern how or why the characters that fall out of the "recognition" are what they are. I feel there should be a way to transform a paint splatter to a perl expression (or any plain text string at all) according to well-defined, reversible procedure.
- leoc 8y ago100% 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 8y ago"a common game for TECO fans was to enter their name as a command sequence, and then try to work out what would happen"
- xrd 8y agoMy 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.
- et2o 8y agoBecause 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 8y agoPerl 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.
- TimTheTinker 8y agoThe best languages sacrifice readability the least for a given amount of cleverness.
- noja 8y agoExactly. Like BASIC.
- TimTheTinker 8y agoI'd argue that use of clever or advanced patterns in BASIC actually renders the code rather opaque. I.e. compare coroutine usage between BASIC and ruby (if you're even able to get it working in BASIC).
- 4thaccount 8y agoOr the best give you all the flexibility you could ever need and allow you the freedom to write readable and maintainable code or use all the features to write an insanely terse oneliner that can do the job quickly and be thrown out.
- AceJohnny2 8y agoQuite 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 8y agoI 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 8y agoWhat do you find error prone in it? As I just posted above, it solves the problem of loosing braces when moving code blocks around.
- collyw 8y agoThe whitespace thing annoyed me when I first stared using Python. Then after using Python for a few months I went back and modified some Perl. Moved some blocks of code around and lost a brace somewhere. Spent 20 minutes trying to work out where. Then I realized that it's is a problem that never occurs in Python.
- Macross8299 8y agoI 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 8y agoPerl6 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 8y ago> The design process for Perl 6 began in 2000 I don’t remember Perl losing mindshare around that time; quite the opposite.
- earenndil 8y agoPerl6 wasn't _released_ until 2016, though.
- bmn__ 8y agoYou 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 8y agoFor 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.
- _sveq 8y agoI like Perl. It is magic.
- marcosdumay 8y agoIndeed it is! You just OCR a random blob and get a division by 0 error.
- hnick 8y agoIt'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.
- jtms 8y agoThe irony is that the readability of 93% of actual Perl code is equivalent to the paint splatters
- godelski 8y agoThe 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 8y agoAren't 100% perl code -> paint splatters. For each code there exists a paint splatter i.e. image of the code itself.
- godelski 8y agoI'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 8y agoYou’re super fun at parties I bet
- barryp 8y agoNot surprising, I often felt you could roll your face across the keyboard and it'd be a valid perl program.
- ricardobeat 8y agoI 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 8y agoHey! 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 8y agoAnd the terrible truth is this is how we got skynet.
- stevekemp 8y agoI was too scared to run randomly generated perl-code. But I did have some fun fuzzing awk/gawk a while back. https://blog.steve.fi/if_line_noise_is_a_program__all_fuzzers_are_developers.html https://blog.steve.fi/if_line_noise_is_a_program__all_fuzzer...
- OrgNet 8y agois it true with all OCR engines
- bradleyjg 8y agoIf 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 8y ago> 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 8y agoI 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 8y agoThe 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.
- ksherlock 8y agoPerl can return the favor. https://metacpan.org/pod/Acme::EyeDrops https://metacpan.org/pod/Acme::EyeDrops
- knolax 8y agoWonder 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?
- yellowapple 8y agoFor 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.
- ozzmotik 8y agoah, 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 8y agoUm. He made an executable using only printable characters.
- endymi0n 8y agoNo 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.
- mikorym 8y agoHow 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':.;");
- captainbland 8y agoBut what I want to know is what percentage of perl programs could be represented as paint splatters?
- fourier_mode 8y agoWhy 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.