Slide 1

Slide 1 text

CoffeeScript @20th Ruby Tuesday ৷ԈᎲ photo by gillyberlin

Slide 2

Slide 2 text

@20th Ruby Tuesday

Slide 3

Slide 3 text

You can get this slide on www.eddie.com.tw/slides

Slide 4

Slide 4 text

Who am I ?

Slide 5

Slide 5 text

I’m a Flash guy. photo by JD Hancock

Slide 6

Slide 6 text

hmm.. maybe only 60% Flasher and 40% Rubyist photo by Crashmaster007

Slide 7

Slide 7 text

a.k.a Eddie or Aquarianboy Live and work in Taipei, Taiwan. Serving in my own little tiny company. Flash / AS3 / Ruby / Rails / Python programming for living. A little bit Objective-C for personal inerests. Technical Education and Consulant. PTT Flash BM (since 2007/4). Adobe Certificaed Flash Developer (Since 2006/7). Linux Professional Institue Certification (Since 2005/3). ৷ԈᎲ photo by Eddie

Slide 8

Slide 8 text

or just google with the keyword "৷ԈᎲ"

Slide 9

Slide 9 text

JavaScript becomes hugely popular. 9th on TIOBE, Nov 2011 photo by gr3m

Slide 10

Slide 10 text

photo by Andrew

Slide 11

Slide 11 text

JavaScript seems easy.. photo by apple apple

Slide 12

Slide 12 text

But it’s also easy o get messy! photo by Marcus Q

Slide 13

Slide 13 text

CoffeeScript

Slide 14

Slide 14 text

photo by Nick Humphries We’re not alking about this kind of coffee.

Slide 15

Slide 15 text

Not this either. photo by naotoj

Slide 16

Slide 16 text

WTF?

Slide 17

Slide 17 text

CoffeeScript is JavaScript just written in different syntax

Slide 18

Slide 18 text

Who won't need this?

Slide 19

Slide 19 text

Who won't need this? people who already know javascrip(the good parts) very well.

Slide 20

Slide 20 text

What’s the problems?

Slide 21

Slide 21 text

photo by Steve Ganz

Slide 22

Slide 22 text

Bad smell.. Will it be equal? that’s the question. 0 == "" // true 1 == true // true 1 == "1" // true 1 == "1.0" // true "true" == true // true "true" === true // false

Slide 23

Slide 23 text

photo by Bryan Gosline What the..?

Slide 24

Slide 24 text

I really don't know how o wrie good JavaScript!

Slide 25

Slide 25 text

CoffeeScript exposes the good parts of JavaScript in a simple way.

Slide 26

Slide 26 text

Synax borrowed from Python and Ruby. I love Python & Ruby

Slide 27

Slide 27 text

If you’re already familiar with Ruby, you’ve probably already learned about 70% CoffeeScript.

Slide 28

Slide 28 text

Really friendly for Rubyist. love_coffeescript == true if rubyist

Slide 29

Slide 29 text

and compiles ino JavaScript code. *.coffee -> *.js

Slide 30

Slide 30 text

Your Brain -> JavaScript -> Browser

Slide 31

Slide 31 text

Your Brain -> Friendly CoffeeScript -> JavaScript -> Browser

Slide 32

Slide 32 text

But that doesn’t mean you can have no knowledge about JavaScript.

Slide 33

Slide 33 text

CoffeeScript is NOT used o replace JavaScript.

Slide 34

Slide 34 text

Let’s get our feet wet! photo by jlhopes

Slide 35

Slide 35 text

What are we looking at oday?

Slide 36

Slide 36 text

- Insallation - Usage - Synax

Slide 37

Slide 37 text

Insall photo by Daniel Dionne

Slide 38

Slide 38 text

Requirements You need o insall some software first.. Node.js > git clone git://github.com/joyent/node.git > cd node > ./configure > make > sudo make insall

Slide 39

Slide 39 text

Requirements You need o insall some software first.. NPM, the “node package manager” > curl http://npmjs.org/insall.sh | sh

Slide 40

Slide 40 text

Insall CoffeeScript CoffeeScript > npm insall coffee-script > coffee -v CoffeeScript version 1.1.3 http://blog.eddie.com.w/2011/08/03/install-coffeescrip/

