Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CanJS
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
sporto
April 11, 2013
Programming
660
6
Share
CanJS
An overview of CanJS and comparison with Backbone, Angular and Ember
sporto
April 11, 2013
More Decks by sporto
See All by sporto
React inside Elm
sporto
2
190
Elm
sporto
1
280
Redux: Flux Reduced
sporto
1
370
Practically Immutable
sporto
0
200
Webpack and React
sporto
4
400
Rails with Webpack
sporto
1
240
Lesson learnt building Single Page Application
sporto
0
140
Grunt
sporto
1
200
Safe Testing in Ruby
sporto
1
140
Other Decks in Programming
See All in Programming
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
2.7k
20260514_its_the_context_window_stupid.pdf
heita
0
860
JCON - Create Agentic AI Apps, The Easy Way!
kdubois
1
100
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
320
Spec-Driven Development with AI Agents (Workshop, May 2026)
antonarhipov
3
340
Kubernetesを使わない環境にもCloud Nativeなデプロイを実現する / Enabling Cloud Native deployments without the complexity of Kubernetes
linyows
3
370
空間オーディオの活用
objectiveaudio
0
150
サークル参加から学ぶ、小さな事業の回し方
yuzneri
0
160
アクセシビリティ試験の"その後"を仕組み化する
yuuumiravy
1
200
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
500
mruby on C#: From VM Implementation to Game Scripting (RubyKaigi 2026)
hadashia
2
1.7k
UaaL×Androidアプリのメモリ計測 — Memory Profilerの先へ
rio432
0
140
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.4k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
170
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
510
The agentic SEO stack - context over prompts
schlessera
0
770
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
240
The untapped power of vector embeddings
frankvandijk
2
1.7k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
160
Into the Great Unknown - MozCon
thekraken
41
2.5k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Abbi's Birthday
coloredviolet
2
7.5k
Transcript
Sebastian Porto @sebasporto
•Intro •Features •Demo •Why?
2008 2012 Part of JMVC 3
CAN.JS MVC View Controller events Model m odify updates via
events
FEATURES
OVERVIEW can.Construct can.Observe can.Model can.Control can.view EJS Mustache can.route
can.Construct var Person = can.Construct({ init: function (name) { this.name
= name; } }); var zack = new Person(”Zack");
OBSERVABLES Construct Observable
can.Observe var state = new can.Observe({ selected: null, showSave: false
});
can.Observe state.bind('selected', function (oldVal, newVal) { … }); state.attr(‘selected’, item);
state.attr(‘selected’);
MODELS Construct Observable Model
can.Model var Library = can.Model({ findAll: ‘GET /libraries’, create: 'POST
/libraries', update: 'PUT /libraries/{id}', destroy: 'DELETE /libraries/{id}' }, {});
can.Model new Library.List([]); Collection Member new Library({name: ‘jQuery’});
VIEWS Model Views live bindings
can.view var template = can.view("#template", { libraries: this.libraries, state: this.state
}); can.$(ele).append(template);
EJS <% libs.forEach(function(el, ix) { %> <li><%= el.name %></li> <%
}) %> <% if (state.isEditing) { %> <button>Save</button> <% } %>
Mustache {{#libraries}} <li>{{name}}</li> {{/libraries}} {{#state.isEditing}} <button>Save</button> {{/state.isEditing}}
CONTROLLERS Controller Model View events m odify
can.Control var Control = can.Control({ init: function (ele, options) {
… } }); var control = new Control('#main’, {});
can.Control '.btn_save click': function (ele, ev) { }, '.name keyup':
function (ele, ev) { }
Other Goodies •Validations •Dirty attributes •Fixtures •Handlebars helpers (Transformations, filters)
DEMO
WHY?
None
LEARNING CURVE A subjective comparison
BACKBONE Confused
EMBER “We frequently receive feedback from new developers about how
frustrating it can be to get started with Ember” Yehuda Katz & Tom Dale http://emberjs.com/blog/2013/03/21/making-ember-easier.html
ANGULAR Wow
None
Convenience / Magic Easier to Learn
They way you already know, is most likely the right
way.
ANGULAR function Ctrl($scope, $element) { $(‘.tree’, $element).dynatree({}); }
That’s not the Angular way! You should use directives!
CAN init: function (element, options) { $(‘.tree’, element).dynatree({}); … }
Yay!
SIZE KB (MIN) Ember Angular CanJS Backbone 18 33 80
141
SIZE KB (MIN) Ember + jQuery + Handlebars Angular CanJS
+ Zepto Backbone + _ + Zepto + Mustache 61 57 80 269
INTEGRATION
Memory leak safe '.btn_save click': function (ele, ev) { …
},
Performance http://jsperf.com/angular-vs-knockout-vs-ember/118
Succinct Source http://paulhammant.com/2013/01/18/client-side-mvc-roundup/
TRY IT OUT!
THANKS... QS?
With #canjs you can do 80% of what you can
possibly need with 20% the learning curve of the others. Sebastian Porto @sebasporto
THE REALLY IMPORTANT STUFF Backbone CanJS Angular Ember Easy to
learn ˒ ˒ Great docs ˒ ˒ ˒ Observable Models ˒ ˒ ˒ ˒ Routing ˒ ˒ ˒ ˒ Views with live bindings ˒ ˒ ˒ Two way bindings ˒ ˒ Avoid unnecessary boilerplate ˒ ˒ ˒