avoiding javascript pitfalls through tree hugging
DESCRIPTION
Slides of the talk given at MeetJS Summit (http://summit.meetjs.pl). The TreeHugger playground can be found here: http://ajaxorg.github.com/treehugger/test.htmlTRANSCRIPT
Avoiding JavaScript PitfallsThrough Tree Hugging
Zef Hemel (@zef)
JavaScript Developer
we’re building#1 JavaScript IDE
~400,000
Iterating using undeclared variable
Warning: you are in an anonymous inner function with its own “this” pointer -- ya sure this is what you mean?
Did you mean “length”?
How?
Unleash the awesome power of...
tatic
taticX
program analysis
Whatcan you do with it?
code outlines
code navigation
...
code completion (intellisense)
Parse
Analyze
ParserCode AST
Abstract Syntax Tree
a * 10 Parser
Op
Var Num“*”
“a” “10”
Zeon
UglifyJS
Narcissus
Esprimalanguage.js
performance (speed/memory)
AST datastructure
traversal tools
performance (speed/memory)
AST datastructure
traversal tools
JavaSc
ript s
pecific
treehugger.js
“The JQuery of AST analysis.”
Standard AST Datastructure
Standard Traversals
Pattern Matching
+
a * 10
Op
Var Num“*”
“a” “10”
Op("*", Var("a"), Num("10"))
Op
Var Num“*”
“a” “10”
Op("*", Var("a"), Num("10"))
ATerm
Op
Var Num“*”
“a” “10”
Constructors
Lists
Strings
Var(_)
[_, _]
"hello"
Placeholders x
http://github.com/ajaxorg/treehugger
http://c9.io @zef @cloud9ide
http://github.com/ajaxorg/treehugger