Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Happy Programming with CoffeeScript

Happy Programming with CoffeeScript

Dbfa12cd7e1ff8b06a588609369d6e49?s=128

高見龍

May 18, 2012
Tweet

Transcript

  1. Happy Programming with CoffeeScript 高見見龍龍 photo by yukop

  2. 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 inerests. Technical Education and Consulant. PTT Flash BM (since 2007/4). Ruby Certified Programmer (Since 2012/1). Adobe Certified Flash Developer (Since 2006/7). Linux Professional Institue Certification (Since 2005/3). 高見見龍龍 photo by Eddie
  3. None
  4. Intro 簡介

  5. Popular

  6. Powerful Popular

  7. Complicaed Powerful Popular

  8. Before photo by Razlan

  9. Now photo by Razlan

  10. seems easy photo by apple apple

  11. photo by Marcus Q

  12. Today, I am going o ell you..

  13. Happy 快樂

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

    of coffee.
  15. Not this either. photo by naotoj

  16. I have no idea why engineers like using food as

    their project name.
  17. Jeremy Ashkenas photo by jsconf

  18. 2009/12

  19. and I sared o use CoffeeScript since 2011/5

  20. and I sared o use CoffeeScript since 2011/5 because of

    Rails
  21. None
  22. yet another new language !?

  23. None
  24. "It's just JavaScript"

  25. just writen in different synax

  26. borrowed from Python, Ruby and Haskell.

  27. and would be compiled ino JavaScript code

  28. JSLint Compatible

  29. So, it's still Javascript

  30. "hmm.."

  31. "It's just JavaScript"

  32. "It's just JavaScript"

  33. "I think it's just CoffeeScript"

  34. whaever.. WTH can you do with CoffeeScript?

  35. anything which JavaScript can do.

  36. front-end, back-end, mobile.. ec.

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

  38. CoffeeScript compiler is writen in CoffeeScript

  39. photo by Bryan Gosline Is JavaScript that bad?

  40. photo by Steve Ganz the good parts

  41. CoffeeScript = English-like grammar + nice Synactic Sugar + Goodies

  42. Syntax 語法

  43. indenations rule, whiespace maters!

  44. } } } }

  45. } } } }

  46. None
  47. String Inerpolation

  48. greeting = "hi, " + name + ", " +

    msg
  49. greeting = "hi, #{name}, #{msg}"

  50. semicolon

  51. semicolon

  52. var

  53. var

  54. ->

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

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

  57. default parameer

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

  59. var say_something; say_something = function(msg) { if (msg == null)

    { msg = "JSDC"; } return console.log("say " + msg); };
  60. ( ) is not always necessary.

  61. greeting("eddie", "how are you");

  62. greeting "eddie", "how are you"

  63. everything is an expression

  64. return is not necessary.

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

  66. hello = -> "hi, JSDC"

  67. Array

  68. var a; a = [1, 2, 3, 4, 5, 6,

    7, 8, 9, 10];
  69. a = [1..10]

  70. Loop

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

  72. var i, _i; for (i = _i = 1; _i

    <= 10; i = ++_i) { console.log(i); }
  73. console.log "YES" if oday == 'JSDC'

  74. Sugar

  75. yes, no

  76. A: “would you marry me?” B: true

  77. A: “would you marry me?” B: yes

  78. console.log "go home" if oday isnt "JSDC"

  79. OO

  80. Hello.prootype.greeting = function(name) { console.log("hi, " + name); };

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

  82. class Hello construcor: (@name) -> greeting: (msg) -> "hi, #{@name},

    #{msg}"
  83. var Hello; Hello = (function() { Hello.name = 'Hello'; function

    Hello(name) { this.name = name; } Hello.prootype.greeting = function(msg) { return "hi, " + this.name + ", " + msg; }; return Hello; })();
  84. Diff? 差別?

  85. Your Brain JavaScript Browser the Original Way

  86. Your Brain JavaScript Browser the CoffeeScript way CoffeeScript

  87. None
  88. lots of languages that compile o JS http://goo.gl/nkAkQ

  89. Ref 參考

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

  91. or my shameless promotion blog http://blog.eddie.com.tw/caegory/coffeescript/

  92. Let’s get our feet wet! photo by jlhopes

  93. Demo 展示

  94. But.. 巴特..

  95. CoffeeScript is not so perfect

  96. Readability != Comprehension

  97. People may still wrie CoffeeScript as horribly as they wroe

    JavaScript..
  98. indenations rule, whiespace maters!

  99. ( ) is not always necessary.

  100. Debugging ool?

  101. You've beter have a human CoffeeScript compiler in your head!

  102. Then.. 然後..

  103. CoffeeScript is not used o replace JavaScript.

  104. If you don’t know Javascript, and you think CoffeeScript can

    save your life..
  105. you would be in trouble.

  106. So.. 所以..

  107. Who is using CoffeeScript?

  108. actually, I don't really care!

  109. Who won't need this?

  110. People who don't like CoffeeScript.

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

  112. Who might need/like this?

  113. someone who don't like ;

  114. someone who don't like { }

  115. someone who don't like the PROTOTYPE.

  116. Rails developer

  117. Anyway 總之

  118. Should I learn CoffeeScript?

  119. Is it worth it?

  120. IMHO 拙見

  121. You should..

  122. learn JavaScript!

  123. learn JavaScript!

  124. learn JavaScript!

  125. learn JavaScript!

  126. .. and use CoffeeScript !

  127. oally worth it!

  128. I can't go back anymore!

  129. give it a try

  130. Happy? 快樂?

  131. END 結束

  132. 高見見龍龍 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 eddie@digik.com.tw +886-928-617-687