Download - There Is No JavaScript
![Page 1: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/1.jpg)
There Is No JavaScript
Noam KfirSenior Architect, Sela Group
http://noam.kfir.cc@NoamKfir
![Page 2: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/2.jpg)
A Brief History of JavaScript
![Page 3: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/3.jpg)
The Bubbling Pool
Brendan Eich hacked JavaScript together in ten days
![Page 4: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/4.jpg)
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
![Page 5: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/5.jpg)
The Mesozoic Lair
John Resig raised JavaScript out of the swamp
![Page 6: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/6.jpg)
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!
![Page 7: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/7.jpg)
And Then Things Got Weird
![Page 8: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/8.jpg)
But First, A Little Exercise!
Yes, we’re going to get physical…
![Page 9: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/9.jpg)
Nod Your Head
if you use JavaScript
![Page 10: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/10.jpg)
Clap Your Hands
if you love JavaScript
![Page 11: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/11.jpg)
Pound Your Feet
if you hate JavaScript
![Page 12: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/12.jpg)
Real Programmers Multi-Task
Use it. Love it. Hate it.
Nod. Clap. Pound.
But why?
![Page 13: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/13.jpg)
Let’s Ask Expert!
Douglas Crockford, 2001
“JavaScript is the world’s most
misunderstood programming language.”
The
![Page 14: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/14.jpg)
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?
![Page 15: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/15.jpg)
But Not Anymore
• Crockford was right, but things have changed• JavaScript is no longer misunderstood
• So the question remains… Why?
![Page 16: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/16.jpg)
Typology
![Page 17: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/17.jpg)
Dynamic?
Yes
![Page 18: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/18.jpg)
Weakly Typed?
Yup
Except it also has a few strong types
![Page 19: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/19.jpg)
Compiled?
Of course not
Except that all major JavaScript engines perform JIT (and AOT?) compilation todayOr maybe even grunt and gulp and webpack?
![Page 20: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/20.jpg)
Interpreted?
Definitely!
Actually, interpreted semanticsWhich change under strict modeAnd again for ES6
![Page 21: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/21.jpg)
Functional?
Yes… high-order functionsAnd no… side effects and immutable semantics
Unless ES5: filter, map, reduce, some, defineProperty…Or ES6: consts, arrow functions, destructuring, generators…Or ES7: async, observe…
![Page 22: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/22.jpg)
Inheritance?
Absolutely, but it’s weird
Prototypes, not classesExcept in ES6, where classes are actually prototypesOr the gazillion logical class implementations, which are mostly abstractions for prototypes or glorified mixins
![Page 23: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/23.jpg)
Modules?
Nope, not really
Unless you use specific design patternsOr hacks, like immediate functionsOr a framework that rolls its own, like AngularOr AMD (RequireJS)Or CommonJS (Node.js)Or ES6 modules
![Page 24: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/24.jpg)
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
![Page 25: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/25.jpg)
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
![Page 26: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/26.jpg)
WTF?!!!!
JavaScript is no longer misunderstood…But it is confusing
JavaScript is a buffet!
![Page 27: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/27.jpg)
Coping Strategies
![Page 28: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/28.jpg)
The Ostrich
Ignore JavaScript“We don’t need no stinkin’
JavaScript!”
• Go native• Or stick to the server• … And curse Brendan Eich
![Page 29: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/29.jpg)
The Chameleon
Hide JavaScript“the assembly language of the web”
• JavaScript is ugly• So compile familiar
languages “down”• Or invent “prettier”
languages to transpile
![Page 30: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/30.jpg)
The Phoenix
Reinvent JavaScript“The king is dead. Long live the king.”
• Improve JavaScript gradually• Or drastically• Or create a “better” superset
![Page 31: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/31.jpg)
The Kangaroo
Skip Over JavaScript“cut out the middleman”
• Use an alternative in the browser(like Dart or VBScript)• Or go binary (with WebAssembly)
![Page 32: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/32.jpg)
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’sall documented
![Page 33: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/33.jpg)
Coping Strategies
• The Ostrich: ignore JavaScript• The Chameleon: hide JavaScript• The Phoenix: reinvent JavaScript• The Kangaroo: skip over JavaScript• The Dinosaur: stop changing JavaScript
![Page 34: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/34.jpg)
There Seems to Be a PatternAnd it’s not the animals
![Page 35: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/35.jpg)
Hint #1 – The Environment
In which environments does your JavaScript run?
• In the browser?• On the server?• In the database?• On some device?
• Everywhere?
![Page 36: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/36.jpg)
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?
![Page 37: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/37.jpg)
Hint #3 – The Language
Which JavaScript do you actually use?
• ES3?• ES5?• ES6?
• Some other version?• Do you even know?
![Page 38: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/38.jpg)
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?
![Page 39: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/39.jpg)
The Problem
• JavaScript is ubiquitous, flexible, feature-rich, expressive and popular
• But it is also very confusing andsuffering from an identity crisis
![Page 40: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/40.jpg)
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
![Page 41: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/41.jpg)
Has JavaScript Peaked?
• JavaScript does not seem to be slowing down
• But neither is the fragmentation
• These are opposing trends
![Page 42: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/42.jpg)
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
![Page 43: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/43.jpg)
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
![Page 44: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/44.jpg)
Looking Forward
• JavaScript is constantly shootingout 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
![Page 45: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/45.jpg)
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.
![Page 46: There Is No JavaScript](https://reader036.vdocuments.us/reader036/viewer/2022062902/58ee12251a28ab747f8b45df/html5/thumbnails/46.jpg)
Thank You
Noam KfirSenior Architect, Sela Group
http://noam.kfir.cc@NoamKfir