An Introduction to CoffeeScript

Post on 10-May-2015

140 views 0 download

Tags:

description

A CoffeeScript introduction presentation, which deals about the basic and basic concepts of CoffeeScript.

Transcript of An Introduction to CoffeeScript

A Small Introduction..!

Who am I?

• rampicos.wordpress.com• twitter.com/rampicos• facebook.com/raamkumar.m• Code• Ramkumar Murugadoss

What is CoffeeScript

• CoffeeScript is a little language that aims to give you easy access to the good parts of JavaScript

• One-third less code in order to generate the same JavaScript

Why CoffeeScript

• Increases readability• Eliminates syntactic clutters• Very less number of code lines to get much

more javascripts• Get to know, because it is really popular

History

• On Christmas Day 2009, Jeremy Ashkenas first released CoffeeScript

• On Christmas 2010 CoffeeScript 1.0 get released, with this release CoffeeScript became one of Github’s “most-watched” projects

• In 2011, CoffeeScript was included in Ruby on Rails 3.1

How it gets so much Popularity

• The good parts like super functions, classes, etc.. are still there

• The Compiler is present to help• It is all so clear

Setting Env

• Install Node.js for your platform• Goto Terminal/CMD• Execute “npm install -g coffee-script”• Use “coffee -v” to check CoffeeScript works

and to know the version

All set

• “coffee –c <filename.coffee>” to compile coffee file to js file

• “coffee -o output/folder -c Coffee/files/folder” to bulk compile coffee files to js files and store in specified folder

Ready to Code

• You don't need to declare variables with var• You don't need to use semicolons ;• Instead of using curly braces { } to surround

blocks of code with indentation• Use @ for this• Use -> for function definition• Assign default values from function arguments

Some Examples

Much more

• Functions• Objects and Arrays• Lexical Scoping and Variable Safety• If, Else, Unless, and Conditional Assignment• Splats...• Loops• Array Slicing and Splicing• Classes, Inheritance, and Super

With jQuery

Or

Or

Or

Time is Yours