Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Frontend Doesn't Suck Anymore

mplewis
September 26, 2017

Frontend Doesn't Suck Anymore

Are you a backend engineer afraid of frontend work? The JavaScript ecosystem can be daunting – new frameworks and tools pop up every day. But it's actually easier than ever to get started writing client-side code. No frontend experience required!

Discover how building tiny webapps can vastly improve your user experience and make your customers happier. Find out about modern languages, advanced tooling, and test-first development for the browser. Learn how to get started right away with ready-made project starter packs.

It's 2017 and the browser is fun again!

mplewis

September 26, 2017
Tweet

More Decks by mplewis

Other Decks in Programming

Transcript

  1. I ❤ these things a lot: – Bicycles – Airplanes

    – Motorcycles – Open source – Cryptocurrency – Hardware maker stuff Let’s chat later!
  2. Outline – Why frontend matters – A brief history of

    frontend – What approach should you take? – 10m break
  3. 1995: The First JS – Brendan Eich creates JavaScript in

    10 days – First introduced in
 Netscape 2.0
  4. 1995: JavaScript We aimed to provide a “glue language” for

    the… programmers who were building Web content from components such as images, plugins, and Java applets. - Brendan Eich
  5. 1995: User-Agent Hell – IE 3.0 falls behind Netscape in

    JS support – Devs just start checking for the Netscape user-agent – Everyone suffers for a very long time
  6. 1997: ECMAScript – Standard to define the JavaScript language –

    V1 based on Navigator 4.0 – Still lots of cross-browser issues everywhere
  7. 1999: ECMAScript 3 – AJAX via XMLHttpRequest – Regex –

    Try/Catch exceptions – Better error messages
  8. 1999: AJAX Before XMLHttpRequest, people used a trick of not

    closing the connection to the server. The server would keep adding more and more to the page, never saying it had finished downloading. - Aaron Swartz
  9. 1999: AJAX – Building block of the modern web –

    “Asynchronous JavaScript and XML” – Update page data without a refresh!
  10. – Isn’t a total solution – Doesn’t provide app structure

    – Apps become a mess of spaghetti code 2010:
  11. – Router! – Structure and tooling for client-side apps –

    Models and collections with AJAX data sync 2010:
  12. – Still very minimal – e.g. no built-in view/ template

    solution – “Roll your own” for the missing bits 2010:
  13. 2012: What HTML would have been, had it been designed

    for building web-apps. - Angular Team
  14. – Structure for large teams with large client-side apps –

    Declarative XML bindings – Components made of smart HTML templates 2012:
  15. Todo Item Render methods return JSX that gets turned into

    HTML Components take props as input Component
  16. Use a starter kit – Batteries included:
 It Just Works

    out of the box! – Provides initial project structure – Supports modern JS,
 JSX, Sass, and others
  17. What do starter kits come with? – Babel: ES6 support

    – Webpack: Modern dependency bundling – Better HTML/CSS:
 JSX, Sass, Less, Stylus
  18. Start from scratch – You get to pick which parts

    you need – Helps you learn how different packages interact – Doesn’t force you to use
 a specific project layout
  19. Start from scratch – Writing your first Webpack config is

    frustrating – You spend a lot of time learning tools before you get to build anything – So many decisions!
  20. A good DIY approach – Pick some tool - it

    doesn’t matter what tool – Build with just that tool – Once you like it, add another tool
  21. ES6: Modern JS – ES6 is incredible – Feels like

    a modern programming language – Feature list
  22. ES6: Modern JS – Template string literals – Destructuring –

    Default, rest, spread – Native promises!
  23. ES6: Modern JS – Most browsers don’t support all ES6

    features. – How do we start using ES6?
  24. – Converts modern JS to compatible legacy JS – Adds

    support for whichever browsers you want to target
  25. : What’s wrong with it? – Cascading style specificity is

    still painful – Writing scoped and nested styles is still painful – Only recent support for variables and calculation
  26. : What’s good about it? – Flexbox and Grid! –

    Media queries! – Animation! – Sane box sizing!
  27. : We’re stuck with it – All modern browsers support

    modern CSS – CSS still sucks to write – Most people hate it
  28. and

  29. & – Compile-to-CSS languages – Makes it a lot easier

    to build reusable, versatile styles!
  30. & – Calculation: column sizes, color palettes – Shared variables:

    use your brand standards across all your apps – Auto-prefixing and polyfills for legacy browsers
  31. – Wide adoption - Bootstrap uses it! – Two different

    syntaxes: CSS-like, Python-like – Requires Ruby to use
  32. Why is frontend painful? – Our code depends on many

    outside resources – Our project is made of hundreds of individual files – None of them are minified – We have to write the URLs for each resource by hand
  33. – We love our modern tools: ES6, Babel, Sass, Stylus

    – Users don’t update their browsers – Old browsers don’t support the hot new stuff Why use a build tool?
  34. – Compiles your ES6 code into ES5 using Babel –

    Compiles your Sass and Stylus into CSS – Transparently and automatically!
  35. : Prod – Bundles images and styles into easy-to-ship JS

    blobs – Includes dependencies in the proper order – Minifies your stuff to keep your bundle small
  36. : Loaders – Bring in whatever resources you need –

    Use them directly in your code – No more fragile URLs to images and data files
  37. – Add entire features to any app. For example: –

    Split your app into smaller chunks, downloaded on demand – Use Service Workers to enable offline use : Plugins
  38. – Webpack is confusing – It’s why I gave up

    on frontend years ago – Just get something working, then fix it later – (Starter kits are great!)
  39. 1. Setup a working base 2. Add something small 3.

    Make it work 4. Make something else work 5. Throw it away
  40. 1. Setup a bare HTML page 2. Add React 3.

    Render a component 4. Render a subcomponent 5. Throw it away
  41. 1. Setup a Vue project 2. Add Webpack 3. Get

    your dev server up and running 4. Add ES6 support via Babel 5. Throw it away
  42. 1. Setup a vanilla JS app 2. Add jQuery 3.

    Use jQuery for CSS selectors 4. Use jQuery for AJAX 5. Throw it away
  43. Save your work – Create a git repo for every

    project you start – GitHub lets you create unlimited public projects – This is your knowledge
 base for future
 frontend work!
  44. Let’s keep talking: – Testing – Deployment – API design

    – Data flow – Anything else you want to learn more about Thanks for coming! [email protected] mplewis.com/talks/fdse