Live data from Hacker News

93% of Paint Splatters Are Valid Perl Programs (2019)

mcmillen.dev

121–130 of 170 posts

Re: 93% of Paint Splatters Are Valid Perl Programs (2019)

#121

Earlier quoted context omitted.

I 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?

> I 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! But if someone said "95% of paint splatters OCR as Welsh words" and it turned out that's because the OCR is looking for words, it doesn't say much interesting about Welsh like the title implies. > Edit: Also, the programs i…

> But if someone said "95% of paint splatters OCR as Welsh words" and it turned out that's because the OCR is looking for words, it doesn't say much interesting about Welsh like the title implies.

I think it depends on the claim, right? IMO, a more analogous statement might be "95% of paint splatters OCR as grammatically-correct Welsh sentences." Unless the software is using something like GPT-3, that finding would be notable regardless of software tuning. Even if it tells us more about Welsh grammar than it does paint splatters.

> Look at the whole gallery though. Most of the OCR results are just a string of letters or a number. Those being valid is very mundane.

Yes, thanks, my mistake!

Re: 93% of Paint Splatters Are Valid Perl Programs (2019)

#122

Earlier quoted context omitted.

I once wrote a vital satellite maneuver orchestration software, which had to parse various files and call models. Simultaneously the scariest and proudest moment in my career, but the alternative was Fortran or C.

FWIW, the originator of "Duff's Device" (an infamously counterintuitive C construct) claimed that "I feel a combination of pride and revulsion". O:-)

I came across Duff's Device as a student and to this day it's one of my favourite pieces of code. It's practically a piece of art!

Re: 93% of Paint Splatters Are Valid Perl Programs (2019)

#123
Well, 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.

Re: 93% of Paint Splatters Are Valid Perl Programs (2019)

#125

Earlier quoted context omitted.

> I 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! But if someone said "95% of paint splatters OCR as Welsh words" and it turned out that's because the OCR is looking for words, it doesn't say much interesting about Welsh like the title implies. > Edit: Also, the programs i…

> But if someone said "95% of paint splatters OCR as Welsh words" and it turned out that's because the OCR is looking for words, it doesn't say much interesting about Welsh like the title implies. I think it depends on the claim, right? IMO, a more analogous statement might be "95% of paint splatters OCR as grammatically-correct Welsh sentences." Unless the software is using something like GPT-3, that finding would b…

> IMO, a more analogous statement might be "95% of paint splatters OCR as grammatically-correct Welsh sentences." Unless the software is using something like GPT-3, that finding would be notable regardless of software tuning. Even if it tells us more about Welsh grammar than it does paint splatters.

Well, I'd argue that "potato" is a grammatically correct sentence in most languages. (Imagine someone asked you what kind of soup you're holding.) And so is "7" and so is "Fififz".

And that's literally what's happening with Perl with the vast majority of these. It's treating a single word/number as a statement.

If you want to say something notable about grammar, you need to be generating sentences that are longer than a single noun.

Re: 93% of Paint Splatters Are Valid Perl Programs (2019)

#126

Earlier quoted context omitted.

It 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.

I'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"

In 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.)

Re: 93% of Paint Splatters Are Valid Perl Programs (2019)

#127
post #71

Earlier quoted context omitted.

I once wrote a vital satellite maneuver orchestration software, which had to parse various files and call models. Simultaneously the scariest and proudest moment in my career, but the alternative was Fortran or C.

Why didn't you write it in C?

Master Foo and the Ten Thousand Lines

Master Foo once said to a visiting programmer: “There is more Unix-nature in one line of [Perl] script than there is in ten thousand lines of C.”

The programmer, who was very proud of his mastery of C, said: “How can this be? C is the language in which the very kernel of Unix is implemented!”

Master Foo replied: “That is so. Nevertheless, there is more Unix-nature in one line of [Perl] script than there is in ten thousand lines of C.”

The programmer grew distressed. “But through the C language we experience the enlightenment of the Patriarch Ritchie! We become as one with the operating system and the machine, reaping matchless performance!”

Master Foo replied: “All that you say is true. But there is still more Unix-nature in one line of [Perl] script than there is in ten thousand lines of C.”

The programmer scoffed at Master Foo and rose to depart. But Master Foo nodded to his student Nubi, who wrote a line of [Perl] script on a nearby whiteboard, and said: “Master programmer, consider this [Perl one-liner]. Implemented in pure C, would it not span ten thousand lines?”

The programmer muttered through his beard, contemplating what Nubi had written. Finally he agreed that it was so.

“And how many hours would you require to implement and debug that C program?” asked Nubi.

“Many,” admitted the visiting programmer. “But only a fool would spend the time to do that when so many more worthy tasks await him.”

“And who better understands the Unix-nature?” Master Foo asked. “Is it he who writes the ten thousand lines, or he who, perceiving the emptiness of the task, gains merit by not coding?”

Upon hearing this, the programmer was enlightened.

Adapted from: http://www.catb.org/~esr/writings/unix-koans/ten-thousand.ht...

Re: 93% of Paint Splatters Are Valid Perl Programs (2019)

#128

Earlier quoted context omitted.

Honest question. When did: use strict; Become more commonplace usage?

It started around two decades ago, but I would say the "use strict if at all possible or you're doing it wrong" consensus was reached at least as long ago as 2005, being conservative. Because backwards compatibility was always seen as paramount, it never became default , but if you opted into new version features by version number[1], those advanced to enabled both new features and to turn off or warn on use of what…

Thanks for that answer, very interesting to know as someone who feels like they got into perl pretty late in the game. I do appreciate it where it works for sure.

I could definitely picture programming in perl in the 90s before people commonly implemented use strict; being a complete hellscape though

Re: 93% of Paint Splatters Are Valid Perl Programs (2019)

#129

Earlier quoted context omitted.

Perl is cool but it's got a hell of a lot of cryptic operators for its syntax. They make sense after you learn them but for beginners it's clear why python gets picked up way easier. They're not having to think in symbols and stuff, it just looks more like a list of instructions rather than a mess of dollar signs and 'my' (my what? just not retrospectively intuitive...) That said I like perl (And lately, awk/sed) a l…

> Plus for systems-level scripts I still tend to use it for that.

Conversely, there's also so many things you can do in a perl (or awk/sed if performance or avoiding malloc by streaming data is necessary) oneliner in a shell script if you know some cool tricks. It's crazy how many resources are thrown into stuff like hadoop (literal ironic elephant logo) clusters to process CSV when dinky tools older than I am can zip through that data 1000x faster just by keeping it in the processor cache on my laptop

https://learnbyexample.github.io/learn_perl_oneliners/cover....

Re: 93% of Paint Splatters Are Valid Perl Programs (2019)

#130
post #45

Earlier quoted context omitted.

Booking.com also

tbh, I'm still sad that Python won against Perl during the heyday. Perl was and is still a fun language.

In my heart, Perl has won a long time ago. Python is nice and all, but it's too much of a jack of all trades language, that doesn't neither suck nor shine at anything.

Also, the fact you can write a Perl script, run it everywhere and just not concern yourself with versioning and stuff is beautiful. If one of my .sh script gets over 40 lines, it becomes a .pl file, that's the rule.

Post reply on HN