Slide 41

Slide 41 text

Insall CoffeeScript CoffeeScript on MacOS > brew insall coffee-script http://blog.eddie.com.w/2011/08/03/install-coffeescrip/ ..and don’t forget insall the bundle for CoffeeScript if you’re using TextMae.

Slide 42

Slide 42 text

Insall CoffeeScript TextMae bundle forCoffeeScript, CMD+B = build, CMD+R = run https://github.com/jashkenas/coffee-scrip-tmbundle

Slide 43

Slide 43 text

Insall CoffeeScript TextMae bundle forCoffeeScript, CMD+B = build, CMD+R = run https://github.com/jashkenas/coffee-scrip-tmbundle

Slide 44

Slide 44 text

Insall CoffeeScript Windows?

Slide 45

Slide 45 text

Insall CoffeeScript Windows? get a mac

Slide 46

Slide 46 text

How o use photo by roboppy

Slide 47

Slide 47 text

Usage Compile *.coffee ino *.js > coffee --wach --compile app.coffee http://blog.eddie.com.w/2011/08/03/how-to-use-coffeescrip-compiler/

Slide 48

Slide 48 text

Usage Compile *.coffee ino *.js > coffee --wach --compile app.coffee http://blog.eddie.com.w/2011/08/03/how-to-use-coffeescrip-compiler/

Slide 49

Slide 49 text

Usage you got a REPL, just like irb.

Slide 50

Slide 50 text

Usage you got a REPL, just like irb.

Slide 51

Slide 51 text

Don’t like o compile? You can run CoffeeScrip in HTML directly

Slide 52

Slide 52 text

Use CoffeeScript on the fly

Slide 53

Slide 53 text

Use CoffeeScript on the fly

Slide 54

Slide 54 text

Use CoffeeScript on the fly alert 'est'

Slide 55

Slide 55 text

Use CoffeeScript on the fly alert 'est'

Slide 56

Slide 56 text

don’t do this in your production.

Slide 57

Slide 57 text

Synax photo by zigazou76

Slide 58

Slide 58 text

} } } }

Slide 59

Slide 59 text

No { } indenations rule! whitespace matters!

Slide 60

Slide 60 text

( ) is not always necessary. Just like Ruby

Slide 61

Slide 61 text

but.. hello +5 means hello(+5) + : convert string to number

Slide 62

Slide 62 text

No trailing semicolon.

Slide 63

Slide 63 text

Return is not necessary. everything is an expression, just like Ruby.

Slide 64

Slide 64 text

No { }, (), and ;

Slide 65

Slide 65 text

No { }, (), and ; // javascript if(age > 20){ voe(); }

Slide 66

Slide 66 text

No { }, (), and ; // javascript if(age > 20){ voe(); } # coffeescript if age > 20 voe()

Slide 67

Slide 67 text

Variables

Slide 68

Slide 68 text

Variable You don’t have o declare it before using it.

Slide 69

Slide 69 text

Variable You don’t have o declare it before using it. # coffeescript lang = ["php", "python", "perl", "ruby"] name = "Eddie"

Slide 70

Slide 70 text

Variable You don’t have o declare it before using it. # coffeescript lang = ["php", "python", "perl", "ruby"] name = "Eddie" // javascript var lang, name; lang = ["php", "python", "perl", "ruby"]; name = "Eddie";

Slide 71

Slide 71 text

Variable Destructuring Assignment

Slide 72

Slide 72 text

Variable Destructuring Assignment # coffeescript x = 100 y = 10 [x, y] = [y, x]

Slide 73

Slide 73 text

Variable Destructuring Assignment # coffeescript x = 100 y = 10 [x, y] = [y, x] // javascript var x, y, _ref; x = 100; y = 10; _ref = [y, x], x = _ref[0], y = _ref[1];

Slide 74

Slide 74 text

Variable Destructuring Assignment

Slide 75

Slide 75 text

Variable Destructuring Assignment # coffeescript weatherReport = (location) -> [location, 72, "Mostly Sunny"] [city, emp, forecast] = weatherReport "Berkeley, CA"

Slide 76

Slide 76 text

