Stapling and Patching the Web of Now (ForwardJS3)


The Presentation inside:

Slide 0

STAPLING AND PATCHING THE WEB OF NOW CHRIS HEILMANN (@CODEPO8), FORWARDJS, SF, 2015


Slide 1

WOW, WE LIVE IN SUCH GREAT TIMES.


Slide 2

THE TECHNOLOGIES WE CAN PLAY WITH ARE INCREDIBLE!


Slide 3

THE TECHNOLOGIES WE CAN PLAY WITH ARE INCREDIBLE! • Web Components • Service Workers • ECMAScript 2015/16… • WebVR/WebGL/WebRTC


Slide 4

WE’VE COME A LONG WAY AS PROFESSIONAL DEVELOPERS • Version control • Test-Driven Development • Task runners • Package management • Pre/Post compilation • Transpiling


Slide 5

OUR TOOLING HAS NEVER BEEN BETTER… • IDE Integration • Watchers/Live Reloads • In-browser debuggers and development tools • Remote debugging tools and protocols


Slide 6

FRAMEWORKS, LIBRARIES AND PACKAGING TOOLS MAKE OUR LIVES MUCH EASIER… • React • Polymer • Angular • Bootstrap • PhoneGap / Manifold.js


Slide 7

BROWSERS ARE OPENLY INNOVATING AND EVERGREEN… • Firefox • Chrome/Opera • Microsoft Edge • Safari iOS • Safari


Slide 8

OUR COMMUNICATION TOOLS ARE SPLENDID • We all ❤ GitHub • We all talk on Slack • We all can access hundreds of free resources on learning our trade • We all can take part in meetups or conferences almost every day - or on the web.


Slide 9

AND YET… IT ALWAYS FEELS LIKE SOMETHING IS MISSING…


Slide 10


Slide 11

EVERYTHING WE DO IS INCREDIBLE


Slide 12

INCREDIBLE


Slide 13

INCREDIBLE = LACKING CREDIBILITY


Slide 14

• • Many things need non-standard code or flags to be turned on • INCREDIBLE? Almost everything we release these days is experimental Things work only in one browser, sometimes even a special build • After impressing one another with a cool logo, grandiose statements and a 3 line hello world demo there’s a fine print stating “don’t use this in production” • To use any of the new standards, you need to use an abstraction library


Slide 15

✘ Not our end users - they are not likely to have the same computers, connections and browsers we have ✘ Not companies who need to work with products that work in large teams or can be used in an environment following certification processes ✔ We code for ourselves, conference participants, hacker news commenters, the tech press and an imaginary, perfect, future audience. WHO DO WE CODE FOR?


Slide 16

WHAT HAPPENED? HOW DID WE END UP SO SELF-CENTERED?


Slide 17

WHAT IS THE MAIN THING WE KEEP TRYING TO FIX WITH ALL OUR INNOVATION EFFORTS?


Slide 18

MOBILE HAS BEEN SOLD TO US AND BY US AS TOTALLY DIFFERENT • The app is a much better form factor than web sites with URLs • Everything needs to work offline • Speed is paramount and every byte costs money. • Everything needs to be much simpler interfaces - people are busy and on the road • Every app should take full advantage over what the operating system and hardware offers


Slide 19

WELL, WE BOLLOCKSED THAT UP PROPER… ✘


Slide 20

TROUBLE WITH THE MOBILE WEB… www.theverge.com/2015/7/20/9002721/the-mobile-web-sucks


Slide 21

TROUBLE WITH THE MOBILE WEB… www.theverge.com/2015/7/20/9002721/the-mobile-web-sucks


Slide 22

THE WEB IS DESIGNED TO WORK INDEPENDENT OF HARDWARE, SOFTWARE, ABILITY OR LOCATION.


Slide 23

ON MOBILE, THE DECK IS STACKED AGAINST THE WEB…


Slide 24

ON MOBILE, THE DECK IS STACKED AGAINST THE WEB… • Browsers are hard-wired and update with operating systems • Hardware creators, service providers and even third party vendors fork and release their own unholy versions of the OS and the browser. • The more you control the experience, the more competitive you are.


Slide 25

THE FIVE STAGES OF MOURNING FOR THE OPEN WEB IN A MOBILE WORLD. DENIAL ANGER BARGAINING DEPRESSION ACCEPTANCE


Slide 26

THE FIVE STAGES OF MOURNING FOR THE OPEN WEB IN A MOBILE WORLD. DENIAL ANGER BARGAINING DEPRESSION • This is just a fad, it will go away. • If we build our own operating system based on HTML5, the others will learn from that and embrace it more. • Surely the simplicity of web standards and the amazing value of Microformats and properly structured HTML will never cease to amaze new developers. ACCEPTANCE


Slide 27

