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
670
6
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
200
Elm
sporto
1
290
Redux: Flux Reduced
sporto
1
380
Practically Immutable
sporto
0
210
Webpack and React
sporto
4
410
Rails with Webpack
sporto
1
240
Lesson learnt building Single Page Application
sporto
0
150
Grunt
sporto
1
210
Safe Testing in Ruby
sporto
1
150
Other Decks in Programming
See All in Programming
Go言語とトイモデルで学ぶTransformerの気持ち / fukuokago23-transformer
monochromegane
0
140
PHP に部分適用が来るぞ!……ところで何それ?おいしいの? #phpcon / phpcon-2026
shogogg
0
380
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
3.1k
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
0
180
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
12
16k
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
400
えっ!!コードを読まずに開発を!?
hananouchi
0
270
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
280
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
1.3k
5分で問診!Composer セキュリティ健康診断
codmoninc
0
630
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
3
660
コーディングルールの鮮度を保ちたい for SRE NEXT 2026 / keep-fresh-go-internal-conventions-sre-next-2026
handlename
0
150
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
The browser strikes back
jonoalderson
0
1.4k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Crafting Experiences
bethany
1
230
Building AI with AI
inesmontani
PRO
1
1.1k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
810
Building a Scalable Design System with Sketch
lauravandoore
463
34k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
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 ˒ ˒ ˒