You have ruined javascript
You - yes you. You know who you are
I'm @robashton
Enterprise developer
I've been around
I've seen things
And I am disappoint.
But enough about me
What about you?
You have great good
You have great wine
And you're a lovely audience
;-)
You have bad coffee
But I won't hold it against you
Now let's talk Javascript
AWful language
'true' == true // returns false
written in a day
in use for nearly two decades
(apparently 1995 was the year of "take that")
In the beginning
We were wizards
then came jquery
everything as a plugin
$('#thing').accordion()
$('#other').tabs({
onChange: onTabChanged
})
never claimed it was ideal
But it worked
But now?
We're writing everything
as a js client*
*(We really shouldn't, but that's another talk)
And we're bringing our baggage with us
This is not cool
Examples?
"I want to manage my dependencies'
Require-js
"RequireJS is a JavaScript file and module loader. It is optimized for in-browser use, but it can be used in other JavaScript environments, like Rhino and Node."
'require-js seems to be the thing'
'wow, requirejs solves so many problems i never knew I had'
everything is configuration
coffeescript?
Configuration
Static file includes?
configuration
unsupported libraries?
Configuration
Then the real problems start
emberjs
convention over... convention
Shove everything on app
App.FooController = blah
App.FooRoute = blah
App.FooView = blah
Refactor and forget
is this code dead now?
Set up your observers
observe that your observers are observing observers which are observing chaos
Except when they're a binding
or a computed property
emberjs: Taking something dynamic and confusing and making it more dynamic and confusing
a six month old ember codebase
But it's okay
you can hire an ember consultant
and angular...
where do you even begin?
"I had a problem and thought to use Angular so now I have a problem directive factory"
(h/t Andreas Brekken )
directives?
<div ng-controller="Controller">
Hello <input ng-model='name'> <hr/>
<span ng-bind="name"></span> <br/>
<span ng:bind="name"></span> <br/>
<span ng_bind="name"></span> <br/>
<span data-ng-bind="name"></span> <br/>
<span x-ng-bind="name"></span> <br/>
</div>
Directives?
angular.module('docsBindExample', [])
.controller('Controller', ['$scope', function($scope) {
$scope.name = 'Max Karl Ernst Ludwig Planck (April 23, 1858 – October 4, 1947)';
}]);
directives are what happen when you take html and js and then vomit all over them
angular is extensible
An Angular "service" is a singleton object created by a "service factory". These service factories are functions which, in turn, are created by a "service provider". "The service providers are constructor functions". When instantiated they must contain a property called $get, which holds the service factory function.
Factory factories?
service factories?
service providers?
"You need all of this because of dependency injection"
Dependency injection
var pony = new Pony(dependency)
testing a dumb view with some dumb data is dumb and easy
var view = new View(fakeProvider) view.addPony("Pinkie Pie") view.render()
.should_contain("pinkie pie")
you don't need extensibility
you need less code
And now - Javascript vnext
- Promises
- Generators
- Classes
- Etc
You can polish turds
but why bother?
If you want a better client-side language
- Idris
- Fay
- Purescript
- Bash
Case study: Google
"Oh what, we have to write js?"
No wai - GWT will save us!
how about making js itself
look more like java?
Ffs, it's not working - let's make angular js
Everything google do is about trying to make javascript more like java
Causes?
- Too much time on their hands?
- Afraid of a little bit of dynamic code?
- Because frameworks and languages are fun to write?
- (genuine performance concerns)
Well I've got a message
for you google
You have done bad
you should feel bad
because you are bad
Why do we do this to ourselves?
lazy?
instant gratification?
"Productivity without much learning"
the only winners here are the consultants
"But rob, how else do you get a large team of developers up to speed?"
time.
if your company wants to do javascript yesterday and you are not already a team of js developers
then you will fail regardless of technology
slow down
spend time learning
have patience
grow as a team
not as a flock of sheep
be set free
anyway
We're not doing too bad really
there are some clever people doing it right
npm
browserify
all the module authors
We are learning as a community
We'll get there eventually
thanks very much
@robashton
You have ruined javascript
By Rob Ashton
You have ruined javascript
- 7,831