Culture / Programming Languages

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

26 Aug 2018 6:00am, by

Millions of developers use a programming language today that was created in just 10 days during the hustle and bustle of the dotcom boom. JavaScript creator Brendan Eich revisited the roots of his language in some newly-released online videos, and explained how all the seeds he planted in 1995 are now finally coming to fruition.

1995 was a different era and a different world. At the time Netscape considered the browser/server combination as a new kind of distributed operating system, remembered Computer magazine. Browsers had the potential to let developers reach users on any platform — Windows, Mac, or Linux  — but the missing ingredient was a programming language. What Netscape really wanted was a language to complement Java that would appeal to beginning programmers, just like Microsoft’s Visual Basic.

The whole tech industry was already scrambling to catch up with the surprising popularity of the internet. “Back then, the pace of Web innovation was furious, with Microsoft suddenly making the Internet the focus of its Windows 95 operating system release in response to Netscape’s emerging browser and server products.” So famously, 34-year-old Brendan Eich created that first version of the language that would become JavaScript in just 10 days. (Last year Eich began a talk at the dotJS conference by saying “22 years ago in May I did 10 days of hard work,” adding “I didn’t sleep much.”)

Eich was the right man for the job, the magazine points out because he’d already built programming languages when he was a college student, “just to experiment in syntax.” Eich remembers that when it came to lexical analysis and language parsers. “I loved that stuff, because it was all very pretty and clean, theoretically… What that gave me was the ability to quickly knock out a language interpreter.” Even before joining Netscape, he’d also created languages for building extensions into network monitoring tools at Silicon Graphics. (And in addition, Eich tells his interviewer, “I’d done it for fun, just to make my own languages.”)

In fact, it was the founder of Silicon Graphics, Jim Clark, who’d gone on to found Netscape  — so there was already some interest in Eich’s language-writing skills. “I was invited to join in the beginning, which I didn’t, because I was sticking with a previous startup for another year,” Eich recently told InfoWorld.

Brendan Eich Mozilla Foundation photoBut when Eich finally took that fateful position at Netscape the next year, “I was lured with this idea of doing a very-popular-with-academics language called Scheme… The idea was ‘Come and do Scheme in Netscape. Put this programming language into the browser.'” He later calls Scheme “that beautiful research language I was tempted with.” But by the time he’d joined Netscape, they had a deal with Sun Microsystems, which was now pushing their newly-minted language Java. “And suddenly the story was, ‘Well, we don’t know if we want Scheme. We don’t know if we even need a little language like we wanted you to do. Maybe Java’s enough.'”

It’s a turning point he’ll always remember. Even back in 2012, Eich told Computer magazine that he was being squeezed on two fronts. “We were all feeling like Microsoft was going to come after Netscape, because they had tried to buy Netscape in late ’94… But we also were in a weird game theory with respect to Java, because even at Netscape, some people thought, ‘Well, if we have Java, do we really need a second language?’ They didn’t see the benefit of the Visual Basic companion language for a much larger cohort of programmers or amateurs, designers or beginners.”

“But Marc Andreessen of Netscape, Bill Joy of Sun, and myself and a few others saw that there was a need for a language that was approachable, that you could put directly in the web page,” he tells InfoWorld. Or, as he explained it to Computer, “I was writing something that could be used by people who didn’t know what a compiler was. They were just going to load it.

“It was like Basic. That was really the pitch….”

“I was under marketing orders to make it look like Java but not make it too big for its britches. It’s just this sort of silly little brother language, right? The sidekick to Java.”

What Happened Next

InfoWorld asked how he reacted to its early success. “When it started getting early traction, in spite of all the bugs and rush job aspects, I was a little surprised. But I wasn’t shocked, because on reflection was happened was the people that wrote the web page could now program the web page.”

“What made JavaScript so powerful, with all the warts and rush job properties, was that it was directly connected to all the things in the browser that average web developers wanted to use.” And with Computer magazine, he shares a stark truth: that “once something is released into the wild, bugs or imperfections quickly become essential features and are nearly impossible to change.”

“It was also an incredible rush job, so there were mistakes in it. Something that I think is important about it is that I knew there would be mistakes, and there would be gaps, so I made it very malleable as a language.”

Or, as he told the crowd at dotJS, “It’s just really hard to replace. There’s something like successful DNA about JavaScript. Once it’s in there, you’re going to have a hard time getting rid of it.”

He cites the “discovery” of asm.js inside of JavaScript, calling it “another thing I’m particularly proud of in the last 10 years.” It uses the bitwise operators that were included in the original JavaScript which are now the basis for a statically-typed language with machine types for high-speed performance. “If it hadn’t been in there from 1995, it would’ve been hard to add later. And the fact that it was there all along meant we could do incredibly fast JavaScript.”

He tells InfoWorld it’s “this very potent seed that was in the original JavaScript from the 10 days of May in 1995.” JavaScript’s 32-bit math operators (known as bitwise operators) trace their lineage all the way back to the C programming language — and to Java. This eventually led to WebAssembly — a way to convert instructions into a quickly-executable binary format for virtual machines — and the realization that with a JavaScript engine, “you can have two languages — the old language I did with the curly braces and the functions and the shift operators, and this new language which is a binary language, not meant for reading by humans or writing. But it can be generated by compilers and tools, and can be read by tools…”

What He’d Do Differently

After 23 years of reflection, is there anything he’d do differently? People tell him he should’ve refused to work on such a short schedule — or that he should’ve implemented a different language into Netscape, like Perl or Python or Scheme — but that’s not what he would’ve changed. He just wishes he’d been more selective about which feedback he’d listened to from JavaScript’s first in-house testers.

“One of the notorious ones was, ‘I’d like to compare a number to a string that contains that numeral. And I don’t want to have to change my code to convert the string to a number, or the number to a string. I just want it to work. Can you please make the equals operator just say, Oh this looks like a two, and this looks like a string number two. They’re equal enough.’

Oreilly JavaScript book cove

“And I did it. And that’s a big regret, because that breaks an important mathematical property, the equivalence relation property… It led to the addition of a second kind of equality operator when we standardized JavaScript.” One of the people who helped standardize JavaScript was Guy Steele, one of the co-creators of Scheme. “Guy said, ‘Don’t worry about it. There are Lisps that have five kinds of equals operators. We’ll just add another one.'”

But 23 years put those 10 days in a different perspective. “When you look at what I did in 10 days, it was like a seed. It was this potent kind of compromise, but still very powerful kernel that grew into a bigger language. And part of the challenge — and I’ve been working on the standardization ever since I had to restart the standards body… I had to help people see how to let the seed unfold into a full language.”

Eich is also the co-founder of the Mozilla community (as well as the Mozilla Foundation which develops open source projects like the Firefox web browser). In 2015 he became the CEO of Brave Software, which created an ad-blocking web browser named Brave that now has more than 2.2 million active users each month. It all stems from his interest in privacy, though Eich jokes at the end of the interview that if you trace it all the back to its origins, JavaScript is one of the fundamental pieces that advertisers use for web tracking.

“So I’m making up for it,” he says with a laugh.


WebReduce

Feature image: Brendan Eich at the dotJS conference.

A newsletter digest of the week’s most important stories & analyses.

View / Add Comments

Please stay on topic and be respectful of others. Review our Terms of Use.