16 ms·
93% of paint splatters are valid Perl programs (2019)
- stcredzero 2y ago"is it possible to smear paint on the wall without creating valid Perl?" This is just a matter of syntax, right? So could it be determined by a stack machine? Unfortunately, the answer is no. Perl is not context free! https://perlmonks.org/?node_id=663393 https://perlmonks.org/?node_id=663393 As just a guess, this question maps to the Halting Problem. (EDIT: That would have to be the question where the input is a programming language, not just for Perl. That question has been answered empirically.)
- mrighele 2y agoNow I am wondering the percentage of programs written in Piet [1] that are also valid Perl programs, and if there is any instance where the are two are actually the same. [1] https://esolangs.org/wiki/Piet https://esolangs.org/wiki/Piet
- tromp 2y agoConcatenative languages [1] have the property that every token sequence is a valid program. For languages using single bits as tokens, every bit sequence is a valid program. One such language is Chris Barker's zot [2]. Inspired by zot, I defined a concatenative version of Binary Lambda Calculus that shares the same property [3]. [1] https://en.wikipedia.org/wiki/Concatenative_programming_language https://en.wikipedia.org/wiki/Concatenative_programming_lang... [2] https://en.wikipedia.org/wiki/Iota_and_Jot#Zot https://en.wikipedia.org/wiki/Iota_and_Jot#Zot [3] https://cstheory.stackexchange.com/questions/32309/concatenative-binary-lambda-calculus-combinatory-logic https://cstheory.stackexchange.com/questions/32309/concatena...
- deathanatos 2y ago> Concatenative languages [1] have the property that every token sequence is a valid program. I don't think this is correct? Concatenative languages have the property that if a and b are both valid programs, that the program a || b is valid (where || means "concatenate"). But that property doesn't imply that every sequence of tokens is valid. For example, in Cat, [1 2 is not grammatically valid.
- tromp 2y agoYou're right. I should have qualified it as "some concatenative languages".
- joshmarlow 2y agoIs there a particular term for concatenative languages with this property?
- contravariant 2y agoTrivially it's all concatenative languages where each single token is valid. Not sure if they have a name but I would be tempted to call it a free language.
- YeGoblynQueenne 2y agoSo does Prolog count as a concatenative language given the standard definition of concatenative languages? For context, a Prolog program is a set of definite clauses so the union of two Prolog programs is a Prolog program. In fact, this property forms the basis of the concept of (syntactic) generality in Prolog: if P1, P2, P3 are three Prolog programs such that P1 is the union of P2 and P3, then we say that P1 generalises each of P2 and P3. Does this concept of generality also exist for concatenative languages?
- dheera 2y agoThey used an OCR program though, which probably has a bias toward attempting to close parentheses.
- kqr 2y ago> making Jot a natural Gödel numbering of all algorithms. This sounds very cool. I wish I understood both Jot and that sentence.
- tromp 2y agoA Gödel numbering is simply a mapping to integers (that is easily decoded). If your programs are arbitrary binary strings, then you're basically already done, since bitstrings are in 1-1 correspondence with integers: empty 0 1 00 01 10 11 000 001 ... 0 1 2 3 4 5 6 7 8 ...
- Dylan16807 2y ago> A Gödel numbering is simply a mapping to integers (that is easily decoded). "easily" is arguable. Sure, I could multiply/factor an enormous number and count how many copies of each prime it has, but I'd much rather concatenate/split some digits.
- thaumasiotes 2y agoFactoring numbers is difficult. Manipulating digits is easy, or it looks that way, but this is partially an illusion resulting from the number being given to you with the digits already known. If you have a quantity in mind but you're not sure what its digits are, it can be a lot of work to learn.
- Dylan16807 2y agoI don't know what you mean by "not sure what its digits are". If you mean what base to represent the number in, that's no more arbitrary than knowing the exact way Gödel numbers use primes.
- pmontra 2y agoMaybe it's an unfair example but: the number of people on Earth. We know the quantity more or less, the leftmost digit in base ten, then it's a lot of work to figure out the other digits.
- gofreddygo 2y agoserious question: What good is perl in 2024. Follow up: where do you see it going. Full disclosure: never implemented anything useful in perl in my personal or professional capacity for the last decade, except for debugging a few scripts here and there.
- tootie 2y agoPerl is a Turing-complete language that runs on any platform and has maybe the longest-standing repository of open-source libraries. I haven't seen a benchmark recently, but I'd bet it still outperforms Python or node. But yeah, you'd be laughed out of any job for suggesting it be used for any serious work. It lost the PR war years ago. I used it as my primary language for several years and it's extremely capable and intuitive. The learning curve of it's syntax is really only slightly longer than any other language. And I have the very strong opinion that syntax contributes less than 5% of readability and the rest is up to the developer to factor smartly and name things well.
- diputsmonro 2y agoAgree! I will add that it's actually very possible to write Perl in a readable way (at least no more unreadable than your average bash or python script). It's all up to the developer to write readable, maintainable code instead of trying to impress themselves with their esoteric one-liners. With the light syntax and giant, well-documented community repos, it feels a lot like Python With References to me, which is honestly pretty great imo. I wish more people respected Perl.
- xandrius 2y agoTo be fair neither node nor python are where they are today because of their performance. I wish we could leave them behind as a fun phase of mass adoption of programming and fully switch to strongly typed languages alone. One can dream.
- tootie 2y agoAs much as I enjoyed Perl, I also cannot fathom how these kind of languages got so much adoption. For me, productivity is most strongly correlated with IDE support, debuggers and documentation. These are the kind of things Java and C# beat everyone else at. But it seems like a lot of devs are just dogmatically tied to their text editors.
- lupire 2y agoCute idea, and useful research to answer the question, but the experimental result is essentially nothing. None of the examples generated anything semantically more complex than `0-0`. Many scripting languages will tolerate meaningless input. Instead of these extremely non-character-istic splatters, I think scribbles or random raster bitmaps would be better input.
- eternityforest 2y agoIf it tolerates meaningless input, that means you could accidentally hit a key, type garbage in a file and the compiler would have no complaints... I've done this many times, trying to use the search bar and then having the debugger suddenly plop my cursor into a file.... I get what people are going for, but I don't think I would enjoy coding in Perl!
- thyrsus 2y ago1. git complains about the uncommitted changes 2. When intentionally writing perl, half the time my "perl -c foo.pl" complains about syntax or badly used names (usu. misspellings), with the typo to correct being obvious. As a practical matter, it's not a problem. I see a lot of semicolons in that ocr output, which might be cheating.
- eternityforest 2y agoGit complains about uncommitted changes but it won't complain if you just like, open a random file and hit a key. I'm sure it has some level of checking, but it doesn't seem anywhere near like what you get in Rust or MyPy. I generally find dumb mistakes and typos take more time to solve than type annotations and verbose syntax take to write.
- mrguyorama 2y ago>but the experimental result is essentially nothing. Sir, this is SIGBOVIK.
- interroboink 2y agoI enjoyed footnote 5: ⁵ 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.
- deleted 2y ago[deleted]
- LeifCarrotson 2y agoCan you help out a reader who does not know any Perl? I tried it in the REPL and found that "Illegal division" can't locate method "illegal" in package "division", so presumably that gets ignored, same with method "by" in package "zero", and that "at /tmp" is the simplest version of the string that produces the error message, which apparently is more severe than the missing package warnings and terminates the program? I'd guess the / is the operator for division, and the "tmp" is getting initialized as a variable and coerced into an integer? But "/tmp" doesn't do it, and "/tmp/" does something with regex, so I'm not sure why the parser would split it there.
- hoytech 2y agoEasiest way is to Deparse it: $ perl -MO=Deparse tp.pl 'division'->Illegal('zero'->by('at' / 'tmp' / 'quine' . 'line'->pl(1))); tp.pl syntax OK So I believe this is what causes it (note that "at" and "tmp" and such are "barewords"): $ perl -e 'at / tmp' Illegal division by zero at -e line 1.
- interroboink 2y agoThe footnote is originally referenced here: 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.⁵ So, the hint is that this has to do with the "unquoted strings" feature (aka "bare words"[1]). See the sibling comment about the actual parse — "at" and "tmp" are seen as strings. The strings get coerced into numbers due to being used with the numeric "/" operator (that's normal Perl behavor). Since the strings can't be parsed as numbers, they become "0". So, you get division by 0. [1] https://perlmaven.com/barewords-in-perl https://perlmaven.com/barewords-in-perl
- rrr_oh_man 2y agoI love the splatters — what’s the copyright on those?
- Manabu-eo 2y agoThey gathered images from pinterest.
- neilv 2y agoClever variation on the old "indistinguishable from line noise" jokes. (For those who weren't frequently exposed to "line noise"... Imagine an ASCII character video terminal that's interpreting a stream of bytes, to display meaningful text. Now imagine that the communication channel gets corrupted somehow (say, someone picks up the phone handset while modem is online, or there's interference on the cable), and there's no error correction or checksumming, so the bytes being interpreted are effectively become randomized. So random letters, digits, punctuation, control characters, etc., are being interpreted and displayed, and this is familiar, and you know it's random and why... but the joke is that it's still actually a valid Perl program.)
- saalweachter 2y agoGreat, now you've made me realize that line noise is in the same category of things I'll never be able to explain to Kids These Days (like broadcast schedules), and now I might as well get it over with and tie an onion to my belt.
- gfldex 2y ago$ cat ~/.signature -- raku -e 'try { not :2(.fear) } and do not die' perl -e 'do not $fear and do not die' raku -e 'say „The Road to Wisdom“; $*ERR and $*ERR and $*ERR but Less and Less and Less'
- legitster 2y agoUnrelated, but what a garbage original tweet that this is taken from. Getting taught useful skills is not mutually exclusive to kids being kids. It would have been nice to have learned how to use a drill press in school rather than the Dewey Decimal System. What do you even think school is for? I didn't come from a very privileged background - no one was going to hand me a career when I turned 18. "I wish I'd had more time to be a kid". I'm a grown ass man and I still read books too late and splash in puddles. It sounds like you just decided not to be fun one day and are blaming other people for you being boring.
- tedunangst 2y agoIf you learn the Dewey Decimal system, you can go to the library and find a book to teach you to use a drill press. On the other hand, if you take a drill press to the library looking for a book, ...
- laurowyn 2y ago...you can mark all the books you've checked with a hole so you know you've checked them. Work harder, not smarter. /s Jokes aside, I still agree with GP, in that there are more practical skills that are left out of education that would be far more useful in day to day life. The Dewey Decimal System has been replaced with search engines. I don't need to know how a search engine works in order to type in "how to use a drill press" and read the results. But that's because the knowledge and understanding of how computers work at a high level circumvents the need to do that - a search engine is a form, give it something to search and hit the submit button. Easy. Being taught by someone to use machining tools helps build an understanding of how every day items are made using those tools, so you have a more fundamental understanding of the items could be combined together into other more interesting things, repair them, take them apart and service them. It's almost the opposite problem of maths in schools. We're taught maths in various incresasingly complex ways, all the way up to calculus. Those methods teach us how to use maths to do clever things. But every day maths doesn't need that. We're taught compound interest, but we have to use that to figure out how to do our taxes by ourselves without any help. Wouldn't it be nice to have an overlap there, hit two birds with one stone and we all walk away with a stronger understanding of the world? If we're not taught how to make things, we struggle to learn how things are made, which means less things get made. Learning how to make things early, and embedding the knowledge of how things are made, enables more things to be made in future.
- mlhpdx 2y agoInteresting, but the social relevance would be improved if the input images were graffiti.
- m000 2y ago[flagged]
- iamleppert 2y agoWith Generative AI, you can create new and innovative paint splatters that evaluate to working software, faster than ever before. Generative AI enables a new class of creators to harness and leverage text to image workflows, driving value for businesses of all sizes. New AI models are capable of embedding working software and machine readable codes into a wide variety of high resolution content, engaging viewers and providing creators new and exciting ways to grow their audiences.
- jhdias 2y agoPosted 1st April. This implies something.
- dmbche 2y agoMore cutting edge computational research here : https://sigbovik.org/ https://sigbovik.org/
- dang 2y agoRelated: 93% of Paint Splatters Are Valid Perl Programs (2019) - https://news.ycombinator.com/item?id=27929730 https://news.ycombinator.com/item?id=27929730 - July 2021 (163 comments) Also: 93% of Paint Splatters Are Valid Perl Programs (2019) - https://news.ycombinator.com/item?id=38754686 https://news.ycombinator.com/item?id=38754686 - Dec 2023 (1 comment)
- 0xbadcafebee 2y agoas a Perl programmer, I consider that non-functional 7% a bug
- glenstein 2y agoI understand that this discusses recognizing paint splatters as characters with a given "optical character recognition" program, which seems disposed to almost always recognize pain as some combination of characters. Of the many possible ways this could be realized, this is absolutely welcome and in the spirit. However, it did give me the initial impression about other possible ways to do this, such as taking patches of color and empty space as 0s and 1s, and the totality of it as a program. I think the vast majority of those cases would be pointless noise. So there's two extremes, one with mostly noise, one with mostly meaning. I suppose the game-within-the-game here is to find what form of interpretation does the most to credit paint splatters with the most possible meaning where, to the greatest extent possible, the meaning truly comes from the structure and not from how aggressive the rules are at choosing to see meaning.
- bee_rider 2y ago> disposed to almost always recognize pain as some combination of characters. Well, break out the eeg, let’s see if pain is also a valid perl program.
- luxuryballs 2y agowhy is Perl like this??
- ramon156 2y ago"is he stupid?"
- Iris2645 2y agoSuch a bullshit article.
- Bjartr 2y agoThat's entirely the point.
- broken-kebab 2y agoJokes aside, isn't it wrong that OCR software still always produces textual result from images wich are not text? More than a decade ago I OCRed an old book, and I remember how annoying it was to deal with all the garbage text produced from small pictures, smudges, and dirt. It looks like there's not much progress done since in the field
- jonahx 2y ago> It looks like there's not much progress done since in the field LLMs help here. From my own experiments chatGPT is pretty good "smart, context-aware" OCR agent.
- Kubuxu 2y agoUsing image embedding and evaluating 100s billion parameter LLM for OCR is like hunting rabbits using Yamato’s 18in naval gun.
- manquer 2y agoWell using a human is bring an interstellar rail gun to hunt rabbit so i guess it still better ?
- jonahx 2y agoNot really. Proper OCR in the broadest sense (extracting text from arbitrary pdfs that intermingle tables, images, etc, or from hand written artistic posters) requires a full understanding of semantic intent. You are perhaps imagining more constrained scenarios of straight lines of consistent text on a page with well-known artifacts of "noise" (smudges, print imperfections, and so on).
- petters 2y agoYes, there has been progress. But the featured article is meant to be fun!
- kzrdude 2y agoThat question seems to be the same kind as the question in the OP. Isn't something wrong when a random scribble creates a valid execution in Perl?
- sakesun 2y agoMore than a decade ago, I heard a big consulting firm executive stated that he deliberately base his project on Perl, because his team will have less chance to find a new job elsewhere from this skill. :|
- Jsisn 2y agoI don't understand how that is done. Can someone explain to me how to do the same? Whether it is reading the raw image, a particular format or the bytes of the print. Surely it's not like that, like I said I don't understand.
- tlarkworthy 2y agoThe OCR (optical character recognition) is doing the heavy lifting, essentially forcing the blotches into strings... which then turn out to be valid perl programs
- cies 2y agoI've come to prefer languages that score very low on this metric of "paint splats OCRed yield valid $PROG_LANG programs". A lot of fun I had with a language called Elm, in which runtime errors are nearly impossible to express.
- syadegari 2y agoTangentially relevant to this is Perl Secrets, a list of operators and constants discovered by various users: https://github.com/book/perlsecret/blob/master/lib/perlsecret.pod https://github.com/book/perlsecret/blob/master/lib/perlsecre...
- tenderfault 2y agois the ocr system written in perl by any chance?
- Mathnerd314 2y ago> (source code not available yet because i am bad at GitHub) Lost forever I guess. Certainly it's not at https://git.mcmillen.dev/explore/repos https://git.mcmillen.dev/explore/repos
- methods21 2y agoI so wish Perl was still in the 'mainstream' and Perl 6 didn't fizzle. Love Perl.