CoffeeScript Basics – A Teach Me To Code Tutorial

CoffeeScript is now going to be a default installation with Ruby on Rails. So, I installed CoffeeScript and NodeJS and have been playing with it for the last hour or so.

Here are the basics you need to know to use CoffeeScript including functions, arrays, hashes (objects), control functions (if, else, unless) and loops.

In my opinion it is friendlier than JavaScript and more terse, but I don’t feel like it’s a huge win over JavaScript. That being said, it is something I’m likely to use in the future.

Download 168 MB
Download (iPhone & iPod) 87.3 MB

{ 71 comments… read them below or add one }

Roy van der Meij April 15, 2011 at 6:41 am

Charles, great screencast.
Unfortunately there is no sound in the screencast (except for the intro and outro)

Reply

Charles Max Wood April 15, 2011 at 12:49 pm

I’m not seeing that problem. Are you having that problem in the youtube version? downloaded version?

Reply

Ken May 13, 2011 at 11:44 pm

The problem, I think, is the with the right/left balance. I have professional studio monitors and there’s a lot more sound coming out of the left speaker for me.

Reply

Roy van der Meij April 15, 2011 at 6:41 am

Charles, great screencast.
Unfortunately there is no sound in the screencast (except for the intro and outro)

Reply

Charles Max Wood April 15, 2011 at 12:49 pm

I’m not seeing that problem. Are you having that problem in the youtube version? downloaded version?

Reply

Anonymous April 15, 2011 at 9:15 am

stop being lazy and type the damn blog out

Reply

Charles Max Wood April 15, 2011 at 12:50 pm

I’m actually planning on getting this transcribed and add the code snippets in sometime early next week. Just wanted this out there for the folks who are curious about the buzz on CoffeeScript

Reply

Anonymous April 15, 2011 at 9:15 am

stop being lazy and type the damn blog out

Reply

Charles Max Wood April 15, 2011 at 12:50 pm

I’m actually planning on getting this transcribed and add the code snippets in sometime early next week. Just wanted this out there for the folks who are curious about the buzz on CoffeeScript

Reply

Zaur Amikishiyev April 15, 2011 at 10:23 am

168Mb, 25 minutes screencast to present a material that would fit on one printed page… Waste of time and internet traffic

Reply

Beo April 15, 2011 at 10:46 am

Did you see the word “BASICS” on the title?
This is the CMW’s style and I like it
I think he read about the buzz on twitter coffeescript so she decided to do a fast screencast on the subject.
Charles, go forward with this topic please!

Reply

Charles Max Wood April 15, 2011 at 12:50 pm

I intend to. I’m not advocating people use CoffeeScript if they like or want to stay with JavaScript. I just want people to know what’s available (and eventually included by default) so they can make an informed decision.

Reply

Charles Max Wood April 15, 2011 at 12:51 pm

As I said, I’m planning on having it transcribed.

If you want a printed page right now, go check out http://jashkenas.github.com/coffee-script/

Reply

Zaur Amikishiyev April 15, 2011 at 10:23 am

168Mb, 25 minutes screencast to present a material that would fit on one printed page… Waste of time and internet traffic

Reply

Beo April 15, 2011 at 10:46 am

Did you see the word “BASICS” on the title?
This is the CMW’s style and I like it
I think he read about the buzz on twitter coffeescript so she decided to do a fast screencast on the subject.
Charles, go forward with this topic please!

Reply

Charles Max Wood April 15, 2011 at 12:50 pm

I intend to. I’m not advocating people use CoffeeScript if they like or want to stay with JavaScript. I just want people to know what’s available (and eventually included by default) so they can make an informed decision.

Reply

Charles Max Wood April 15, 2011 at 12:51 pm

As I said, I’m planning on having it transcribed.

If you want a printed page right now, go check out http://jashkenas.github.com/coffee-script/

Reply

Rodrigo Rosenfeld Rosas April 15, 2011 at 10:46 am

The problem with equal (=) is that it means assignment, I guess. You probably should use the equals comparison (==)…

Reply

