I gave this talk at the code.talks 2015 conference in Hamburg, Germany: https://www.codetalks.de/2015/programm/there-is-no-javascript.
JavaScript is a truly bizarre language: at once interpreted and compiled, functional and mutative, prototypal and syntactically poor, chaotic and elegant. It is the lowest high-level language of the amorphous operating system known as the web. It has evolved rapidly, sidelining all competition and building up a huge ecosystem of libraries and tools and symbiotic users.
And yet, its very popularity is bringing about its demise, whether by the introduction of the low-level WebAssembly or innumerable higher-level languages or even the reimagined ECMAScript 6 and other descendants. In this talk, we will explore JavaScript's evolution from a mere amoeba in Brendan Eich's bubbling pool to a dinosaur in John Resig's slightly more recent Mesozoic lair and all the way to its inevitable disappearance into civilized ubiquity.
4. The First Decade Happened
• JavaScript was handed to a committee
• The browsers went to war
• A bunch of languages fought and JavaScript
won
• The web got big
6. The Second Decade Happened
• IE6 died a slow painful death
• We got standards and frameworks and tools
• JavaScript spread to Node.js and MongoDB and
Johnny Five!
13. Let’s Ask Expert!
Douglas Crockford, 2001
“JavaScript is the world’s
most misunderstood
programming language.”
The
14. Most Misunderstood
• the name carries misleading implications
• typecasting and lisp in c’s clothing
• moving target and design errors
• amateurs and lousy implementations
• bad books and a substandard standard
• not really object-oriented?
15. But Not Anymore
• Crockford was right, but things have changed
• JavaScript is no longer misunderstood
• So the question remains… Why?
19. Compiled?
Of course not
Except that all major JavaScript engines
perform JIT (and AOT?) compilation today
Or maybe even grunt and gulp and webpack?
21. Functional?
Yes… high-order functions
And no… side effects and immutable semantics
Unless ES5: filter, map, reduce, some,
defineProperty…
Or ES6: consts, arrow functions, destructuring,
generators…
Or ES7: async, observe…
22. Inheritance?
Absolutely, but it’s weird
Prototypes, not classes
Except in ES6, where classes are actually
prototypes
Or the gazillion logical class implementations,
which are mostly abstractions for prototypes or
glorified mixins
23. Modules?
Nope, not really
Unless you use specific design patterns
Or hacks, like immediate functions
Or a framework that rolls its own, like Angular
Or AMD (RequireJS)
Or CommonJS (Node.js)
Or ES6 modules
24. Expressive?
It really depends on who you ask
But before jQuery showed us the way, most
programmers did not see it as expressive or use
it that way
25. So JavaScript Is…
• Clearly dynamic
• Mostly weakly typed
• Kind of interpreted yet also compiled
• Trending toward but not quite functional
• Inherently mixed up about inheritance
• Inconsistently modular
• Subjectively expressive
28. The Ostrich
Ignore JavaScript
“We don’t need no stinkin’ JavaScript!”
• Go native
• Or stick to the server
• … And curse Brendan Eich
29. The Chameleon
Hide JavaScript
“the assembly language of the web”
• JavaScript is ugly
• So compile familiar
languages “down”
• Or invent “prettier”
languages to transpile
30. The Phoenix
Reinvent JavaScript
“The king is dead. Long live the king.”
• Improve JavaScript gradually
• Or drastically
• Or create a “better” superset
31. The Kangaroo
Skip Over JavaScript
“cut out the middleman”
• Use an alternative in the browser
(like Dart or VBScript)
• Or go binary (with WebAssembly)
32. The Dinosaur
Stop Changing JavaScript
“Why ruin a good thing?”
• It works, leave it alone
• The advantage of living
in the past is that it’s
all documented
33. Coping Strategies
• The Ostrich: ignore JavaScript
• The Chameleon: hide JavaScript
• The Phoenix: reinvent JavaScript
• The Kangaroo: skip over JavaScript
• The Dinosaur: stop changing JavaScript
35. Hint #1 – The Environment
In which environments does your JavaScript run?
• In the browser?
• On the server?
• In the database?
• On some device?
• Everywhere?
36. Hint #2 – The Ecosystem
What language do you use to write your code?
• JavaScript all the way!
• CoffeeScript?
• TypeScript or Flow?
• C# or Java?
• Anything but JavaScript?
37. Hint #3 – The Language
Which JavaScript do you actually use?
• ES3?
• ES5?
• ES6?
• Some other version?
• Do you even know?
38. Hint #4 – The Style
Do you have a preferred programming style?
• More functional?
• More object-oriented?
• Whatever the framework prescribes?
• Whatever gets the job done?
• What are you talking about?
39. The Problem
• JavaScript is ubiquitous, flexible, feature-rich,
expressive and popular
• But it is also very confusing and
suffering from an identity crisis
40. Converging and Diverging
• JavaScript engines are finally converging and
are achieving remarkable feature parity,
implying eventual consistency across tools,
platforms and ecosystems
• But the tools, platforms and ecosystems are
actually diverging, despite expectations
• These are opposing trends
41. Has JavaScript Peaked?
• JavaScript does not seem to be slowing down
• But neither is the fragmentation
• These are opposing trends
42. JavaScript Has Evolved
• JavaScript’s design has been influenced by
many factors and contradictory goals:
• open source
• competing browsers
• a changing web
• maturation of the industry
• etc.
• They have caused fragmentation
• But ironically, they have also contributed to its
evolution and survival
43. JavaScript Is Inherently Adaptive
• The key to its survival is its adaptability
• Its ubiquity and strange typology are
evolutionary byproducts
• Change is part of its DNA
• The language will continue to evolve
44. Looking Forward
• JavaScript is constantly shooting
out in new directions
• It will hopefully never stabilize
• Stabilization will be its death knell
• Change makes our lives difficult
• In the long run, it’s a necessity
45. There Is No Spoon
• Do not try and bend the spoon. That’s
impossible. Instead, only try and realize the
truth.
• What truth?
• There is no spoon.
• There is no spoon?
• Then you’ll see that it is not the spoon that
bends, it is only yourself.
A Short History of JavaScript on w3c.org
https://www.w3.org/community/webed/wiki/A_Short_History_of_JavaScript
JavaScript was basically supposed to be a performance optimization.
Exciting times…
Does anybody cares about the programmers?
History - highlights:
- browser wars - inconsistencies, standards
- ActionScript extended JS
- JScript bit the bullet
- VBScript bit the bullet
- DHTML gave us full access to the DOM
- jQuery rewired our brains
- Object.create()
Only about 150 million internet years ago…
jQuery:
- unified browsers
- made Ajax easy
- made JavaScript elegant and professional
- solved tons of problems
“JQuery is used by 95.5% of all the websites whose JavaScript library we know. This is 65.9% of all websites.”
http://w3techs.com/technologies/details/js-jquery/all/all
The server, and the database, and Arduino microchip controllers.
I want to talk about the current state of JavaScript and where it’s heading.
I won’t ask you to stand up, unless…
Or shake it. Whatever.
Don’t be shy…
1. There’s no shame in it.
2. And nobody can you see your feet.
Nod you hands, clap your feet, pound your heads.
A bit old, but surprisingly some of it is still relevant today!
- moving target and design errors: bad choices, outdated opinions, too many versions
- object-oriented: encapuslation, inheritance, prototypes?
Sections:
- the name
- lisp in c’s clothing
- moving target
- design errors
- lousy implementations
- substandard standard
- amateurs
- object-oriented
A typological analysis is quite revealing.
JavaScript today is more confusing than ever!
Some strong types:
* Int8Array, also 16 and 32
* Uint8Array, also 16 and 32
* Float32Array, also 64
strict mode:
- no implied global variables in functions
- no with statement
- no octal literals
- restrictions on eval
- setting a writeable: false property will throw
- deleting a configurable: false property will throw
- apply and call do not default to the global object
- “this” not bound to the global object by function form
- eval and arguments are reserved
- arguments not linked to parameters
- no more arguments.caller or arguments.callee
- duplicate names in an object literal or function parameters are a syntax error
based on: https://gist.github.com/sym3tri/2425983
immediate functions
- self-executing functions
- immediately invoked function expressions (IIFEs)
ES6 vs. Node.js modules
- ES6 import vs. CJS require
- CJS can load modules dynamically
- ES6 can be synd or async, CJS is never async
… I know I’m confused.
Obviously, the language was designed by committee…
Buffet – smorgasbord – has a bit of everything and you get to choose what you want.
They’ll even write Objective-C!
Or maybe just stop programming…
There are hundreds of languages that compile to JavaScript! It’s almost like they don’t like the language…
Assembly is always just the lowest layer. But JavaScript can be any layer. It really depends on your approach.
- http://www.slant.co/topics/101/~what-are-the-best-languages-that-compile-to-javascript
- https://github.com/jashkenas/coffeescript/wiki/list-of-languages-that-compile-to-js
- compile down:
- C#: Script# and DuoCode
- Java: GWT and Vaadin
- Clojure: ClojureScript
- Ruby: Opal
- F#: FunScript
- Python: pyjamas
- transpile:
- CoffeeScript
- Dart
- Haxe (maybe)
emscripten talk:
http://kripken.github.io/mloc_emscripten_talk/#/5
Phoenixes believe that JavaScript is not “just” the assemble language of the web. It is layer-agnostic.
- Gradually improve JavaScript:
- strict mode
- property attributes
- new library functions
- Drastically change JavaScript
- ES6 and ES7: new keywords, operators and semantics)
- Create “better” supersets
- Flow
- TypeScript
- specific alternatives: Dart and VBScript
- go binary: WebAssembly and asm.js
Assembly as the assembly language of the web, except it’s not really an assembly language.
Brendan Eich: “we are aiming to develop the Web’s polyglot-programming-language object-file format”
https://brendaneich.com/2015/06/from-asm-js-to-webassembly/
Big Web App? Compile It! by Alon Zakai / Mozilla
http://kripken.github.io/mloc_emscripten_talk/#/
“Vanilla JavaScript” is good just the way it is
Are the convergence and divergence mutual?
The fragmentation is like a powerful and unstoppable undercurrent.
New directions: experimenting with new technologies, adapting to new platforms and environments
The moral is: as JavaScript changes, so must we.
We have a symbiotic relationship with the language.
Nobody wants to be a dinosaur.