Variable Destructuring Assignment # coffeescript ag = "" [open, conents..., close] = ag.split("") # coffeescript weatherReport = (location) -> [location, 72, "Mostly Sunny"] [city, emp, forecast] = weatherReport "Berkeley, CA"

Slide 77

Slide 77 text

Function

Slide 78

Slide 78 text

-> dash rocket

Slide 79

Slide 79 text

->""<- enjoy coding :) Not

Slide 80

Slide 80 text

-> "hello, Ruby Tuesday"

Slide 81

Slide 81 text

-> "hello, Ruby Tuesday" (function() { return "hello, Ruby Tuesday"; });

Slide 82

Slide 82 text

Function

Slide 83

Slide 83 text

Function # coffeescript say_hello = (guest1, guest2 = "Nayumi") -> "Hello #{guest1} and #{guest2}" say_hello "Eddie"

Slide 84

Slide 84 text

Function # coffeescript say_hello = (guest1, guest2 = "Nayumi") -> "Hello #{guest1} and #{guest2}" say_hello "Eddie" // javascript var say_hello; say_hello = function(guest1, guest2) { if (guest2 == null) { guest2 = "Nayumi"; } return "Hello " + guest1 + " and " + guest2; }; say_hello("Eddie");

Slide 85

Slide 85 text

=> fat arrow http://blog.eddie.com.w/2011/11/18/dash-rocket-vs-fat-arrow-in-coffeescrip/

Slide 86

Slide 86 text

Global Variables

Slide 87

Slide 87 text

Global Variables (function() { }).call(this);

Slide 88

Slide 88 text

Slide 89

Slide 89 text

http://blog.eddie.com.w/2011/11/18/global-variables-in-coffeescrip/

Slide 90

Slide 90 text

http://blog.eddie.com.w/2011/11/18/global-variables-in-coffeescrip/ window.logout = -> alert "You've already logout!" if confirm "logout!?" # coffeescript

Slide 91

Slide 91 text

http://blog.eddie.com.w/2011/11/18/global-variables-in-coffeescrip/ window.logout = -> alert "You've already logout!" if confirm "logout!?" # coffeescript root = exports ? this root.logout = -> alert "You've already logout!" if confirm "logout!?" # coffeescript

Slide 92

Slide 92 text

http://blog.eddie.com.w/2011/11/18/global-variables-in-coffeescrip/ window.logout = -> alert "You've already logout!" if confirm "logout!?" # coffeescript root = exports ? this root.logout = -> alert "You've already logout!" if confirm "logout!?" # coffeescript

Slide 93

Slide 93 text

Splats Just like Ruby

Slide 94

Slide 94 text

...

Slide 95

Slide 95 text

Splats

Slide 96

Slide 96 text

Splats # coffeescript sum = (nums...) -> result = 0 result += n for n in nums result console.log sum(1, 2, 3, 4, 5)

Slide 97

Slide 97 text

Array

Slide 98

Slide 98 text

Array // javascript # coffeescript

Slide 99

Slide 99 text

Array // javascript # coffeescript heroes = [ 'Spider Man', 'Capain America', 'X-men', 'Iron Man' ]

Slide 100

Slide 100 text

Array // javascript # coffeescript heroes = [ 'Spider Man', 'Capain America', 'X-men', 'Iron Man' ] var heroes, students, eachers; heroes = ['Spider Man', 'Capain America', 'X-men', 'Iron Man'];

Slide 101

Slide 101 text

Array // javascript # coffeescript heroes = [ 'Spider Man', 'Capain America', 'X-men', 'Iron Man' ] var heroes, students, eachers; heroes = ['Spider Man', 'Capain America', 'X-men', 'Iron Man']; students = [1..10]

Slide 102

Slide 102 text

Array // javascript # coffeescript heroes = [ 'Spider Man', 'Capain America', 'X-men', 'Iron Man' ] var heroes, students, eachers; heroes = ['Spider Man', 'Capain America', 'X-men', 'Iron Man']; students = [1..10] students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

Slide 103

Slide 103 text

Array // javascript # coffeescript heroes = [ 'Spider Man', 'Capain America', 'X-men', 'Iron Man' ] var heroes, students, eachers; heroes = ['Spider Man', 'Capain America', 'X-men', 'Iron Man']; students = [1..10] eachers = [1...10] students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

