JavaScript Runs the World—Maybe Even Literally

Trending 1 month ago

Lex Fridman has done galore agelong interviews connected his celebrated podcast. Even so, nan section pinch nan legendary programmer John Carmack has an unhinged director’s-cut consciousness to it. Over 5 hours, Carmack dishes connected everything from vector operations to Doom. But it’s thing Fridman says, offhand, that really justifies nan extended tally time: “I deliberation that if we’re surviving in a simulation, it’s written successful JavaScript.”

To review: JavaScript is what makes fixed web pages “dynamic.” Without it, nan net would lucifer thing truthful overmuch arsenic an after-hours arcade, lifeless and dark. These days, nan connection is utilized successful some front- and backend improvement for a full big of mobile platforms and apps, including Slack and Discord. And nan main point to understand astir it, successful nan discourse of Fridman’s nerdy koan, is this: For immoderate self-respecting programmer, admitting to really liking JavaScript is thing of a faux pas—much for illustration an art-house filmmaker confessing to Marvel fandom.

I suppose this has thing to do pinch nan truth that JavaScript was created successful little clip than it takes to home-brew a jar of kombucha: 10 days. In 1995, Netscape hired a programmer named Brendan Eich to create a connection to embed successful its browser, Netscape Navigator. Originally called LiveScript, nan connection was renamed JavaScript to piggyback connected nan hype astir an unrelated connection called Java, which had been introduced earlier that year. (Asked nan quality betwixt Java and JavaScript, a programmer is apt to joke: “Java is to JavaScript what car is to carpet.”) To this day, fewer group see JavaScript a peculiarly well-designed language, slightest of each Eich. “I perpetrated JavaScript successful 1995,” he erstwhile said, “and I’ve been making up for it ever since.”

What was his crime, exactly? You tin easy find scads of blog posts, memes, and Reddit threads sandbagging JavaScript, but my favourite is simply a four-minute talk by package technologist Gary Bernhardt titled “Wat.” Imagine, for starters, showing a group of non-English speakers nan coming and past forms of verbs for illustration boil (boil/boiled) and chew (chew/chewed). Then, erstwhile you inquire them for nan conjugation of eat, who could blasted them for answering eat/eated? Similarly, nan “Wat” talk is simply a blooper reel of JavaScript’s quirks and unpredictable behaviors. Let’s opportunity you want to benignant a database of numbers: [50, 100, 1, 10, 9, 5]. Calling nan built-in benignant usability successful immoderate sane connection returns nan database successful numerically ascending order: [1, 5, 9, 10, 50, 100]. Doing truthful successful JavaScript returns [1, 10, 100, 5, 50, 9], wherever 10 and 100 are considered larger than 5. Why? Because JavaScript interprets each number arsenic a drawstring type and does lexical sorting, not numerical sorting. Total insanity.

When Fridman says JavaScript runs nan world, successful different words, what he intends is that our world is, for illustration nan underlying root code, massively screwed up and incomprehensible. It’s nan balanced of pronouncing, pinch a sigh, that considering nan sorry authorities of nan planet, nan Universal Declaration of Human Rights must person been written successful Comic Sans.

At this point, I should confess that while JavaScript is not my favourite language, I for illustration it. Adore it, successful fact. So I can’t thief but consciousness a flare of disapproval whenever a definite fraternity of programmers polemicizes against it. Often they attraction connected flaws that were dealt pinch years ago. To dwell connected JavaScript’s original shortcomings is to place nan truth that immoderate portion of software—and each programming connection is, successful essence, a suite of software—is amenable to revision and improvement.