'

Stapling and Patching the Web of Now (ForwardJS3)

Понравилась презентация – покажи это...





Слайд 0

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


Слайд 1

WOW, WE LIVE IN SUCH GREAT TIMES.


Слайд 2

THE TECHNOLOGIES WE CAN PLAY WITH ARE INCREDIBLE!


Слайд 3

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


Слайд 4

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


Слайд 5

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


Слайд 6

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


Слайд 7

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


Слайд 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.


Слайд 9

AND YET… IT ALWAYS FEELS LIKE SOMETHING IS MISSING…


Слайд 10


Слайд 11

EVERYTHING WE DO IS INCREDIBLE


Слайд 12

INCREDIBLE


Слайд 13

INCREDIBLE = LACKING CREDIBILITY


Слайд 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


Слайд 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?


Слайд 16

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


Слайд 17

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


Слайд 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


Слайд 19

WELL, WE BOLLOCKSED THAT UP PROPER… ✘


Слайд 20

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


Слайд 21

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


Слайд 22

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


Слайд 23

ON MOBILE, THE DECK IS STACKED AGAINST THE WEB…


Слайд 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.


Слайд 25

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


Слайд 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


Слайд 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


Слайд 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


Слайд 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


Слайд 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


Слайд 31

IN OTHER WORDS…


Слайд 32

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


Слайд 33

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


Слайд 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


Слайд 35

AND REPLACE THEM WITH YUMMY GOODNESS.


Слайд 36

IT SEEMS THE WEB IS SAFARI/IOS…


Слайд 37

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


Слайд 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


Слайд 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


Слайд 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


Слайд 41

THE WEB IS A MESS!


Слайд 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.


Слайд 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.


Слайд 44

THE ONE THING THAT CAN HELP US IS LOVE…


Слайд 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)


Слайд 46

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


Слайд 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.


Слайд 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


Слайд 49

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


Слайд 50

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


Слайд 51

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


Слайд 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.


Слайд 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


Слайд 54

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


Слайд 55

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


Слайд 56


Слайд 57


Слайд 58


Слайд 59

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


Слайд 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…


Слайд 61

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


Слайд 62

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


Слайд 63

WE NEED TO MOVE FROM PATCHING TO BUILDING


Слайд 64

THANK YOU! CHRIS HEILMANN @CODEPO8 Stick and Carrot: Alan O’Rourke https://www.flickr.com/photos/33524159@N00/17233999165 Selfie Stick group: j0sh (www.pixael.com) https://www.flickr.com/photos/87690240@N03/16322726941/ Stick, Carrot and heart: opensourceway https://www.flickr.com/photos/47691521@N07/5537457133/ Skip by Denna Jones https://www.flickr.com/photos/95267793@N00/2336623192 Messy room: David, Bergin, Emmett and Elliott https://www.flickr.com/photos/44925192@N00/183227976


Слайд 65


×

HTML:





Ссылка: