15
A Small Introduction..!

An Introduction to CoffeeScript

Embed Size (px)

DESCRIPTION

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

Citation preview

Page 1: An Introduction to CoffeeScript

A Small Introduction..!

Page 2: An Introduction to CoffeeScript

Who am I?

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

Page 3: An Introduction to CoffeeScript

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

Page 4: An Introduction to CoffeeScript

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

Page 5: An Introduction to CoffeeScript

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

Page 6: An Introduction to CoffeeScript

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

Page 7: An Introduction to CoffeeScript

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

Page 8: An Introduction to CoffeeScript

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

Page 9: An Introduction to CoffeeScript

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

Page 10: An Introduction to CoffeeScript

Some Examples

Page 11: An Introduction to CoffeeScript
Page 12: An Introduction to CoffeeScript

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

Page 13: An Introduction to CoffeeScript

With jQuery

Or

Page 14: An Introduction to CoffeeScript

Or

Or

Page 15: An Introduction to CoffeeScript

Time is Yours