132
Happy Programming with CoffeeScript photo by yukop

Happy Programming with CoffeeScript - 高見龍 · Flash / AS3 / Ruby / Rails / Python programming for living. Mac OS user, Objective-C for personal inerests. Technical Education

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

  • Happy Programming with CoffeeScript

    高見見龍龍photo by yukop

    http://www.flickr.com/photos/yukop/http://www.flickr.com/photos/yukop/

  • 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. Mac OS user, Objective-C for personal inerests. Technical Education and Consulant.

    PTT Flash BM (since 2007/4). Ruby Certified Programmer (Since 2012/1). Adobe Certified Flash Developer (Since 2006/7). Linux Professional Institue Certification (Since 2005/3).

    高見見龍龍

    photo by Eddie

    http://www.eddie.com.twhttp://www.eddie.com.tw

  • Intro簡介

  • Popular

  • Powerful

    Popular

  • Complicaed

    Powerful

    Popular

  • Beforephoto by Razlan

    http://www.flickr.com/photos/razlan79/http://www.flickr.com/photos/razlan79/

  • Nowphoto by Razlan

    http://www.flickr.com/photos/razlan79/http://www.flickr.com/photos/razlan79/

  • seems easy

    photo by apple apple

    http://www.flickr.com/photos/setrowbridge/http://www.flickr.com/photos/setrowbridge/

  • photo by Marcus Q

    http://www.flickr.com/photos/marcusq/http://www.flickr.com/photos/marcusq/

  • Today, I am going o ell you..

  • Happy快樂

  • photo by Nick Humphries

    We’re not alking

    about this kind of coffee.

    http://www.flickr.com/photos/nickhumphries/http://www.flickr.com/photos/nickhumphries/

  • Not this either.

    photo by naotoj

    http://www.flickr.com/photos/naotoj/http://www.flickr.com/photos/naotoj/

  • I have no idea why engineers like using food as their project name.

  • Jeremy Ashkenas

    photo by jsconf

    http://www.flickr.com/photos/jsconf/http://www.flickr.com/photos/jsconf/

  • 2009/12

  • and I sared o use CoffeeScript since 2011/5

  • and I sared o use CoffeeScript since 2011/5

    because of Rails

  • yet another new language !?

  • "It's just JavaScript"

  • just writen in different synax

  • borrowed from Python, Ruby and Haskell.

  • and would be compiled ino JavaScript code

  • JSLint Compatible

  • So, it's still Javascript

  • "hmm.."

  • "It's just JavaScript"

  • "It's just JavaScript"

  • "I think it's just CoffeeScript"

  • whaever..

    WTH can you do with CoffeeScript?

  • anything which JavaScript can do.

  • front-end, back-end, mobile.. ec.

  • but with less line of code..~ 30% off

  • CoffeeScript compiler is writen in CoffeeScript

  • photo by Bryan Gosline

    Is JavaScript

    that bad?

    http://www.flickr.com/photos/brymo/http://www.flickr.com/photos/brymo/

  • photo by Steve Ganz

    the good parts

    http://www.flickr.com/photos/steveganz/http://www.flickr.com/photos/steveganz/

  • CoffeeScript =English-like grammar + nice Synactic Sugar +

    Goodies

  • Syntax語法

  • indenations rule, whiespace maters!

  • } } } }

  • } } } }

  • String Inerpolation

  • greeting = "hi, " + name + ", " + msg

  • greeting = "hi, #{name}, #{msg}"

  • semicolon

  • semicolon

  • var

  • var

  • ->

  • say_hello = (msg) -> console.log "hello, JSDC"

  • var say_hello;say_hello = function(msg) { return console.log("hello, JSDC");};

  • default parameer

  • say_something = (msg = "JSDC") -> console.log "say #{msg}"

  • var say_something;

    say_something = function(msg) { if (msg == null) { msg = "JSDC"; } return console.log("say " + msg);};

  • ( ) is not always necessary.

  • greeting("eddie", "how are you");

  • greeting "eddie", "how are you"

  • everything is an expression

  • return is not necessary.

  • var hello;

    hello = function() { return "hi, JSDC";};

  • hello = -> "hi, JSDC"

  • Array

  • var a;a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

  • a = [1..10]

  • Loop

  • console.log i for i in [1..10]

  • var i, _i;

    for (i = _i = 1; _i

  • console.log "YES" if oday == 'JSDC'

  • Sugar

  • yes, no

  • A: “would you marry me?”B: true

  • A: “would you marry me?”B: yes

  • console.log "go home" if oday isnt "JSDC"

  • OO

  • Hello.prootype.greeting = function(name) { console.log("hi, " + name);};

  • class Hello greeting: (name) -> console.log "hi, #{name}"

  • class Hello construcor: (@name) ->

    greeting: (msg) -> "hi, #{@name}, #{msg}"

  • var Hello;Hello = (function() { Hello.name = 'Hello'; function Hello(name) { this.name = name; } Hello.prootype.greeting = function(msg) { return "hi, " + this.name + ", " + msg; }; return Hello;})();

  • Diff?差別?

  • Your Brain

    JavaScript

    Browser

    the Original Way

  • Your Brain

    JavaScript

    Browser

    the CoffeeScript way

    CoffeeScript

  • lots of languages that compile o JShttp://goo.gl/nkAkQ

    http://goo.gl/nkAkQhttp://goo.gl/nkAkQ

  • Ref參考

  • RTFM, it's awesome!http://coffeescript.org/

    http://coffeescript.org/http://coffeescript.org/

  • or my shameless promotion bloghttp://blog.eddie.com.tw/caegory/coffeescript/

    http://blog.eddie.com.tw/category/coffeescript/http://blog.eddie.com.tw/category/coffeescript/

  • Let’s get our feet wet!photo by jlhopes

    http://www.flickr.com/photos/dwe/http://www.flickr.com/photos/dwe/

  • Demo展示

  • But..巴特..

  • CoffeeScript is not so perfect

  • Readability != Comprehension

  • People may still wrie CoffeeScript as horribly as they

    wroe JavaScript..

  • indenations rule, whiespace maters!

  • ( ) is not always necessary.

  • Debugging ool?

  • You've beter have a human CoffeeScript compiler in your head!

  • Then..然後..

  • CoffeeScript is not used o replace JavaScript.

  • If you don’t know Javascript, and you think CoffeeScript can save your life..

  • you would be in trouble.

  • So..所以..

  • Who is using CoffeeScript?

  • actually, I don't really care!

  • Who won't need this?

  • People who don't like CoffeeScript.

  • People who already know javascript(the good parts) very well.

  • Who might need/like this?

  • someone who don't like ;

  • someone who don't like { }

  • someone who don't like the PROTOTYPE.

  • Rails developer

  • Anyway總之

  • Should I learn CoffeeScript?

  • Is it worth it?

  • IMHO拙見

  • You should..

  • learn JavaScript!

  • learn JavaScript!

  • learn JavaScript!

  • learn JavaScript!

  • .. and use CoffeeScript !

  • oally worth it!

  • I can't go back anymore!

  • give it a try

  • Happy?快樂?

  • END結束

  • 高見見龍龍Conacts

    photo by Eddie

    Websie

    Blog

    Plurk

    Facebook

    Google Plus

    Twiter

    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://twiter.com/#!/eddiekao

    [email protected]

    +886-928-617-687

    http://www.eddie.com.twhttp://www.eddie.com.twhttp://www.eddie.com.twhttp://www.eddie.com.twhttp://blog.eddie.com.twhttp://blog.eddie.com.twhttp://www.plurk.com/aquarianboyhttp://www.plurk.com/aquarianboyhttp://www.facebook.com/eddiekaohttp://www.facebook.com/eddiekaohttp://www.eddie.com.tw/+http://www.eddie.com.tw/+https://twitter.com/#!/eddiekaohttps://twitter.com/#!/eddiekaomailto:[email protected]:[email protected]