132
Happy Programming with CoffeeScript photo by yukop

Happy Programming with CoffeeScript

Embed Size (px)

Citation preview

  • 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 inerests. Technical Education and Consulant. PTT Flash BM (since 2007/4). Ruby Certied Programmer (Since 2012/1). Adobe Certied Flash Developer (Since 2006/7). Linux Professional Institue Certication (Since 2005/3). photo by Eddie 3. Intro 4. Popular 5. PopularPowerful 6. Popular PowerfulComplicaed 7. Before photo by Razlan 8. photo by RazlanNow 9. seems easyphoto by apple apple 10. photo by Marcus Q 11. Today, I am going o ell you.. 12. Happy 13. Were not alkingabout this kind of coffee.photo by Nick Humphries 14. Not this either.photo by naotoj 15. I have no idea why engineers likeusing food as their project name. 16. JeremyAshkenas photo by jsconf 17. 2009/12 18. and I sared o useCoffeeScript since 2011/5 19. and I sared o useCoffeeScript since 2011/5 because of Rails 20. yet another new language !? 21. "Its just JavaScript" 22. just writen in different synax 23. borrowed fromPython, Ruby and Haskell. 24. and would be compiled ino JavaScript code 25. JSLint Compatible 26. So, its still Javascript 27. "hmm.." 28. "Its just JavaScript" 29. "Its just JavaScript" 30. "I think its just CoffeeScript" 31. whaever..WTH can you do with CoffeeScript? 32. anything which JavaScript can do. 33. front-end, back-end, mobile.. ec. 34. but with less line of code..~ 30% off 35. CoffeeScript compiler is writen in CoffeeScript 36. Is JavaScriptthatbad?photo by Bryan Gosline 37. the good partsphoto by Steve Ganz 38. CoffeeScript =English-like grammar +nice Synactic Sugar +Goodies 39. Syntax 40. indenations rule,whiespace maters! 41. }}}} 42. }}}} 43. String Inerpolation 44. greeting = "hi, " + name + ", " + msg 45. greeting = "hi, #{name}, #{msg}" 46. semicolon 47. semicolon 48. var 49. var 50. -> 51. say_hello = (msg) -> console.log "hello, JSDC" 52. var say_hello;say_hello = function(msg) { return console.log("hello, JSDC");}; 53. default parameer 54. say_something = (msg = "JSDC") -> console.log "say #{msg}" 55. var say_something;say_something = function(msg) { if (msg == null) {msg = "JSDC"; } return console.log("say " + msg);}; 56. ( ) is not always necessary. 57. greeting("eddie", "how are you"); 58. greeting "eddie", "how are you" 59. everything is an expression 60. return is not necessary. 61. var hello;hello = function() { return "hi, JSDC";}; 62. hello = -> "hi, JSDC" 63. Array 64. var a;a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; 65. a = [1..10] 66. Loop 67. console.log i for i in [1..10] 68. var i, _i;for (i = _i = 1; _i console.log "hi, #{name}" 78. class Helloconstrucor: (@name) -> greeting: (msg) -> "hi, #{@name}, #{msg}" 79. 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;})(); 80. Diff? ? 81. the Original WayYour BrainJavaScript Browser 82. the CoffeeScript wayYour Brain CoffeeScriptJavaScript Browser 83. lots of languages that compile o JS http://goo.gl/nkAkQ 84. Ref 85. RTFM, its awesome! http://coffeescript.org/ 86. or my shameless promotion blog http://blog.eddie.com.tw/caegory/coffeescript/ 87. Lets get our feet wet!photo by jlhopes 88. Demo 89. But.. .. 90. CoffeeScript is not so perfect 91. Readability != Comprehension 92. People may still wrieCoffeeScript as horribly as they wroe JavaScript.. 93. indenations rule,whiespace maters! 94. ( ) is not always necessary. 95. Debugging ool? 96. Youve beter have a humanCoffeeScript compiler in your head! 97. Then.... 98. CoffeeScript is not used o replaceJavaScript. 99. If you dont know Javascript, andyou think CoffeeScript can saveyour life.. 100. you would be in trouble. 101. So.. .. 102. Who is using CoffeeScript? 103. actually, I dont really care! 104. Who wont need this? 105. People who dont like CoffeeScript. 106. People who already knowjavascript(the good parts) verywell. 107. Who might need/like this? 108. someone who dont like ; 109. someone who dont like { } 110. someone who dont like thePROTOTYPE. 111. Rails developer 112. Anyway 113. Should I learn CoffeeScript? 114. Is it worth it? 115. IMHO 116. You should.. 117. learn JavaScript! 118. learn JavaScript! 119. learn JavaScript! 120. learn JavaScript! 121. .. and use CoffeeScript ! 122. oally worth it! 123. I cant go back anymore! 124. give it a try 125. Happy?? 126. END 127. Conacts WebsieBlog http://www.eddie.com.tw http://blog.eddie.com.twPlurkhttp://www.plurk.com/aquarianboyFacebook http://www.facebook.com/eddiekaoGoogle Plus http://www.eddie.com.tw/+Twiterhttps://twiter.com/#!/[email protected] +886-928-617-687photo by Eddie