Slide 104

Slide 104 text

Array // javascript # coffeescript heroes = [ 'Spider Man', 'Capain America', 'X-men', 'Iron Man' ] var heroes, students, eachers; heroes = ['Spider Man', 'Capain America', 'X-men', 'Iron Man']; students = [1..10] eachers = [1...10] eachers = [1, 2, 3, 4, 5, 6, 7, 8, 9]; students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

Slide 105

Slide 105 text

Array # coffeescript // javascript

Slide 106

Slide 106 text

Array # coffeescript // javascript heroes[0..2]

Slide 107

Slide 107 text

Array # coffeescript // javascript heroes[0..2] heroes.slice(0, 3);

Slide 108

Slide 108 text

Array # coffeescript // javascript heroes[0..2] heroes[1..2] = ["Batman", "ThunderCat"] heroes.slice(0, 3);

Slide 109

Slide 109 text

Array # coffeescript // javascript heroes[0..2] heroes[1..2] = ["Batman", "ThunderCat"] var _ref; [].splice.apply(heroes, [1, 2].concat(_ref = ["Batman", "ThunderCat"])), _ref; heroes.slice(0, 3);

Slide 110

Slide 110 text

Object

Slide 111

Slide 111 text

Object

Slide 112

Slide 112 text

Object # coffeescript eddie = { name: "Eddie Kao", age: 18, speciality: "eat" }

Slide 113

Slide 113 text

Object # coffeescript eddie = { name: "Eddie Kao", age: 18, speciality: "eat" } // javascript var eddie; eddie = { name: "Eddie Kao", age: 18, speciality: "eat" };

Slide 114

Slide 114 text

Object

Slide 115

Slide 115 text

Object # coffeescript eddie = name: "Eddie Kao" age: 18 lovers: nayumi: name: "Nayumi Hung" age: 18 mary: name: "Mary Bloody" age: 20

Slide 116

Slide 116 text

Object # coffeescript eddie = name: "Eddie Kao" age: 18 lovers: nayumi: name: "Nayumi Hung" age: 18 mary: name: "Mary Bloody" age: 20 // javascript var eddie; eddie = { name: "Eddie Kao", age: 18, lovers: { nayumi: { name: "Nayumi Hung", age: 18 }, mary: { name: "Mary Bloody", age: 20 } } };

Slide 117

Slide 117 text

Loop

Slide 118

Slide 118 text

But we Rubyist barely use for-loop

Slide 119

Slide 119 text

List Comprehension # coffeescript // javascript

Slide 120

Slide 120 text

List Comprehension # coffeescript // javascript alert i for i in [1..10]

Slide 121

Slide 121 text

List Comprehension # coffeescript // javascript alert i for i in [1..10] var i, _sep; for (i = 1; i <= 10; i++) { alert(i); }

Slide 122

Slide 122 text

List Comprehension # coffeescript // javascript alert i for i in [1..10] var i, _sep; for (i = 1; i <= 10; i++) { alert(i); } alert i for i in [1..10] when i % 2 == 0

Slide 123

Slide 123 text

List Comprehension # coffeescript // javascript alert i for i in [1..10] var i, _sep; for (i = 1; i <= 10; i++) { alert(i); } alert i for i in [1..10] when i % 2 == 0 for (i = 1; i <= 10; i++) { if (i % 2 === 0) { alert(i); } }

Slide 124

Slide 124 text

List Comprehension # coffeescript // javascript alert i for i in [1..10] var i, _sep; for (i = 1; i <= 10; i++) { alert(i); } alert i for i in [1..10] when i % 2 == 0 alert i for i in [1..10] by 2 for (i = 1; i <= 10; i++) { if (i % 2 === 0) { alert(i); } }

Slide 125

Slide 125 text

List Comprehension # coffeescript // javascript alert i for i in [1..10] var i, _sep; for (i = 1; i <= 10; i++) { alert(i); } alert i for i in [1..10] when i % 2 == 0 alert i for i in [1..10] by 2 for (i = 1; i <= 10; i++) { if (i % 2 === 0) { alert(i); } } for (i = 1, _sep = 2; i <= 10; i += _sep) { alert(i); }

