46
There Is No JavaScript am Kfir nior Architect, Sela Group http://noam.kfir.cc @NoamKfir

Noam Kfir - There is no Java Script - code.talks 2015

Embed Size (px)

Citation preview

Page 1: Noam Kfir - There is no Java Script - code.talks 2015

There Is No JavaScript

Noam KfirSenior Architect, Sela Group

http://noam.kfir.cc@NoamKfir

Page 2: Noam Kfir - There is no Java Script - code.talks 2015

A Brief History of JavaScript

Page 3: Noam Kfir - There is no Java Script - code.talks 2015

The Bubbling Pool

Brendan Eich hacked JavaScript together in ten days

Page 4: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

The Mesozoic Lair

John Resig raised JavaScript out of the swamp

Page 6: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

And Then Things Got Weird

Page 8: Noam Kfir - There is no Java Script - code.talks 2015

But First, A Little Exercise!

Yes, we’re going to get physical…

Page 9: Noam Kfir - There is no Java Script - code.talks 2015

Nod Your Head

if you use JavaScript

Page 10: Noam Kfir - There is no Java Script - code.talks 2015

Clap Your Hands

if you love JavaScript

Page 11: Noam Kfir - There is no Java Script - code.talks 2015

Pound Your Feet

if you hate JavaScript

Page 12: Noam Kfir - There is no Java Script - code.talks 2015

Real Programmers Multi-Task

Use it. Love it. Hate it.

Nod. Clap. Pound.

But why?

Page 13: Noam Kfir - There is no Java Script - code.talks 2015

Let’s Ask Expert!

Douglas Crockford, 2001

“JavaScript is the world’s most

misunderstood programming language.”

The

Page 14: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

But Not Anymore

• Crockford was right, but things have changed• JavaScript is no longer misunderstood

• So the question remains… Why?

Page 16: Noam Kfir - There is no Java Script - code.talks 2015

Typology

Page 17: Noam Kfir - There is no Java Script - code.talks 2015

Dynamic?

Yes

Page 18: Noam Kfir - There is no Java Script - code.talks 2015

Weakly Typed?

Yup

Except it also has a few strong types

Page 19: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

Interpreted?

Definitely!

Actually, interpreted semanticsWhich change under strict modeAnd again for ES6

Page 21: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

WTF?!!!!

JavaScript is no longer misunderstood…But it is confusing

JavaScript is a buffet!

Page 27: Noam Kfir - There is no Java Script - code.talks 2015

Coping Strategies

Page 28: Noam Kfir - There is no Java Script - code.talks 2015

The Ostrich

Ignore JavaScript“We don’t need no stinkin’

JavaScript!”

• Go native• Or stick to the server• … And curse Brendan Eich

Page 29: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

The Phoenix

Reinvent JavaScript“The king is dead. Long live the king.”

• Improve JavaScript gradually• Or drastically• Or create a “better” superset

Page 31: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

There Seems to Be a PatternAnd it’s not the animals

Page 35: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

Hint #3 – The Language

Which JavaScript do you actually use?

• ES3?• ES5?• ES6?

• Some other version?• Do you even know?

Page 38: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

The Problem

• JavaScript is ubiquitous, flexible, feature-rich, expressive and popular

• But it is also very confusing andsuffering from an identity crisis

Page 40: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

Has JavaScript Peaked?

• JavaScript does not seem to be slowing down

• But neither is the fragmentation

• These are opposing trends

Page 42: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

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: Noam Kfir - There is no Java Script - code.talks 2015

Thank You

Noam KfirSenior Architect, Sela Group

http://noam.kfir.cc@NoamKfir