Charles Max Wood April 15, 2011 at 12:52 pm

Did I mix them up? If I did, that’s a good catch. Thanks for pointing it out.

Reply

Rodrigo Rosenfeld Rosas April 15, 2011 at 1:01 pm

This is about 23:20:

i=10
until i=0 … instead of “until i==0” :)

Reply

Charles Max Wood April 17, 2011 at 3:39 am

Ah, that’s why my ‘until’ wasn’t working like I wanted it to. Thank you!

Reply

Rodrigo Rosenfeld Rosas April 15, 2011 at 10:46 am

The problem with equal (=) is that it means assignment, I guess. You probably should use the equals comparison (==)…

Reply

Charles Max Wood April 15, 2011 at 12:52 pm

Did I mix them up? If I did, that’s a good catch. Thanks for pointing it out.

Reply

Rodrigo Rosenfeld Rosas April 15, 2011 at 1:01 pm

This is about 23:20:

i=10
until i=0 … instead of “until i==0” :)

Reply

Charles Max Wood April 17, 2011 at 3:39 am

Ah, that’s why my ‘until’ wasn’t working like I wanted it to. Thank you!

Reply

Clinton April 15, 2011 at 1:19 pm

Good lord, there are a lot of haters on here. I like these slow-moving videos because I can type the same things out in real time.

