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
Nick Quaranto
January 16, 2013
Programming
0
580
CoffeeScript - Spartan Javascript
Going over the basics of CoffeeScript. Given at BarCampRochester and BuffaloJS.
Nick Quaranto
January 16, 2013
Tweet
Share
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
550
rubygems.next
qrush
5
480
how to find GIFs
qrush
10
560
RubyMotion: The sleeper has awakened!
qrush
5
890
Basecamp Next: Code Spelunking
qrush
62
9k
m: a better Ruby Test::Unit runner
qrush
2
580
Test Driven Development
qrush
14
1.5k
Lapidary: The Art of Gemcutting
qrush
2
530
Other Decks in Programming
See All in Programming
技術的負債と戦略的に戦わざるを得ない場合のオブザーバビリティ活用術 / Leveraging Observability When Strategically Dealing with Technical Debt
yoshiyoshifujii
0
160
"使いづらい" をリバースエンジニアリングする UI の読み解き方
rebase_engineering
0
110
RubyKaigiで得られる10の価値 〜Ruby話を聞くことだけが RubyKaigiじゃない〜
tomohiko9090
0
100
抽象データ型について学んだ
ryounasso
0
210
CQRS/ESのクラスとシステムフロー ~ RailsでフルスクラッチでCQRSESを組んで みたことから得た学び~
suzukimar
0
190
MLOps Japan 勉強会 #52 - 特徴量を言語を越えて一貫して管理する, 『特徴量ドリブン』な MLOps の実現への試み
taniiicom
2
570
TypeScript Language Service Plugin で CSS Modules の開発体験を改善する
mizdra
PRO
3
2.4k
Agent Rules as Domain Parser
yodakeisuke
1
340
【TSkaigi 2025】これは型破り?型安全? 真実はいつもひとつ!(じゃないかもしれない)TypeScript クイズ〜〜〜〜!!!!!
kimitashoichi
1
300
コードに語らせよう――自己ドキュメント化が内包する楽しさについて / Let the Code Speak
nrslib
5
1k
Language Server と喋ろう – TSKaigi 2025
pizzacat83
2
670
Feature Flag 自動お掃除のための TypeScript プログラム変換
azrsh
PRO
4
630
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
512
110k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
42
2.3k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
15
890
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
32
5.8k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.6k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.6k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
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