Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Introduction to CoffeeScript (screencasts.org)
35 points by franze on July 1, 2011 | hide | past | favorite | 7 comments


I'm porting over my UI-heavy app from JS to CS this week. The problem with CS is that there's just not enough tutorials/documentation online yet so articles like this are quite welcome. Here's a list of random CS things that took me a little figuring out:

1. Every function returns the last operation. To not return anything, insert a blank 'return' at the end.

2. Descending ranges just work: [10..0]

3. You can use if(`regular JS between backticks`) / else

4. You don't need node.js to compile CS (or LessJS)*

5. Don't expect a 1-to-1 conversion between old JS and new CS. CS loops have lots of smart-things built-in and will look different but work just the same or better once you know what you're doing.

* CS and Less both have JS functions that accept a raw string and output compiled string. On OSX, you can use jsc + little bit of bash to compile CS and Less to JS and CSS respectively. It is such a pleasure to work in CS and Less, especially since I know the end result is clean, standard JS/CSS that works everywhere.


If you're looking for top-notch tutorials that won't take you long to get through, I'd recommend:

http://arcturo.github.com/library/coffeescript/

http://railscasts.com/episodes/267-coffeescript-basics


fastforward to 6:40 if you don't care to see how to install and configure coffeescript on a mac with homebrew + textmate.


You can find this screencast and more on coffeescript here:

http://www.learnivore.com/search/coffeescript


Why give up jQuery and learn another scripting language?


recommendation: read the article - or - watch the movie - linked above.


You don't have to give up jQuery. You can use jQuery in your CoffeeScript.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: