Part II: The Web

Chapter 07

#The Web: waking up the words

https://en.wikipedia.org/wiki/Netscape_Navigator It's May 1995. You've just landed a dream job at the hot new startup of the decade: Netscape. You want to impress. The gurus in charge ask you to add a programming language to the Web. https://en.wikipedia.org/wiki/Netscape_Navigator

You have 10 days.

Brendan Eich JavaScript Brendan Eich was the wizard who made JavaScript under these conditions. Its creation story is almost mythical. https://en.wikipedia.org/wiki/Brendan_Eich

https://en.wikipedia.org/wiki/Common_Gateway_Interface Before JavaScript, the only way to make a website interactive was a form. A visitor filled it in and pressed submit. The browser sent the data to the web server, which called a program through the CGI interface. The program did its magic and printed a response, and the server sent that back as a whole new page. Not very interactive at all. https://en.wikipedia.org/wiki/Common_Gateway_Interface

https://en.wikipedia.org/wiki/Internet_Explorer_1 In 1995 Netscape was king of the browser hill. Internet Explorer 1.0 would only appear in August of that year, and wouldn't get any real traction until version 4, in 1997. Netscape had set its sights on making the web browser the next operating system. Instead of software shipped on floppy disks and CD-ROMs, they saw a future where software ran in the network, and all you needed was a connection and a browser. Netscape Navigator, of course. https://en.wikipedia.org/wiki/Internet_Explorer_1

https://en.wikipedia.org/wiki/Java_%28programming_language%29 For that, the Web would need to be programmable. So Netscape set out a two-pronged strategy. Real™ programmers would use a Real™ programming language to write Real™ programs. The rest of us could glue these together in a scripting language. The Real™ programming language of choice, in 1995, was of course Java™. So the scripting language would have to look like Java. https://en.wikipedia.org/wiki/Java_%28programming_language%29

https://en.wikipedia.org/wiki/Java_virtual_machine Why Java isn't hard to see. There were still many different computer architectures in use, and writing software that ran on all of them was hard. Java sidestepped that problem with the JVM, the Java Virtual Machine, and promised: write once, run anywhere. Using anything other than Java would have made the whole plan almost impossible. https://en.wikipedia.org/wiki/Java_virtual_machine

Enter Brendan Eich. As he later described it:

"At least client engineering management including Tom Paquin, Michael Toy, and Rick Schell, along with some guy named Marc Andreessen, were convinced that Netscape should embed a programming language, in source form, in HTML." — "What was needed was a convincing proof of concept, AKA a demo. That, I delivered, and in too-short order it was a fait accompli."

That prototype became the programming language of the Web.

https://en.wikipedia.org/wiki/Scheme_%28programming_language%29 We got uncharacteristically lucky. JavaScript was not a watered-down, dummified version of Java. Brendan had been lured to Netscape with the promise that he could build a Scheme-like language. https://en.wikipedia.org/wiki/Scheme_%28programming_language%29

Scheme is a descendant of Lisp (and Algol). It is nothing like Java. But like any Lisp-like language, it can be changed to do anything any other programming language can do. So Brendan put a Java-like syntax on a Scheme-like core. And 10 days later, the world would be changed forever.

https://web.archive.org/web/20200204010840/https://brendaneich.com/2008/04/popularity/ Brendan Eich - "I’m not proud, but I’m happy that I chose Scheme-ish first-class functions and Self-ish (albeit singular) prototypes as the main ingredients. The Java influences, especially y2k Date bugs but also the primitive vs. object distinction (e.g., string vs. String), were unfortunate." https://web.archive.org/web/20200204010840/https://brendaneich.com/2008/04/popularity/

https://en.wikipedia.org/wiki/Self_%28programming_language%29 https://en.wikipedia.org/wiki/Smalltalk Like any prototype pushed into production too soon, JavaScript has its problems. But its roots in Scheme and Self, themselves descendants of Lisp and Smalltalk, gave it a much healthier base than we could have hoped for. https://en.wikipedia.org/wiki/Self_%28programming_language%29 https://en.wikipedia.org/wiki/Smalltalk

Douglas Crockford The Good Parts In 2008 JavaScript finally got some good press, in the form of a book by the wizard Douglas Crockford: JavaScript: The Good Parts. Clearly the good parts derive from Scheme and Self. https://en.wikipedia.org/wiki/Douglas_Crockford

#Toil and trouble

https://www.youtube.com/watch?v=Y2Y0U-2qJMs https://jquery.com/ Today it is hard not to associate JavaScript with the DOM, the Document Object Model we met in the previous chapter. That is not fair to JavaScript. The DOM may be the worst API ever invented. It was so bad that there came to be not one, not a few, but countless DOM wrapper libraries. I wrote my own, as did many web developers of the era. In the end there was a clear winner, jQuery, which was then folded back into the browser in a weirdly distorted way. $(".class") became document.querySelectorAll(".class") because long names are the hallmark of committee standards. https://www.youtube.com/watch?v=Y2Y0U-2qJMs https://jquery.com/

https://react.dev/ https://vuejs.org/ https://angular.dev/ https://svelte.dev/ https://emberjs.com/ Even so, the DOM is mostly treated as a compilation target: not something you program directly, unless you are a masochist. Instead you use React, Vue, Angular, Svelte, Ember... https://react.dev/ https://vuejs.org/ https://angular.dev/ https://svelte.dev/ https://emberjs.com/

https://www.npmjs.com/ https://babeljs.io/ Even JavaScript itself is often processed before the browser sees it. For years that meant npm, bundlers, transpilers and configuration files. Babel compiled JavaScript into JavaScript. https://www.npmjs.com/ https://babeljs.io/

The result: bundled, minified, obfuscated and unreadable JavaScript.

All this makes web development much harder than it needs to be. It is the real fallout from rushing JavaScript into production in 1995. The language was so incomplete that wizards all over the world invented their own additions.

Take modules. For the longest time, JavaScript had none. In the browser you could fake them with a pile of HTML script tags, working around the language rather than in it. Or you could use a bundler to glue all the code into a single file. So we ended up with several module formats and several bundlers, each with its own configuration.

https://nodejs.org/ There is a standard module system now. But much of what we install from npm still uses the older format designed for Node, JavaScript on the server. https://nodejs.org/

#The browser-shaped computer

Netscape's dream did not happen quite the way Netscape imagined. We did not all simply stop using operating systems and live inside Navigator.

Yet a lot of what people now call "using the computer" is really using the browser. Mail, documents, calendars, maps, banking... I could go on. The local machine is still there, but it matters less and less. It has become an interface—a keyboard, mouse and screen that give you access to your work instead of holding it.

https://chromeos.google/ ChromeOS makes that idea unusually explicit. It is an operating system built around the assumption that the web is not just one application among many. The web is the main place where things happen. https://chromeos.google/

https://electronjs.org/docs/latest Electron approaches the same idea from the other direction. If people still expect desktop applications, fine. Put a browser-shaped runtime inside the application and let web technologies pretend to be native software. This is a ridiculous thing to do, and also a very successful one. Not an unusual combination in software history. https://electronjs.org/docs/latest

https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps Progressive Web Apps sit somewhere in the middle. They try to let web applications behave a bit more like installed software, with icons, offline behavior and notifications, without fully leaving the web behind. https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps

None of these has replaced the operating system. We still live in an Apple and Windows world, with a sprinkling of Linux in between. But more and more of what an operating system used to do is moving to the Web. Not always in the way we'd like.

Netscape wanted the browser to become the operating system, and in many ways it did. The network is becoming the OS. The question is whether this new OS serves you, or someone else.