THE FIVE STAGES OF MOURNING FOR THE OPEN WEB IN A MOBILE WORLD. DENIAL ANGER BARGAINING DEPRESSION • It is all the fault of our users - they do all the things wrong like using outdated browsers or turning off JavaScript! • It is the fault of browser makers - they just don’t innovate quickly enough to match what mobile can do! • It is the fault of clients - they only want crap and nothing exciting that pushes the envelope! • It is the fault of tool creators - we need to match what native has in terms of tooling and then we all can ride unicorns and have ice cream! ACCEPTANCE


Slide 28

THE FIVE STAGES OF MOURNING FOR THE OPEN WEB IN A MOBILE WORLD. DENIAL ANGER BARGAINING DEPRESSION • Let’s build a stop phone gap solution - one that is designed to become redundant to show mobile OS makers that the web is ready if only it had access to hardware capabilities. • Let’s define lots of APIs and form expert groups - surely these will be embraced an implemented by OS providers instead of coming up with their own ones! • Let’s inject browsers with our apps into the platform (crosswalk-project.org). This worked wonders with Chromeframe and Internet Explorer. ACCEPTANCE


Slide 29

THE FIVE STAGES OF MOURNING FOR THE OPEN WEB IN A MOBILE WORLD. DENIAL ANGER BARGAINING DEPRESSION • Let’s concede defeat - we can never match what native offers, and never innovate as fast. • Let’s consider a new career - goat farming, for example, sounds like a great investment. • Let’s try to find recognition elsewhere - maybe in a smaller group of people who care about what I do. ACCEPTANCE


Slide 30

THE FIVE STAGES OF MOURNING FOR THE OPEN WEB IN A MOBILE WORLD. DENIAL ANGER BARGAINING DEPRESSION • Maybe this is just another form factor - and we could use our time to care for the web that is instead. • Maybe there is space for more than one form factor - just maybe. I mean, crazier things have happened, like multiple ways to use a road. • Maybe this is a time to reflect and improve what we have after all, there is a lot that needs fixing? ACCEPTANCE


Slide 31

IN OTHER WORDS…


Slide 32

THE WEB IS FULL OF RUBBISH, TIME TO CLEAN IT UP INSTEAD OF ADDING MORE…


Slide 33

I JOINED MICROSOFT TO HELP WITH ONE VERY IMPORTANT FIX THE WEB VERY MUCH NEEDED…


Slide 34

✘ ✘ THE IDEA WAS TO GET RID OF ALL THE BAD IDEAS OF THE PAST… VML attachEvent() ✘ currentStyle ✘ X-UA-Compatible (render modes) ✘ IE Layout Quirks ✘ VBScript ✘ Conditional Comments ✘ MS-Prefixed Events


Slide 35

AND REPLACE THEM WITH YUMMY GOODNESS.


Slide 36

IT SEEMS THE WEB IS SAFARI/IOS…


Slide 37

EXPERIMENTAL? PROBABLY SAFE TO USE… before after -webkit-appearance: none before after -webkit-gradient


Slide 38

COPY + PASTE BEATS VALIDATION? <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta charset="utf-8"> ✔ <meta charset=“utf8"> ✘ > 600k times in use on GitHub! https://github.com/search?l=html&q=charset+%22UTF8%22&ref=searchresults&type=Code&utf8=%E2%9C%93


Slide 39

THINGS YOU LEARN WHEN YOU WRITE A NEW JS ENGINE @BTERLSON @GAURAVSETH https://channel9.msdn.com/events/WebPlatformSummit/2015/Chakra-TheJavaScript-Engine-that-powers-Microsoft-Edge


Slide 40

✘ ✘ THINGS YOU LEARN WHEN YOU WRITE A NEW JS ENGINE Only a third of the top 3000 sites can benefit from JS inlining. Reason is lots of scripts instead of concatenation. You need to optimise a lot of JS in the engine (length reading on every iteration of for loops!) ✘ Outdated libraries are still very much in use and clash with new JS features (mootools breaking with array.contains(), zepto disliking array constructors) ✓ Minification is used a lot on the web and optimising for uglify.js code is a big win


Slide 41

THE WEB IS A MESS!


Slide 42

PROMISES DON’T WORK • Can we stop producing “not ready for production” solutions? • People are getting tired of “upcoming amazing technology” we “need to use now” and jump through hoops to implement. • Abstraction libraries end up in production, become interoperability issues and fill up the web. • Experimental technology in use gets included across browsers to ensure backwards compatibility - making browsers slow and fat.


Slide 43

WE SHOULD NEVER PUNISH OUR USERS • It isn’t their job to fix their working environments to our needs • There is no “everybody should use this” - you publish on the web; you knew what you signed up for. • We’re wasting time re-evaluating sensible concepts like progressive enhancement. It works, it is futureproof. Let’s not pretend we can control things.


