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
CoffeeScript - Spartan Javascript
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Nick Quaranto
January 16, 2013
Programming
610
0
Share
CoffeeScript - Spartan Javascript
Going over the basics of CoffeeScript. Given at BarCampRochester and BuffaloJS.
Nick Quaranto
January 16, 2013
More Decks by Nick Quaranto
See All by Nick Quaranto
The GraphQL Way: A new path for JSON APIs
qrush
287
20k
Awesome Extractions Done Quick
qrush
1
570
rubygems.next
qrush
5
520
how to find GIFs
qrush
10
580
RubyMotion: The sleeper has awakened!
qrush
5
940
Basecamp Next: Code Spelunking
qrush
62
9.1k
m: a better Ruby Test::Unit runner
qrush
2
620
Test Driven Development
qrush
14
1.5k
Lapidary: The Art of Gemcutting
qrush
2
600
Other Decks in Programming
See All in Programming
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
390
Old Dog, New Tricks: The Java 25 Reinvention - JNation
bazlur_rahman
0
130
Oxlintはいかにしてtsgolintのlint ruleを呼び出しているのか
syumai
2
1k
次世代リンターで探る、tsgo 時代における型認識カスタムルールの現実解
ytakahashii
3
1.3k
1人1案件のプロダクトエンジニア時代に、"プロセス監督"としてチャレンジしたこと
non0113
0
350
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
1
510
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
480
GitHub Copilot CLIのいいところ
htkym
2
1.2k
SPMマルチモジュールで テストカバレッジを取得する技法
yosshi4486
0
130
Inside Stream API
skrb
1
350
今さら聞けないCancellationToken
htkym
0
200
AI 時代のソフトウェア設計の学び方
masuda220
PRO
28
11k
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.3k
Mobile First: as difficult as doing things right
swwweet
225
10k
New Earth Scene 8
popppiees
3
2.3k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Google's AI Overviews - The New Search
badams
0
1k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
1.5k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
The Language of Interfaces
destraynor
162
26k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
380
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
120
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.8k
Transcript
R R CoffeeScript @qrush BarCampRoc Apr 2013 Spartan JavaScript
None
JavaScript as a language is Not Verbose
Good JS is OO
Good JS is Concise
CoffeeScript is “Just JS”
CoffeeScript writes Good JS
CoffeeScript is Spartan!
a new battle! http://www.flickr.com/photos/pshab/1578426589/
the closest I’ve felt to the power I had 20
years ago in Smalltalk ~Ward Cunningham
it was the first time I experienced language envy ~DHH
I use both ~Brendan Eich
function foo() { }
function foo() func foo() function foo( function foo() func foo()
function foo( function foo() func foo() function foo( function foo() func
function foo() func foo() function foo( function foo() func foo()
function foo( function foo() func foo() function foo( function foo() func
this
this
foo = function() { return 1 + 1; }
foo = () -> 1 + 1
bar = function(x) { return x + 1; }
bar = (x) -> x + 1
_.bind(fn, obj) http://underscorejs.org/#bind http://coffeescript.org#fat_arrow
baz = () => this.foo()
foz = () => @foo()
$ -> new ItemsRouter() Backbone.history.start()
$ -> new ItemsRouter() Backbone.history.start()
more features
indents are scope
last statements implicitly return
all vars local by default
easier object syntax
title: "Sparta!" author: name: "Leonidas" handle: "theking" apples: 1
string interpolation
var html = "<option value='" + this.id + "'>" +
this.get("title") + "</option>";
"<option value='#{@id}'> #{@get("title")}</option>"
"<option value='#{@id}'> #{@get("title")}</option>"
inheritance actually works
class Item extends Backbone.Model url: -> "/events/#{@id}"
loops are less painful
None
nums = [4, 5, 6] for i in nums console.log
i 4 5 6
comprehensions compact code
nums = [1, 2, 3] [ 1, 2, 3 ]
sq = (n * n for n in nums) [ 1, 4, 9 ]
nums = [1, 2, 3] [ 1, 2, 3 ]
sq = (n * n for n in nums) [ 1, 4, 9 ]
conditionals and loops can be inline
console.log("Sparta!") if true Sparta! console.log("Persia!") unless false Sparta!
x = 6 6 x += 1 while x <
10 [ 7, 8, 9, 10 ] x 10
get existential
spear? false spear = -> "Throw!" [Function] spear? true
window.bcx ?= {} {}
startWaiting: -> @waitTimeout ?= setTimeout => @$container.addClass "waiting" , 300
stopWaiting: -> if @waitTimeout? clearTimeout @waitTimeout @waitTimeout = null @$container.removeClass "waiting"
meet your enemies
None
making coffee • Rails: http://guides.rubyonrails.org/ asset_pipeline.html • Jekyll & Rake:
https://gist.github.com/4496420 • Node: npm install coffee • Anything else: Less.app http://incident57.com/less/
debugging is not terrible
http://alexspeller.com/
some silly keywords
yes, true, on no, false, off
more info • http://coffeescript.org • http://coffeescript.codeschool.com/ • http://robots.thoughtbot.com/post/ 9251081564/coffeescript-spartan- javascript