Slide 126

Slide 126 text

List Comprehension # coffeescript // javascript alert i for i in [1..10] var i, _sep; for (i = 1; i <= 10; i++) { alert(i); } alert i for i in [1..10] when i % 2 == 0 alert i for i in [1..10] by 2 alert i * 2 for i in [1..10] for (i = 1; i <= 10; i++) { if (i % 2 === 0) { alert(i); } } for (i = 1, _sep = 2; i <= 10; i += _sep) { alert(i); }

Slide 127

Slide 127 text

List Comprehension # coffeescript // javascript alert i for i in [1..10] var i, _sep; for (i = 1; i <= 10; i++) { alert(i); } alert i for i in [1..10] when i % 2 == 0 alert i for i in [1..10] by 2 alert i * 2 for i in [1..10] for (i = 1; i <= 10; i++) { if (i % 2 === 0) { alert(i); } } for (i = 1, _sep = 2; i <= 10; i += _sep) { alert(i); } for (i = 1; i <= 10; i++) { alert(i * 2); }

Slide 128

Slide 128 text

Condition

Slide 129

Slide 129 text

Swich # coffeescript swich day when "Mon" then go work when "Tue" then go relax when "Thu" then go iceFishing when "Fri", "Sat" if day is bingoDay go bingo go dancing when "Sun" then go church else go work

Slide 130

Slide 130 text

Modifier You can put "if", "unless", "while", "until" behind

Slide 131

Slide 131 text

Modifier You can put "if", "unless", "while", "until" behind // javascript if (age > 20) { voe(); }

Slide 132

Slide 132 text

Modifier You can put "if", "unless", "while", "until" behind # coffeescript voe() if age > 20 // javascript if (age > 20) { voe(); }

Slide 133

Slide 133 text

Synactic Sugar

Slide 134

Slide 134 text

Synactic Sugar # coffeescript // javascript wrie more readable code by using synactic sugar.

Slide 135

Slide 135 text

Synactic Sugar # coffeescript // javascript wrie more readable code by using synactic sugar. is === isnt !== true, on, yes true false, off, no false not ! and && or || unless if not until while not of in

Slide 136

Slide 136 text

# coffeescript Synactic Sugar

Slide 137

Slide 137 text

# coffeescript Synactic Sugar alert "I can't see anything" if light is off

Slide 138

Slide 138 text

# coffeescript Synactic Sugar alert "I can't see anything" if light is off alert "It's impossible!" if eddie isnt handsome

Slide 139

Slide 139 text

# coffeescript Synactic Sugar alert "I can't see anything" if light is off alert "It's impossible!" if eddie isnt handsome if girl is not single alert "Don't Touch! Be Careful!"

Slide 140

Slide 140 text

// javascript Synactic Sugar

Slide 141

Slide 141 text

// javascript Synactic Sugar if (light === false) { alert("I can't see anything"); } if (eddie !== handsome) { alert("It's impossible!"); } if (girl === !single) { alert("Don't Touch! Be Careful!"); }

Slide 142

Slide 142 text

Synactic Sugar Which answer do you like o hear when you say ...

Slide 143

Slide 143 text

Synactic Sugar Which answer do you like o hear when you say ... Eddie: Will you marry me? Nayumi: yes!

Slide 144

Slide 144 text

Synactic Sugar Which answer do you like o hear when you say ... Eddie: Will you marry me? Nayumi: yes! or Eddie: Will you marry me? Nayumi: true!

Slide 145

Slide 145 text

Synactic Sugar

Slide 146

Slide 146 text

Synactic Sugar # coffeescript alert "I'll marry you!" if answer is yes

Slide 147

Slide 147 text

Synactic Sugar // javascript if (answer === true) { alert("I'll marry you!"); } # coffeescript alert "I'll marry you!" if answer is yes

Slide 148

Slide 148 text

Synactic Sugar Chained Comparison

Slide 149

Slide 149 text

Synactic Sugar # coffeescript console.log "I'm awesome!" if 20 < my_girl_friends < 100 Chained Comparison

Slide 150

Slide 150 text

