Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
CoffeeScript Intro
Search
David Newell
March 22, 2013
Programming
110
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CoffeeScript Intro
An intro to coffeescript and comparison to javascript.
David Newell
March 22, 2013
More Decks by David Newell
See All by David Newell
Git and Hg
rustedgrail
1
110
Other Decks in Programming
See All in Programming
Security issues being discussed on Web Platforms
petamoriken
0
930
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
0
1.2k
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
150
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
330
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
2.7k
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
110
Omarchy Tokyo やると聞いて UMPC 買ってセットアップしてきた
mtsmfm
0
140
そのリトライ、死んだコネクションを使い回していませんか ── GoのHTTPクライアントとHTTP/2を実プロダクト障害から学び直す
myus4a
0
130
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
2
1.8k
A2UI for Android: Safely Rendering AI-Generated UI with Jetpack Compose - DroidKaigi 2026
itsmedreamwalker
0
130
Java 27新機能 / Java 27 new features
kishida
2
130
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
1
310
Featured
See All Featured
Joys of Absence: A Defence of Solitary Play
codingconduct
1
520
We Are The Robots
honzajavorek
0
370
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Building a Scalable Design System with Sketch
lauravandoore
464
34k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
How to Ace a Technical Interview
jacobian
281
24k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
240
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
42k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
330
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.8k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
830
Transcript
CoffeeScript "It's just JavaScript"
Installation $ npm install -g coffee-script -- OR -- $
https://github.com/jashkenas/coffee-script.git $ sudo bin/cake install -- THEN -- $ coffee -v
Editors with CoffeeScript Extensions •TextMate •Vim •Emacs •gedit •jEdit •IntelliJ
IDEA •IntelliJ RubyMine 4 •NetBeans •Eclipse •Cloud9
Hello World console.log 'hello world' $coffee -c hello.coffee (function() {
console.log('hello world'); }).call(this); console.log 'hello world' $coffee -c --bare hello.coffee console.log('hello world');
Functions greeting = (subject) -> "Hello #{subject}" console.log greeting "CSNY"
======================== var greeting; greeting = function(subject) { return "Hello " + subject; }; console.log(greeting("CSNY"));
Conditionals if typeof 5 is 'number' console.log '5 is odd'
unless 5 % 2 == 1 else throw '5 is not a number' ======================== if (typeof 5 === 'number') { if (5 % 2 !== 1) { console.log('5 is odd'); } } else { throw '5 is not a number'; }
Context setName = (@name) -> ======================== var setName; setName =
function(name) { return this.name = name; };
Fat Arrow save: -> client.open (err, p_client) => client.collection 'worker',
@add ======================== var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; (function() { return client.open(__bind(function(err, p_client) { return client.collection('worker', add); }, this)); });
Arguments (first = 1, rest...) -> ======================== (function() { var
first, rest; first = arguments[0], rest = 2 <= arguments.length ? __slice. call(arguments, 1) : []; if (first == null) { first = 1; }
JSON delta = '\u3094' greekUnicode = {delta} ======================== var delta,
greekUnicode; delta = '\u3094'; greekUnicode = { delta: delta };
Destructuring Assignment metaLanguages = javascript: coffeescript: ["Jeremy", "Ashkenas"] {javascript: {coffeescript:
[first, last]}} = metaLanguages ======================== metaLanguages = { javascript: { coffeescript: ["Jeremy", "Ashkenas"] } }; _ref = metaLanguages.javascript.coffeescript, first = _ref[0], last = _ref[1];
Comprehensions for a in [0..10] by 2 when a %
3 == 0 ======================== var a, _step; for (a = 0, _step = 2; a <= 10; a += _step) { if (a % 3 === 0) { console.log(a); } }
Existential Operator variable? variable ?= "A value" ======================== typeof variable
!== "undefined" && variable !== null; if (typeof variable !== "undefined" && variable !== null) { variable; } else { variable = "A value"; };
Classes class Snake extends Animal constructor: (@noise) -> super() Animal::bark()
var Snake; var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent)
{ for (var key in parent) { if (__hasProp.call(parent, key)) child [key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; Snake = (function() { __extends(Snake, Animal); function Snake(noise) { this.noise = noise; Snake.__super__.constructor.call(this, this.animal); Animal.prototype.noise(); } return Snake;
Watch Out! printing = -> console.log "Watch this" console.log printing
printing() $coffee printing.coffee [Function] Watch this
More Info -- Main Site -- http://jashkenas.github.com/coffee-script/ -- Little Book
on CoffeeScript -- http://arcturo.github.com/library/coffeescript/ -- Smooth-CoffeeScript -- http://autotelicum.github.com/Smooth-CoffeeScript/ -- CoffeeScript Koans -- http://cskoans.herokuapp.com/
Questions -- CoffeeScript Meetup -- http://www.meetup.com/Coffee-Script-New-York/ -- Code and Slides
-- https://github.com/rustedgrail/CoffeeScript-Intro -- CoffeeScript and Node Tower Defense -- http://qqtd.herokuapp.com/