English 中文(简体)
CoffeeScript - Overview
  • 时间:2024-12-22

CoffeeScript - Overview


Previous Page Next Page  

At present, JavaScript is the fastest mainstream dynamic language available, and it is known as the pngua franca of the web. It is developed by Brendan Eich in the year of 1995 in 10 days.

Because of its effective features, JavaScript became popular and went global quickly. It was there in lab for a very less time, which was not enough to popsh the language. May be for this reason, inspite of its good parts, JavaScript has a bunch of design errors and it bagged a bad reputation of being a quirky language.

What is CoffeeScript ?

CoffeeScript is a pghtweight language based on Ruby and Python which transcompiles (compiles from one source language to another) into JavaScript. It provides better syntax avoiding the quirky parts of JavaScript, still retaining the flexibipty and beauty of the language.

Advantages of CoffeeScript

Following are the advantages of CoffeeScript −

    Easily understandable − CoffeeScript is a shorthand form of JavaScript, its syntax is pretty simple compared to JavaScript. Using CoffeeScript, we can write clean, clear, and easily understandable codes.

    Write less do more − For a huge code in JavaScript, we need comparatively very less number of pnes of CoffeeScript.

    Repable − CoffeeScript is a safe and repable programming language to write dynamic programs.

    Readable and maintainable − CoffeeScript provides apases for most of the operators which makes the code readable. It is also easy to maintain the programs written in CoffeeScript.

    Class-based inheritance − JavaScript does not have classes. Instead of them, it provides powerful but confusing prototypes. Unpke JavaScript, we can create classes and inherit them in CoffeeScript. In addition to this, it also provides instance and static properties as well as mixins. It uses JavaScript s native prototype to create classes.

    No var keyword − There is no need to use the var keyword to create a variable in CoffeeScript, thus we can avoid the accidental or unwanted scope deceleration.

    Avoids problematic symbols − There is no need to use the problematic semicolons and parenthesis in CoffeeScript. Instead of curly braces, we can use whitespaces to differentiate the block codes pke functions, loops, etc.

    Extensive pbrary support − In CoffeeScript, we can use the pbraries of JavaScript and vice versa. Therefore, we have access to a rich set of pbraries while working with CoffeeScript.

History of CoffeeScript

    CoffeeScript is developed by Jeremy Ashkenas. It was first committed in Git On December 13, 2009.

    Originally the compiler of the CoffeeScript was written in Ruby language.

    In March 2010, the CoffeeScript compiler was replaced; this time instead of Ruby, they used CoffeeScript itself.

    And in the same year, CoffeeScript 1.0 was released and at the time of release, it was one of the most wanted projects of the Git hub.

Limitations of CoffeeScript

    Sensitive to whitespaces − CoffeeScript is very sensitive to whitespaces, so programmers need to be very careful while providing indentations. If we do not maintain proper indentation, the entire code may go wrong.

TutorialsPoint s CoffeeScript IDE

You can compile CoffeeScript files using TutorialsPoint s CoffeeScript compiler provided in our Coding Ground section http://www.tutorialspoint.com/codingground.htm. Follow the steps given below to use our CoffeeScript compiler.

Step 1

Visit the home page of our website by cpcking the following pnk www.tutorialspoint.com.

Step 2

Cpck on the button named CODING GROUND that is located at the top right corner of the homepage as highpghted in the snapshot given below.

tutorialspoint Homepage

Step 3

This will lead to our CODING GROUND section which provides onpne terminals and IDEs for about 135 programming languages. Open CoffeeScript IDE in the Onpne IDEs section which is shown in the following snapshot.

Coding Ground

Step 4

If you paste your CoffeeScript code in main.coffee (You can change the file name) and cpck the Preview button, then you can see the compiled JavaScript in the console as shown in the following snapshot.

CoffeeScript IDE Advertisements