CoffeeScript is a programming language that compiles to JavaScript. It adds syntactic sugar like Ruby and Python to make JavaScript more readable and concise. CoffeeScript code compiles directly to equivalent JavaScript code without runtime interpretation. This allows seamless use of existing JavaScript libraries. CoffeeScript code is more readable and maintainable due to its indentation-based syntax and lack of semicolons. While it simplifies JavaScript programming, an additional compilation step is required and errors can be difficult to debug due to obfuscated compiled code. Overall, CoffeeScript aims to remove rough edges from JavaScript for a smoother programming experience.
4. What is Coffee Script-1
• Coffee Script is a programming language that transcompiles to
JavaScript that means source code of a coffee script as its input
and outputs the source code into another programming language.
• The language adds syntactic sugar inspired by Ruby, Python and
Haskell to enhance JavaScript's brevity and readability, adding
sophisticated features like list comprehension and pattern
matching.
• Coffee Script is an attempt to expose the good parts of JavaScript
5. What is Coffee Script-1
• The golden rule of Coffee Script is: "It's just JavaScript". The code
compiles one-to-one into the equivalent JS, and there is no
interpretation at runtime.
• You can use any existing JavaScript library seamlessly from Coffee
Script (and vice-versa). a simple way. The compiled output is
readable and pretty-printed, will work in every JavaScript
runtime, and tends to run as fast or faster than the equivalent
handwritten JavaScript.
6. What is Coffee Script -2
• Cooperate with already existing JS libraries (like
jQuery, Facebook JS SDK, Google API etc.)
• Code compiles one-to-one into the equivalent JS
• Pass through JSLint without warnings
7. How it can help us ?
• Less lines of code with better readability,
• Code easy to understand, and maintain
• Standard code encapsulation and variables
• Protection (no var anymore)
• But... even if you are writing code in CoffeeScript
You should know how JavaScript`s concepts work
9. Coffee Script in Your Browser
1. <script src=“coffee-script.js” type=“text/javascript”></script>
2. <script type=“text/CoffeScript”>
3. firstname = prompt “what is your first name?”
4. lastname= prompt “what is your last name ?”
5. fullname=firstname+ lastname
6. Alert “Hello, #{fullname}”
7. </script>
10. Advantages
• All the good Feature of java script are present in coffee
script
• English Like syntax and no return statement required.
• You don`t have to debug any “ }” in your script
• With the proper use of white space you can make your
script more readable as well as maintainable
11. Advantages
• The ability to write code that works in old versions of
Internet Explorer without having to compromise or
shim
• Not having to worry about JavaScript pitfalls like
trailing commas and automatic semicolon insertion
• Cleaned up semantics where every language construct
can be used as part of a larger expression
12. Disadvantages
• When you are using coffee script , there`s an additional
compilation step involved in the process.
• Coffee Script is very sensitive to whitespace, counting a tab
as a single space.
• The compiler provides very rudimentary diagnostic
information in the case of errors.
13. Disadvantages
• Priority rules are not always intuitive, sometimes causing
sub-expressions to end up in unexpected places.
• Debugging is a major problem because the compiled code
is not always readable.
• But Coffee script team is trying to solve this in the future
14. The Final Word
• Sole purpose is to remove the rough edges from the java
script and provide a smooth way of programming in
JavaScript
• Now Programming in JavaScript has an easy way and
hard way –the choice is yours.
• To learn Coffee script syntax you can refer
Coffeescript.org