Synactic Sugar // javascript if ((20 < my_girl_friends && my_girl_friends < 100)) { console.log("I'm awesome!"); } # coffeescript console.log "I'm awesome!" if 20 < my_girl_friends < 100 Chained Comparison

Slide 151

Slide 151 text

Synactic Sugar Exisential Operaor

Slide 152

Slide 152 text

Synactic Sugar # coffeescript age ?= 18 Exisential Operaor

Slide 153

Slide 153 text

Synactic Sugar # coffeescript age ?= 18 // javascript if (typeof age !== "undefined" && age !== null) { age; } else { age = 18; }; Exisential Operaor

Slide 154

Slide 154 text

Raw JavaScript If you still prefer the original way..

Slide 155

Slide 155 text

Raw JavaScript

Slide 156

Slide 156 text

Raw JavaScript # coffeescript say_hello = `function(name){ return "Hello, " + name }`

Slide 157

Slide 157 text

OOP

Slide 158

Slide 158 text

OOP CoffeeScrip's classes are syntactic sugar only.

Slide 159

Slide 159 text

Prootype?

Slide 160

Slide 160 text

Prootype? IMHO, prooype-based OO is no elegant

Slide 161

Slide 161 text

OOP - new

Slide 162

Slide 162 text

OOP - new # coffeescript class Animal construcor: (name, age) -> this.name = name this.age = age animal = new Animal("eddie", 18) alert animal

Slide 163

Slide 163 text

OOP - new # coffeescript class Animal construcor: (name, age) -> this.name = name this.age = age animal = new Animal("eddie", 18) alert animal // javascript var Animal, animal; Animal = (function() { function Animal(name, age) { this.name = name; this.age = age; } return Animal; })(); animal = new Animal("eddie", 18); alert(animal);

Slide 164

Slide 164 text

OOP - @ = this.

Slide 165

Slide 165 text

OOP - @ = this.

Slide 166

Slide 166 text

# coffeescript OOP - method

Slide 167

Slide 167 text

# coffeescript OOP - method class Animal construcor: (@name, @age) -> say_hello: (something) -> console.log "Hello, #{something}" animal = new Animal("eddie", 18) animal.say_hello("CoffeeScript")

Slide 168

Slide 168 text

OOP - inheriance

Slide 169

Slide 169 text

OOP - inheriance # coffeescript class Animal construcor: (@name, @age) -> say_hello: (something) -> alert "Hello, #{something}" class Human exends Animal walk: -> alert "I can walk with my foots!" eddie = new Human("eddie", 18) eddie.say_hello "CoffeeScript" eddie.walk()

Slide 170

Slide 170 text

OOP - inheriance

Slide 171

Slide 171 text

OOP - inheriance

Slide 172

Slide 172 text

TL;DR

Slide 173

Slide 173 text

Exend more function?

Slide 174

Slide 174 text

Exend more function http://blog.eddie.com.w/2011/11/19/extend-functionaliy-for-your-class/

Slide 175

Slide 175 text

Exend more function # coffeescript String::repeat = (n) -> Array(n + 1).join @ String::downcase = -> @oLowerCase() String::upcase = -> @oUpperCase() String::find = (str) -> @indexOf str String::has = (str) -> (@indexOf str) > 0 http://blog.eddie.com.w/2011/11/19/extend-functionaliy-for-your-class/

Slide 176

Slide 176 text

Cooperae with other JS library or framework?

Slide 177

Slide 177 text

working with jQuery

Slide 178

Slide 178 text

working with jQuery // javascript $(document).ready(function() { wakeup(); walk_o_oilet(); pee(); go_back_o_sleep(); })

Slide 179

Slide 179 text

working with jQuery # coffeescript $ -> wakeup() walk_o_oilet() pee() go_back_o_sleep() // javascript $(document).ready(function() { wakeup(); walk_o_oilet(); pee(); go_back_o_sleep(); })

Slide 180

Slide 180 text

working with jQuery

Slide 181

Slide 181 text

working with jQuery // javascript $('#girl').animae({ width: '100px', height: '50px', opacity: '0.8' }, 2000, 'easeOutQuad');

Slide 182

Slide 182 text

