The unholy trinity of #JavaScript

In the interest of full disclosure, here is the same trinity for my beloved #Perl.

Tabs (and any string that can’t be read as a number) are *numerically* equal to 0 and "0" because they don’t have any value in numeric context. If you want string equality or inequality, use eq or ne, respectively: https://perldoc.perl.org/perlop#Equality-Operators

(Boolean context is a separate thing, which is why most defined, non-empty and non-zero values are considered “true.”)

perlop - Perl expressions: operators, precedence, string literals - Perldoc Browser

@mjgardner This is entertainingly baffling to behold, given that in #bash and its ilk (where I write a lot of scripts), -ne and -eq are used for numerical comparison; and == and != are used for string comparison.
@DopeGhoti There are several surprises waiting for those who think of #Perl as “#shell scripting with extras”: https://perldoc.perl.org/perltrap#Shell-Traps
perltrap - Perl traps for the unwary - Perldoc Browser

@mjgardner
I'm sure there are. Most perl incantations I've seen in the past end up looking like a keyboard just lost a fight with a feral cat, but I imagine most of those were highly code-golfed into illegibility. (:
@DopeGhoti Sysadmins and other part-time programmers haven’t historically cared about writing code for others to read because their jobs didn’t require them to read much code that others have written. That’s changed with the whole #DevOps infrastructure-as-code movement; now they’re configuring things in declarative domain-specific languages and favor imperative scripting-level languages with rigid limits on expressivity.
@DopeGhoti Regarding #Perl specifically, I noted a couple years ago that most of the ire is due to a few features that *have* readability affordances that people don’t use enough of: https://phoenixtrap.com/2021/07/20/the-four-noisy-horsemen-of-perl-hate/
The four noisy horsemen of Perl hate—The Phoenix Trap

Do you hate Perl because it looks like noise? Let's decipher some of the language's quirks and the ways they can and should be better.

@mjgardner

So symmetrical, yet so insane.

@mjgardner smart quotes == pain
@malwareminigun If you are trying to copy and execute code from a shitposting graphic then you have problems I can’t fix
@mjgardner Who said anything about copy paste?
@malwareminigun Not me—I only said “copy.” That includes eyeball-and-type
@malwareminigun @mjgardner PowerShell "solved" this problem by explicitly supporting smart quotes…
@jernej__s @mjgardner Unfortunately even if PowerShell supports them, my eyes bleed upon viewing them 😅😵‍💫
@malwareminigun @mjgardner Maybe I should've said „solved“ :)

@jernej__s @malwareminigun / \p{Quotation_Mark} solved \p{Quotation_Mark} /x #Perl #regex

(Note that doesn’t work with software using the #PCRE Perl “Compatible” #RegularExpression library because its #Unicode support is worse: https://www.pcre.org/current/doc/html/pcre2unicode.html#:~:text=Only%20the%20short%20names%20for%20properties%20are%20supported)

pcre2unicode specification

@mjgardner @jernej__s Unfortunately my 👀 don't implement full perl regexes either 😅
@malwareminigun @jernej__s #Perl has readability affordances for #regexes that nothing else can touch: https://perldoc.perl.org/perlre#%2Fx-and-%2Fxx
perlre - Perl regular expressions - Perldoc Browser

I wonder why mathematicians haven't picked up enochian glyphs yet.

@cstross
@mjgardner

@RefurioAnachro @cstross @mjgardner

Well that's something new that I've just learned. Thanks.

https://en.m.wikipedia.org/wiki/Enochian

Enochian - Wikipedia

Fun indeed, right? I got the tip from the incredible @cstross's fabulous Laundry Files series, in which he mixes maths, occultism and commentary on organizational structures into one delightful reading experience, which I may be enjoying much more than I probay should. Oh, and lovecraftian horrors, because of course that's what happens, if you toss all of the above in one hot cauldron.

@mjgardner
@jgamble

@mjgardner
The unholy trinity, with four items in it.
@robertpi It is a reference to the Scutum Fidei symbol of Christianity: https://en.wikipedia.org/wiki/Shield_of_the_Trinity
Shield of the Trinity - Wikipedia

@mjgardner
I did not know that.

But it doesn't really surprise me that theologians have off by one errors too.

@mjgardner why the fuck does '\t' == 0 😮
@scott @mjgardner I guess any white space cast to a number is zero? This is probably to make numerical form validation easier, but it seems like a terrible idea.
@mjgardner @StefanRoock What an absurd language. Can’t believe, that JavaScript is the bedrock of the whole internet now.
@mjgardner this is the real Triangle Of Pain, no matter what a urologist might say

@mjgardner

If we could make a rock-paper-scissors version of that graph, which way would the arrows run?

@mjgardner seems like JavaScript is a religion! /j
@mjgardner The "flux capacitor" of JavaScript
Mark Gardner ‍:sdf: (@[email protected])

Attached: 1 image · Content warning: religion

SDF Social

@mjgardner

The Javascript people were playing hooky when equivalence relations were taught in second year discrete mathematics.

If [] == 0 is true, and 0 == "\t" is true, but [] == "\t" is not true, the == operator isn't a form of equivalence. It is missing the transitive property.

@Kazinator The “#JavaScript people” was one guy, @BrendanEich, and he had ten days and a marketing mandate that it look like #Java’s baby brother for non-programmers: https://thenewstack.io/brendan-eich-on-creating-javascript-in-10-days-and-what-hed-do-differently-today/
Brendan Eich on Creating JavaScript in 10 Days, and What He'd Do Differently Today

Millions of developers use a programming language today that was created in just 10 days during the hustle and bustle

The New Stack

@mjgardner @BrendanEich

Is that when the "unholy trinity" was cemented in place already?

Brendan Eich on Creating JavaScript in 10 Days, and What He'd Do Differently Today

Millions of developers use a programming language today that was created in just 10 days during the hustle and bustle

The New Stack
@mjgardner this elder rune reduced me to a gibbering madman.
@mjgardner look. Just because brackets is-a zero and whitespace is-a zero doesn't mean that brackets is-a whitespace, ya dig? You just need to call static_cast.
@jmjm I think you got your C++ peanut butter in my JavaScript chocolate
@mjgardner I need to get that tattooed somewhere
@mjgardner babe wake up, javascript is a uterus just dropped.
@ajkandy That’s a different Abrahamic religious reference: https://en.wikipedia.org/wiki/Tree_of_life_(Kabbalah)
Tree of life (Kabbalah) - Wikipedia

@mjgardner I know. It’s from the anime Neon Genesis Evangelion
@mjgardner So basically you can make the Flux Capacitor with JavaScript. https://backtothefuture.fandom.com/wiki/Flux_capacitor
Flux capacitor

This is what makes time travel possible.Doc Brown Leaning inside the DeLorean, Doc Brown pointed to a particular centerpiece unit. "Get a picture of this on tape," he said. / Marty pointed the camera at the strange-looking object. Moving his head next to it so that he could be seen on camera and describe its workings at the same time, Doc Brown continued in his professional tone. "This is what makes time travel possible — the flux capacitor." / "Flux capacitor, huh?" Marty repeated. "Is that its

Futurepedia
@jaycruz Gonna need to take the DeLorean a little farther back for the reference: https://social.sdf.org/@mjgardner/110548513677273322
Mark Gardner ‍:sdf: (@[email protected])

Attached: 1 image · Content warning: religion

SDF Social