Why I will never write JavaScript ever again*
description
Transcript of Why I will never write JavaScript ever again*
Why I will never write JavaScript again*
LA CoffeeScript 10/22/14
Why I will never write JavaScript again*
LA CoffeeScript 10/22/14
*the“no really, I don’t hate JavaScript” version
–You
“Wait, Who is this guy and what the hell does he know about JavaScript?”
Hi I’m Wolff!• A little about me:
• Señor Frontend Engineer @ The Noun Project
• Active community of designers
• Nearly 70,000 icons in SVG/PNG
• New API http://api.thenounproject.com
• All around cool person…
• Avid pizza aficionado
• Wanted to be a playwright not a developer
Wolff’s Backstory:• Accepted to school for Playwriting
• Me: “That’s a terrible fucking idea”
• Me: “I’ve made a website before, why not do that?!”
• Made the logical choice to go to art school for programming 😕
• Worked in iOS (hated it)
• 2nd Frontend dev barackobama.com
• Relaunched thenounproject.com on new NP API
What we'll cover
• A brief history of JavaScript!
• Intro to CoffeeScript !
• Why I will never write JavaScript again* (AKA Why CoffeeScript is good for you and your team)
(AKA Why CoffeeScript isn’t just hipster crap)
Wolff Storytelling Break:
–CS Major
“Wait, what exactly are building your website with?”
–Wolff
“Uh… well JavaScript. Of course.”
–CS Major
laughing “JavaScript isn’t a programming language, it's a
half-assed scripting language.”
–Wolff
😢
A brief history of JavaScript
1993/2014
Code Smell designed by Arthur Shlain from the Noun Project
Your Grandpa’s JS (93/03)
• “This shit’s f***’d!” -pretty much everyone
Medieval JS (04/08)
• Enter modern web applications:!
• Gmail
• OMFG AJAX!!!!
GTFO JAVASCRIPTERS!
• JavaScript was considered a novelty
• Unwelcome at the proverbial big kids table.
• Only called upon when our skills were needed to do terrible things to the DOM.
However, we're not
in 2007 anymore 😉
(*…and we all know that CS Major ended up writing Java and hates his life)
Modern Day Awesomeness
JavaScript 2014
Knife designed by Nathan Driskell from the Noun Project
JavaScript is FAST!!!!
High powered JS engines:!!
V8, Nitro (SquirrelFish Extreme), Rhino,
Spidermonkey etc. etc. !!
({Lots of fucking animal names})
Rocket designed by James Fenton from the Noun Project
JavaScript is Glamorous
Writing Server-side JavaScript doesn’t have to
suck anymore:!!
Node, npm, yoman, Grunt, Gulp etc. etc.
!!
({install all the things})
JavaScript is
still a pain in the ass
({💩});
Hell is other people’s JavaScript
({This has been all of us, admit it.})
Spaghetti Code
({Be honest. You’ve written some.})
Modern solutions to code organization
• Unit tests
• Modularization
• Project patterns
• etc.
JavaScript is improving!
• But it will be approximately 8 years before we don’t have to worry about crappy backwards compatibility.
But there has to be more…
• Leaves some still wanting more organization
• What I call the human factor
• JavaScript syntax isn’t for humans
Intro to CoffeeScript
Coffee designed by Jacob Halton from the Noun Project
CofeeScript is Not JavaScript
• No syntactical bloat
• ({ Banish curly braces forever! });
• Write more like a human
Write like a sane human
CoffeeScript is Not JavaScript
• (w)rappers; (w)rappers; (w)rappers
• CoffeeScript:
!
• JavaScript:
!!
for input in form.find(“input")!$input = $(input)
_ref = form.find("input");!for (_i = 0, _len = _ref.length; _i < _len; _i++) {! input = _ref[_i];! $input = $(input);!}
CoffeeScript is Not JavaScript
• Closures (OMFG!)
• handles scoping for us
• no need for var!
• all variables will be correctly scoped and declared efficiently
CoffeeScript is Not JavaScript
• smarter objects (thanks to baked-in patterns)
• JavaScript doesn’t bind functions by default.
• I say: “FUCK THAT SHIT!”
CoffeeScript is Not JavaScript
• Binding functions in CoffeeScript:
class Wolff!!! awesome: false!!! getPizza: =>!!! ! @awesome = true
• Otherwise use -> for private functions
CoffeeScript is Not JavaScript
• Other perks
• Simple prototypal chaining
• class Array extends Array!
• super classing of methods
• Literally just include super
CoffeeScript is Not JavaScript
• Compiles!
• Grunt / Gulp etc.
• ability to do imports and concatenation on multiple JS files
CoffeeScript is Not JavaScript
• CoffeeScript Caveats:
• Bad for shoehorning
• "Let's get coffeescript working for our _______ CMS”
• Legacy JS can be tricky
Why I will never write JavaScript ever again*
*I don’t want to hate JavaScript anymore.
Why I will never write JavaScript ever again*
• Readability #A.K.A. the human factor
• People might look at your code and not want to kill themselves
Why I will never write JavaScript ever again*
• Machines read machine code / humans write human code
• most important thing about CoffeeScript
Why I will never write JavaScript ever again*
• Machines read machine code / humans write human code
• most important thing about CoffeeScript
Why I will never write JavaScript ever again*
• Standards - assets should never, NEVER be committed to version control
• machines read machine code
• code that is read by the browser should be uglified, minified, gzipped (pretty much unreadable by humans)
Production JavaScript
({Optimized for machine input})
Why I will never write JavaScript ever again*
• Don't be the developer that complains about a JS lib being over 10k and then then doesn't uglify/min/AND Gzip
• Much easier to have libraries handled via package management
• npm, bower, etc.
Why I will never write JavaScript ever again*
• Remove the boiler-plating
• less brackets and syntactical bloat
• live ({free})
You know you’re a JavaScripter when? …
({We’ve all been there})
Why I will never write JavaScript ever again*
• Efficiency comes built in
• Programmers can go about their day solving problems
• CoffeeScript handles efficiency under the hood
Why I will never write JavaScript ever again*
• Think more like an engineer, even when you're wearing your developer hat
• JR devs can worry about solving day to day problems
• less hacking / more planning
Why I will never write JavaScript ever again?
CoffeeScript makes JavaScript more human for
you and your team.
In Summation
• Make things simpler on yourself
• We all know you survived JSLint.
• We’ve all been there
In Summation
• Focus more on what’s important
• organization
• code cleanliness
• efficiency
In Summation
• Have more fun:
• The future of JavaScript is exciting!
• Worry less, enjoy more
In Summation
Enjoy the future of JavaScript!
🚀
Thanks!
Questions?Twitter: @seawolff
Noun Project: @thenounproject