why javascript sucks · “javascript's parser does a more efficient job of providing code...

26
Developers Why JavaScript sucks but we still love it! Daniel Kurka Software Engineer

Upload: others

Post on 22-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

Developers

Why JavaScript sucksbut we still love it!

Daniel Kurka Software Engineer

Page 2: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

!2

Page 3: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

What is this about

!3

• History of JavaScript • The quirks of JavaScript • JavaScript serving two masters

- people writing by hand - people compiling to JavaScript

• Having a good laugh

Page 4: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

What is this not about

!4

• Bashing of a language - JavaScript is very successful and will continue to be - it will slowly improve over time

• Java being a better language compared to JavaScript - language is a personal preference - choose what you like and what makes you productive

Page 5: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

Learn JavaScript

!5

• JavaScript can be a lot of fun (can also be a lot of pain) - Learn about the good stuff - Learn the bad stuff (and keep away from it) - prototyping without a heavy type system is much nicer

• In general: functional programming is fun

Page 6: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

!6http://upload.wikimedia.org/wikipedia/commons/9/9a/History_of_Hudson_County_and_of_the_Old_Village_of_Bergen_0055.png

History of JavaScript

Page 7: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

History of JavaScript*

!7

• Brendan’s ten days in May 1995: “Mocha” • September 1995: LiveScript • December 1995: LiveScript • 1996-1997: ECMA-262 Ed., aka ES1 • 1999: ES3: modern JS baseline • 2005: Ajax revolution • 2008: ES4 RIP, Harmony founded in July • 2009: ES5 “use strict”, JSON, Object.create, etc. • 2012: ES6 under way, modules, let, proxies, etc.

*from Brendan Eich, http://www.infoq.com/presentations/State-JavaScript

Page 8: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

!8http://upload.wikimedia.org/wikipedia/commons/6/63/Schienenbruch.jpg

Quirks

Page 9: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

!9

Page 10: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

Double equals

!10

http://www.ecma-international.org/ecma-262/5.1/#sec-11.9.3

Page 11: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

Demo

!11

Page 12: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

GWT was successful because

• GWT fixed the weird quirks in the language - int types - clear defined this - …

• brought all the tools to the web platform

!12

Page 13: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

In 2005

• debugging was alert(); • completely different DOM Apis

- no jquery - different rendering

• GWT was one of the first tools that just lets you write stuff

!13

Page 14: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

In 2014

• many of the pains of the web platform have been fixed • just look at the chrome dev tools • browser standards

!14

Page 15: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

GWT was so successful because it removed the bad parts while keeping

the good stuff

!15

Page 16: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

Everyone is doing JavaScript now

• the Java eco system is healthy and vibrant • JavaScript eco system is just growing • I think Java8 will make Java cool again • GWT’s new JSInterop will yield new sweet spots

- start leveraging all the new JavaScript tools (chrome debugger, source maps, profiler, ..)

• JavaScript has a new sweet spot for compilers

!16

Page 17: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

JavaScript serves two masters

• people writing JavaScript by hand • people compiling to JavaScript

!17

Page 18: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

“Javascript might go away some day, because it just becomes the bytecode and the source

language is never written by hand, because even with error functions its just too verbose. I could believe that future, but that will take a

while to get to, and in the mean time people are handwriting it and compiling to it.”

!18

Brandon Eich, CTO Mozilla

Page 19: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

JavaScript the bytecode of the web

!19

Page 20: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

!20

“We had always thought that Java's JVM would be the VM of the web, but it turns out that it's JavaScript.”

Douglas Crockford

Page 21: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

!21

“JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the write once, run everywhere promise, perhaps because it works at a higher level, avoiding low level edge cases. And then Turing takes care of the rest of it.”

Douglas Crockford

Page 22: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

GWT has a sweet spot

!22

Page 23: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

Write in Java

!23

Page 24: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

with all the tools

!24

Page 25: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

and run everywhere

!25

Page 26: Why JavaScript sucks · “JavaScript's parser does a more efficient job of providing code security than the JVM's bytecode verifier. JavaScript did a better job of keeping the

Daniel Kurkawww.m-gwt.com !gplus: daniel-kurka.de/+ !twitter: @dankurka