Slide 44

THE ONE THING THAT CAN HELP US IS LOVE…


Slide 45

✔ LOVE FOR THE FORM FACTOR THAT IS THE WEB… Let’s not repeated the same mistakes we did with IE6 (checking for browsers, blocking others) ✔ Let’s not write code “that works” rather than “is correct” ✔ Let’s not optimise our work for a platform that doesn’t appreciate it and where it won’t flourish (mobile)


Slide 46

AND THIS IS WHERE RIGHT NOW WE NEED TO CONCENTRATE ON GETTING ONE THING RIGHT…


Slide 47

ES6 COMES WITH SO MUCH GOODNESS, TECHNICALLY IT HAS TO BE FATTENING… • Arrow functions as a short-hand version of an anonymous function. • Block-level scope using let instead of var makes variables scoped to a block (if, for, while, etc.) • Classes to encapsulate and extend code. • Constants using the const keyword. • Default parameters for functions like foo(bar = 3, baz = 2) • Destructuring to assign values from arrays or objects into variables. • Generators that create iterators using function* and the yield keyword. • Map, a Dictionary type object that can be used to store key/value pairs. and Set as a collection object to store a list of data values. • Modules as a way of organizing and loading code. • Promises for async operations avoiding callback hell • Rest parameters instead of using arguments to access functions arguments. • Template Strings to build up string values including multi-line strings.


Slide 48

ALL OF THESE PARTS HAVE DIFFERENT AUDIENCES Syntactic Sugar Scalable Apps Library Builders Arrow functions Enhanced object literals Template strings Destructuring Rest, Spread, Default String, Math, Number, Object, RegExp APIs let, const & block7 scoped bindings Classes Promises Iterators Generators Typed arrays Modules map, set & weakmap __proto__ Proxies Symbols Sub7classable built7ins


Slide 49

SUPPORT IS ENCOURAGING, BUT ALSO PATCHY http://kangax.github.io/compat-table/es6/


Slide 50

THE PROBLEM: FOR NON-SUPPORTING BROWSERS, ES6 FEATURES ARE SYNTAX ERRORS…


Slide 51

THE SOLUTION: TRANSPILING INTO ES5… https://babeljs.io


Slide 52

✘ THE PROBLEMS WITH TRANSPILING: It adds an extra step in between writing code and running it in the browser - probably the thing that made the web grow as fast as it did. ✘ You don’t run or debug the code you write. ✘ You’re at the mercy of the transpiler to create efficient code ✘ You create probably much more code than you need ✘ Browsers that support ES6 will never get any.


Slide 53

PRIORITIES OF CONSTITUENCIES… “ In case of conflict, consider users over authors over implementors over specifiers over theoretical purity. In other words costs or difficulties to the user should be given more weight than costs to authors; which in turn should be given more weight than costs to implementors; which should be given more weight than costs to authors of the spec itself, which should be given more weight than those proposing changes for theoretical reasons alone. Of course, it is preferred to make things better for multiple constituencies at once. http://www.w3.org/TR/html-design-principles/#priority-of-constituencies


Slide 54

TURNS OUT, YOU CAN FEATURE TEST ES6… https://featuretests.io/


Slide 55

HOW DOES ES6 PERFORM? http://kpdecker.github.io/six-speed/


Slide 56


Slide 57


Slide 58


Slide 59

http://kpdecker.github.io/six-speed/


Slide 60

• • We can use TypeScript or transpile it • THE ES6 CONUNDRUM: We can’t use it safely in the wild We can feature test for it, but that can get complex quickly • Browsers that support it, will not get any ES6 that way (but can use it internally) • The performance is bad right now (which is a normal thing). To improve this, we need ES6 to be used in the wild…


Slide 61

HELP ES6 BY LOOKING AT ITS UNIT TESTS… https://github.com/tc39/test262 http://test262.ecmascript.org/


Slide 62

YOU CAN LEARN AND FIX ISSUES. http://es6katas.org


Slide 63

WE NEED TO MOVE FROM PATCHING TO BUILDING


Slide 64

THANK YOU! CHRIS HEILMANN @CODEPO8 Stick and Carrot: Alan O’Rourke https://www.flickr.com/photos/[email protected]/17233999165 Selfie Stick group: j0sh (www.pixael.com) https://www.flickr.com/photos/[email protected]/16322726941/ Stick, Carrot and heart: opensourceway https://www.flickr.com/photos/[email protected]/5537457133/ Skip by Denna Jones https://www.flickr.com/photos/[email protected]/2336623192 Messy room: David, Bergin, Emmett and Elliott https://www.flickr.com/photos/[email protected]/183227976


Slide 65


×

HTML:





Ссылка: