CapitolJS Conference 2011 Schedule and Overview
Table of Contents
- Overview
- Schedule
- 9:15 AM Douglas Crockford: JavaScript and the Brain
- Language requires precision
- Why jslint
- Reiteration of fall-through
- Canonization reqiures clarity
- No space before ( with invocation
- Don't use forms that can't be distinguished from errors
- Don't use complicated features when simplier will do
- Make your programs look like what you do
- Write in the language you're writing in
- ++ is hardly optimal when looking at += 1
- var a = b = 0
- Style demands you don't use all
- CoffeeScript
- Why do language designers add bad parts
- 9:45 AM Ben Combee: webOS
- 10:30 AM Nicholas Zakas: High Performance JavaScript
- UI Thread
- No single JavaScript job should
- Don't interrupt UI updates with script calls
- <script defer src=''>
- <script async src=''>
- Technique 1: Split execution setTimeout
- Technique 2: Script Yeilding
- Technique 3: Web Workers
- Repsonsive: small UI, small JS, small UI…
- Handling document.write after page load
- Recommendation: look at WebKit source
- 11:00 AM Mikeal Rogers: node.js module tour
- 11:45 AM Jed Schmidt: Code Golf
- 1:00 PM Mike Taylor: Event Protocols
- 1:30 PM Rebecca Murphey: Mulberry
- 2:15 PM Alex Sexton:
- 3:15 PM Joe McCann: Improving HTML5 Development with Node
- 4:30 PM Pamela Fox: Client-Side APIs
- 4:30 PM Progressive Mobile
- 5:00 PM Brendan Eich
- 7:00 PM Zappos' Closing Party
- 9:15 AM Douglas Crockford: JavaScript and the Brain
Overview
Schedule
9:15 AM Douglas Crockford: JavaScript and the Brain
Language requires precision
Why jslint
Reiteration of fall-through
Canonization reqiures clarity
Example: canonization of the bible with constantine required introduction of punctuation and spacing.
No space before ( with invocation
Don't use forms that can't be distinguished from errors
Don't use complicated features when simplier will do
Make your programs look like what you do
Write in the language you're writing in
++ is hardly optimal when looking at += 1
x++ vs. ++x ; pre-post increment difference forces a code reviewer to go back and check all code from the author.
var a = b = 0
This actually become a global issue:
b = 0; var a = b;
Example:
function multAssign() { var a = b = 0; console.log('a' + a); console.log('b' + b) } ; multAssign(); console.log('b' + b)
Style demands you don't use all
CoffeeScript
Wished that JavaScript looked more like CoffeeScript but debugging code
Why do language designers add bad parts
Language is an experiment…
JavaScripts combination of lambdas and prototypes worked well.
Not all worked well.
9:45 AM Ben Combee: webOS
Architectural discussion
WebKit, Node.js Service Runtime, webOS Services
Enyo
Thisi s for full page applictions. js over html.
Node.js
Used as part of the service bus.
10:30 AM Nicholas Zakas: High Performance JavaScript
UI Thread
Paint operations are queued since there could be a number of UI changes queued from the event.
No single JavaScript job should
Per Nielson: .1s is the limit to a user sense of instantaneous.
Don't interrupt UI updates with script calls
Download doesn't block with dynamic load for document.createElement.
<script defer src=''>
Avoid slow load: dynamically, deferred, asycn
Downloaded but not run until all UI is completed.
<script async src=''>
Runs as soon as possible. Order isn't preserved (by design).
Technique 1: Split execution setTimeout
todo = items.concat(); start = +new Date()
Technique 2: Script Yeilding
process.nextTick()
msSetImmediate: // MSIE 10 setImmediate(function(0 {
});
https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/setImmediate/Overview.html
Technique 3: Web Workers
Repsonsive: small UI, small JS, small UI…
Handling document.write after page load
Overwrite document.write to handle load…
Recommendation: look at WebKit source
11:00 AM Mikeal Rogers: node.js module tour
Node core doesn't have all features you might reasonably want
This falls to external libraries
npm has 10 to 30 new updates per day
npm utilies
% npm explore request 0 master[2708668] 11:10:53
Exploring usr/local/lib/node.npm/request/active/package Type 'exit' or ^D when finished
npm libraries
underscore 216 coffee-script 175 request 141 express 141 connect 130 optimist 127 colors 90 uglify-js 85 socket.io 85 redis 76
optimist
https://github.com/substack/node-optimist
Mentioned as the best options parser.
----------–— 1.js var optimist = require('optimist'); console.log(optimist.argv); ----------–— 1.js
$ node 1.js asdfasdfasd asdf asdf { _: [ 'asdfasdfasd', 'asdf', 'asdf' ], '$0': 'node ./1.js' }
request
Advanced HTTP client.
request.pipe() is a core feature.