Tip right at the beginning: Coffeescript includes string interpolation, much like Ruby. So instead of (“Hi my name is” + name “.”), you can type (“Hi, my name is #{name}.”) Much nicer.

Reply

Charles Max Wood April 17, 2011 at 3:39 am

That is definitely a good one to know. I’m going to like your comment to put it near the top. Thanks for helping us learn!

Reply

Clinton April 15, 2011 at 1:19 pm

Good lord, there are a lot of haters on here. I like these slow-moving videos because I can type the same things out in real time.

Tip right at the beginning: Coffeescript includes string interpolation, much like Ruby. So instead of (“Hi my name is” + name “.”), you can type (“Hi, my name is #{name}.”) Much nicer.

Reply

Charles Max Wood April 17, 2011 at 3:39 am

That is definitely a good one to know. I’m going to like your comment to put it near the top. Thanks for helping us learn!

Reply

Jon Atack April 15, 2011 at 2:05 pm

A timely topic. Downloaded the cast and looking forward to checking it out. Thanks Charles.

Reply

Charles Max Wood April 17, 2011 at 3:37 am

You’re welcome. Make sure you come back and let me know what you thought. I always appreciate constructive feedback.

Reply

Jon Atack April 15, 2011 at 2:05 pm

A timely topic. Downloaded the cast and looking forward to checking it out. Thanks Charles.

Reply

Charles Max Wood April 17, 2011 at 3:37 am

You’re welcome. Make sure you come back and let me know what you thought. I always appreciate constructive feedback.

Reply

Steve Gentile April 15, 2011 at 3:39 pm

Thanks – and ignore the haters – if they don’t want a video then don’t watch it – geez.

Reply

Charles Max Wood April 17, 2011 at 3:36 am

Steve – Thanks for the feedback. There are enough people out there like you that give positive feedback that I feel like I’m getting it mostly right. I may tweak things, but the people who want it in text can either read it someplace else, or wait for me to figure out transcription.

I really want to provide it and insert the code snippets in the middle of it, but enough people like the videos that I’ll do it when I can get around to it.

Reply

Tomascot April 17, 2011 at 11:58 pm

It would be the coolest feature ever if something could tell us if we are gonna like a video or not without watch it

Reply

Steve Gentile April 15, 2011 at 3:39 pm

Thanks – and ignore the haters – if they don’t want a video then don’t watch it – geez.

Reply

Charles Max Wood April 17, 2011 at 3:36 am

Steve – Thanks for the feedback. There are enough people out there like you that give positive feedback that I feel like I’m getting it mostly right. I may tweak things, but the people who want it in text can either read it someplace else, or wait for me to figure out transcription.

I really want to provide it and insert the code snippets in the middle of it, but enough people like the videos that I’ll do it when I can get around to it.

Reply

Tomascot April 17, 2011 at 11:58 pm

It would be the coolest feature ever if something could tell us if we are gonna like a video or not without watch it

Reply

Beo April 15, 2011 at 8:38 pm

—– VERY Off Topic ——–
hello in italian is “salve”(formal) or “ciao”(informal)
Buongiorno is like “good morning”
This can be very handy when you will come in Italy 😀

Reply

Charles Max Wood April 17, 2011 at 3:35 am

—– Still off topic —–

I usually used “Buongiorno” and “Buonasera” rather than “salve” or “ciao” unless I wanted to be especially formal or casual. But I was a missionary at the time and felt like I had to represent myself a little differently.

Are you Italian? (I’m assuming so since an American would have said “come to Italy” rather than the more direct Italian translation “come in Italy” from “vieni in italia”.)

Reply

Beo April 23, 2011 at 3:07 pm

—- off topic again and again —
Yes I’m italian, I live 100Km away from Rome.
I’m really impressed by your knowledge of Italian, my English is quite low but your screencasts an podcasts are very clear and understandable thanks both the language and for the pleasant “slowness”of the lessons.

Reply

Charles Max Wood April 25, 2011 at 3:52 pm

I lived in Italy for two years as a missionary for my church. I lived in Arezzo, Ancona, Verona, and Pordenone. I would love to go back to Italy someday.

Reply

Beo April 26, 2011 at 3:03 pm

Wow a missionary! You are a wonderful person!!

Beo April 15, 2011 at 8:38 pm

—– VERY Off Topic ——–
hello in italian is “salve”(formal) or “ciao”(informal)
Buongiorno is like “good morning”
This can be very handy when you will come in Italy 😀

Reply

Charles Max Wood April 17, 2011 at 3:35 am

—– Still off topic —–

I usually used “Buongiorno” and “Buonasera” rather than “salve” or “ciao” unless I wanted to be especially formal or casual. But I was a missionary at the time and felt like I had to represent myself a little differently.

Are you Italian? (I’m assuming so since an American would have said “come to Italy” rather than the more direct Italian translation “come in Italy” from “vieni in italia”.)

Reply

Beo April 23, 2011 at 3:07 pm

—- off topic again and again —
Yes I’m italian, I live 100Km away from Rome.
I’m really impressed by your knowledge of Italian, my English is quite low but your screencasts an podcasts are very clear and understandable thanks both the language and for the pleasant “slowness”of the lessons.

Reply

Charles Max Wood April 25, 2011 at 3:52 pm

I lived in Italy for two years as a missionary for my church. I lived in Arezzo, Ancona, Verona, and Pordenone. I would love to go back to Italy someday.

Reply

Beo April 26, 2011 at 3:03 pm

Wow a missionary! You are a wonderful person!!

Thomas Chik April 16, 2011 at 1:06 pm

To iterate a hash using comprehension, use of instead of in; it would be ‘for person, age of ages’ in the example.

Reply

Charles Max Wood April 17, 2011 at 3:38 am

I did eventually get there, but thanks for the clarification. I did go through it rather quickly.

Reply

Thomas Chik April 16, 2011 at 1:06 pm

To iterate a hash using comprehension, use of instead of in; it would be ‘for person, age of ages’ in the example.

Reply

Charles Max Wood April 17, 2011 at 3:38 am

I did eventually get there, but thanks for the clarification. I did go through it rather quickly.

Reply

rsludge April 17, 2011 at 5:58 pm

Nice screencast, thanks Charles.
But I don’t understand why I should use something with ruby/python syntax instead of Javascript

Reply

Charles Max Wood April 18, 2011 at 2:59 pm

I think it’s a matter of preference. If you’re happy with JavaScript, then there may not be any compelling reason to switch.

For me, the syntax matches more closely to Ruby, which lowers the barrier when I need to switch. That being said, I’m very comfortable with JavaScript and so haven’t decided if I’m going to switch myself. I just thought that people may want to see what it was all about considering the recent news in the Rails world.

Reply

rsludge April 17, 2011 at 5:58 pm

Nice screencast, thanks Charles.
But I don’t understand why I should use something with ruby/python syntax instead of Javascript

Reply

Charles Max Wood April 18, 2011 at 2:59 pm

I think it’s a matter of preference. If you’re happy with JavaScript, then there may not be any compelling reason to switch.

For me, the syntax matches more closely to Ruby, which lowers the barrier when I need to switch. That being said, I’m very comfortable with JavaScript and so haven’t decided if I’m going to switch myself. I just thought that people may want to see what it was all about considering the recent news in the Rails world.

Reply

Tad Thorley April 18, 2011 at 2:23 am

I think a lot of people are missing some of the key features of coffescript that make it so compelling. If you’ve listened to Doug Crockford talk about the “good parts” of javascript and take a look back at coffeescript, you’ll see that coffeescript encourages the good parts and cleans up all of the warts.

I’m disappointed that you didn’t cover some of my favorites: the “fat arrow”, the “is” and sane classes/inheritance. Hopefully we’ll see them in the next episode?

Reply

Charles Max Wood April 18, 2011 at 3:01 pm

I want to get into more of that. Next, I’m going to add it to a project, install jQuery, and figure out how to make that work. Then I’ll probably post a follow up with more features of CoffeeScript.

I only wanted to make it 15 minutes, so I cut it off at 25. There are definitely a lot more features to cover. Thanks for the feedback, Tad.

Reply

Tad Thorley April 18, 2011 at 2:23 am

I think a lot of people are missing some of the key features of coffescript that make it so compelling. If you’ve listened to Doug Crockford talk about the “good parts” of javascript and take a look back at coffeescript, you’ll see that coffeescript encourages the good parts and cleans up all of the warts.

I’m disappointed that you didn’t cover some of my favorites: the “fat arrow”, the “is” and sane classes/inheritance. Hopefully we’ll see them in the next episode?

Reply

Charles Max Wood April 18, 2011 at 3:01 pm

I want to get into more of that. Next, I’m going to add it to a project, install jQuery, and figure out how to make that work. Then I’ll probably post a follow up with more features of CoffeeScript.

I only wanted to make it 15 minutes, so I cut it off at 25. There are definitely a lot more features to cover. Thanks for the feedback, Tad.

Reply

Eric Berry April 18, 2011 at 4:32 pm

I love your screencasts, Chuck! Keep up the great work!!!

By the way, since I found out the lesscss.org was now working with javascript, I’m a true believer in that. I am doing ALL css with all new projects using less from here on out. Great screencast on that as well 😀

Reply

Charles Max Wood April 18, 2011 at 5:09 pm

Thanks Eric. Glad you’re enjoying them.

I’ll have to look at lesscss.org.

Reply

Eric Berry April 18, 2011 at 4:32 pm

I love your screencasts, Chuck! Keep up the great work!!!

By the way, since I found out the lesscss.org was now working with javascript, I’m a true believer in that. I am doing ALL css with all new projects using less from here on out. Great screencast on that as well 😀

Reply

Charles Max Wood April 18, 2011 at 5:09 pm

Thanks Eric. Glad you’re enjoying them.

I’ll have to look at lesscss.org.

Reply

Eric Berry April 19, 2011 at 5:24 pm
Antonychristopher May 8, 2011 at 2:16 pm

Hi Eric i want a website to be developed with complete crm solutions please do reply my email address is antonychristopher01@gmail.com

Reply

Eric Berry April 19, 2011 at 5:24 pm
Antonychristopher May 8, 2011 at 2:16 pm

Hi Eric i want a website to be developed with complete crm solutions please do reply my email address is antonychristopher01@gmail.com

Reply

Charles Max Wood April 26, 2011 at 5:33 pm

I try. I have to say that it was an incredible experience. I love Italy and Italians.

Reply

Charles Max Wood April 26, 2011 at 5:33 pm

I try. I have to say that it was an incredible experience. I love Italy and Italians.

Reply

Leave a Comment

{ 10 trackbacks }