there is no javascript

Post on 12-Apr-2017

319 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

There Is No JavaScript

Noam KfirSenior Architect, Sela Group

http://noam.kfir.cc@NoamKfir

A Brief History of JavaScript

The Bubbling Pool

Brendan Eich hacked JavaScript together in ten days

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

The Mesozoic Lair

John Resig raised JavaScript out of the swamp

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!

And Then Things Got Weird

But First, A Little Exercise!

Yes, we’re going to get physical…

Nod Your Head

if you use JavaScript

Clap Your Hands

if you love JavaScript

Pound Your Feet

if you hate JavaScript

Real Programmers Multi-Task

Use it. Love it. Hate it.

Nod. Clap. Pound.

But why?

Let’s Ask Expert!

Douglas Crockford, 2001

“JavaScript is the world’s most

misunderstood programming language.”

The

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?

But Not Anymore

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

• So the question remains… Why?

Typology

Dynamic?

Yes

Weakly Typed?

Yup

Except it also has a few strong types

Compiled?

Of course not

Except that all major JavaScript engines perform JIT (and AOT?) compilation todayOr maybe even grunt and gulp and webpack?

Interpreted?

Definitely!

Actually, interpreted semanticsWhich change under strict modeAnd again for ES6

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…

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

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

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

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

WTF?!!!!

JavaScript is no longer misunderstood…But it is confusing

JavaScript is a buffet!

Coping Strategies

The Ostrich

Ignore JavaScript“We don’t need no stinkin’

JavaScript!”

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

The Chameleon

Hide JavaScript“the assembly language of the web”

• JavaScript is ugly• So compile familiar

languages “down”• Or invent “prettier”

languages to transpile

The Phoenix

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

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

The Kangaroo

Skip Over JavaScript“cut out the middleman”

• Use an alternative in the browser(like Dart or VBScript)• Or go binary (with WebAssembly)

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

Coping Strategies

• The Ostrich: ignore JavaScript• The Chameleon: hide JavaScript• The Phoenix: reinvent JavaScript• The Kangaroo: skip over JavaScript• The Dinosaur: stop changing JavaScript

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

Hint #1 – The Environment

In which environments does your JavaScript run?

• In the browser?• On the server?• In the database?• On some device?

• Everywhere?

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?

Hint #3 – The Language

Which JavaScript do you actually use?

• ES3?• ES5?• ES6?

• Some other version?• Do you even know?

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?

The Problem

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

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

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

Has JavaScript Peaked?

• JavaScript does not seem to be slowing down

• But neither is the fragmentation

• These are opposing trends

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

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

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

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.

Thank You

Noam KfirSenior Architect, Sela Group

http://noam.kfir.cc@NoamKfir

top related