working with jQuery # coffeescript $('#girl').animae width: '100px' height: '50px' opacity: '0.8' 2000 'easeOutQuad' // javascript $('#girl').animae({ width: '100px', height: '50px', opacity: '0.8' }, 2000, 'easeOutQuad');

Slide 183

Slide 183 text

working with jQuery

Slide 184

Slide 184 text

working with jQuery // javascript (function($){ $.fn.exend({ isEmail: function(email){ return /some email validaor/.est(email); } }); })(Query);

Slide 185

Slide 185 text

working with jQuery # coffeescript $ = jQuery $.fn.exend isEmail: (email) -> /some email validaor/.est email // javascript (function($){ $.fn.exend({ isEmail: function(email){ return /some email validaor/.est(email); } }); })(Query);

Slide 186

Slide 186 text

makes jQuery more easy, and more fun http://blog.eddie.com.w/2011/11/14/when-jquery-meets-coffeescrip/

Slide 187

Slide 187 text

References http://blog.eddie.com.w/category/coffeescrip/ http://jashkenas.github.com/coffee-scrip/ Websies: https://github.com/sleepyfox/coffeescrip-koans http://upgrade2rails31.com/coffee-scrip Koans:

Slide 188

Slide 188 text

References http://pragprog.com/book/tbcoffee/coffeescrip Book: http://arcturo.github.com/library/coffeescrip/index.html http://autoelicum.github.com/Smooh-CoffeeScrip/

Slide 189

Slide 189 text

Conclusion

Slide 190

Slide 190 text

being a 40% Rubyist I don’t like..

Slide 191

Slide 191 text

being a 40% Rubyist I don’t like.. var

Slide 192

Slide 192 text

being a 40% Rubyist I don’t like.. var return

Slide 193

Slide 193 text

being a 40% Rubyist I don’t like.. var return for loop

Slide 194

Slide 194 text

being a 40% Rubyist I don’t like.. var return for loop ()

Slide 195

Slide 195 text

being a 40% Rubyist I don’t like.. var return for loop () {}

Slide 196

Slide 196 text

I Love..

Slide 197

Slide 197 text

Coding Style I Love.. I love Python & Ruby, of course :)

Slide 198

Slide 198 text

Indenation! I Love..

Slide 199

Slide 199 text

Anonymous function No global function and variable by default I Love..

Slide 200

Slide 200 text

String Inerpolation I Love.. sorry, but string building really sucks :)

Slide 201

Slide 201 text

List Comprehension I Love..

Slide 202

Slide 202 text

Synactic Sugar I Love..

Slide 203

Slide 203 text

English-like grammar I Love.. alert "of course it is!" if ruby_tuesday is awesome

Slide 204

Slide 204 text

Comparison & Equality I Love.. "true" == true // true "true" === true // false

Slide 205

Slide 205 text

Works with other JS frameworks well. Because it’s just JavaScrip I Love..

Slide 206

Slide 206 text

Compilation I Love.. JSLint Approved

Slide 207

Slide 207 text

What else?

Slide 208

Slide 208 text

Make, Rake, Cake.

Slide 209

Slide 209 text

More and more projects are writen in CoffeeScript.

Slide 210

Slide 210 text

Pow.cx

Slide 211

Slide 211 text

CoffeeScript compiler is writen in CoffeeScript.

Slide 212

Slide 212 text

Tianium Mobile http://blog.eddie.com.w/2011/08/03/using-coffeescrip-in-titanium-studio/

Slide 213

Slide 213 text

Immature? photo by theseanster93

Slide 214

Slide 214 text

Performance? photo by theseanster93 photo by chr1sl4i

Slide 215

Slide 215 text

CoffeeScript Means Giving Up on JavaScript?

Slide 216

Slide 216 text

Learn JavaScript, and Use CoffeeScript.

Slide 217

Slide 217 text

Any Question? photo by jamuraa

Slide 218

Slide 218 text

৷ԈᎲ Conacts photo by Eddie Websie Blog Plurk Facebook Google Plus Twiter Email Mobile http://www.eddie.com.tw http://blog.eddie.com.tw http://www.plurk.com/aquarianboy http://www.facebook.com/eddiekao http://www.eddie.com.tw/+ https://twiter.com/#!/eddiekao [email protected] +886-928-617-687