{"id":1411,"date":"2021-09-30T10:19:58","date_gmt":"2021-09-30T10:19:58","guid":{"rendered":"https:\/\/blog.amt.in\/?p=1411"},"modified":"2021-09-30T10:19:58","modified_gmt":"2021-09-30T10:19:58","slug":"introduction-to-coffeescript","status":"publish","type":"post","link":"https:\/\/blog.amt.in\/index.php\/2021\/09\/30\/introduction-to-coffeescript\/","title":{"rendered":"Introduction to CoffeeScript"},"content":{"rendered":"<p>CoffeeScript\u00c2\u00a0is a programming language that compiles to\u00c2\u00a0JavaScript. It adds\u00c2\u00a0syntactic sugar\u00c2\u00a0inspired by\u00c2\u00a0Ruby,\u00c2\u00a0Python\u00c2\u00a0and\u00c2\u00a0Haskell\u00c2\u00a0in an effort to enhance JavaScript&#8217;s brevity and readability.\u00c2\u00a0Specific additional features include\u00c2\u00a0list comprehension\u00c2\u00a0and\u00c2\u00a0destructuring assignment.<\/p>\n<p>JavaScript\u00c2\u00a0often abbreviated as\u00c2\u00a0JS, is a\u00c2\u00a0programming language\u00c2\u00a0that conforms to the\u00c2\u00a0ECMAScript\u00c2\u00a0specification.\u00c2\u00a0JavaScript is\u00c2\u00a0high-level, often\u00c2\u00a0just-in-time compiled, and\u00c2\u00a0multi-paradigm. It has\u00c2\u00a0curly-bracket syntax,\u00c2\u00a0dynamic typing,\u00c2\u00a0prototype-based\u00c2\u00a0object-orientation, and\u00c2\u00a0first-class functions.<\/p>\n<p>Alongside\u00c2\u00a0HTML\u00c2\u00a0and\u00c2\u00a0CSS, JavaScript is one of the core technologies of the\u00c2\u00a0World Wide Web.\u00c2\u00a0Over 97% of\u00c2\u00a0websites\u00c2\u00a0use it\u00c2\u00a0client-side\u00c2\u00a0for\u00c2\u00a0web page\u00c2\u00a0behavior,\u00c2\u00a0often incorporating third-party\u00c2\u00a0libraries.\u00c2\u00a0Most\u00c2\u00a0web browsers\u00c2\u00a0have a dedicated\u00c2\u00a0JavaScript engine\u00c2\u00a0to execute the code on the\u00c2\u00a0user&#8217;s device.<\/p>\n<p>As a multi-paradigm language, JavaScript supports\u00c2\u00a0event-driven,\u00c2\u00a0functional, and\u00c2\u00a0imperative\u00c2\u00a0programming styles. It has\u00c2\u00a0application programming interfaces\u00c2\u00a0(APIs) for working with text, dates,\u00c2\u00a0regular expressions, standard\u00c2\u00a0data structures, and the\u00c2\u00a0Document Object Model\u00c2\u00a0(DOM).<\/p>\n<p>The ECMAScript standard does not include any\u00c2\u00a0input\/output\u00c2\u00a0(I\/O), such as\u00c2\u00a0networking,\u00c2\u00a0storage, or\u00c2\u00a0graphics\u00c2\u00a0facilities. In practice, the web browser or other\u00c2\u00a0runtime system\u00c2\u00a0provides JavaScript APIs for I\/O.<\/p>\n<p>JavaScript engines were originally used only in web browsers, but they are now core components of\u00c2\u00a0other\u00c2\u00a0software systems, most notably\u00c2\u00a0servers\u00c2\u00a0and a variety of\u00c2\u00a0applications.<\/p>\n<p>CoffeeScript support is included in\u00c2\u00a0Ruby on Rails\u00c2\u00a0version 3.\u00c2\u00a0and\u00c2\u00a0Play Framework.\u00c2\u00a0In 2011,\u00c2\u00a0Brendan Eich\u00c2\u00a0referenced CoffeeScript as an influence on his thoughts about the future of JavaScript.<\/p>\n<p>On December 13, 2009,\u00c2\u00a0Jeremy Ashkenas\u00c2\u00a0made the first\u00c2\u00a0Git\u00c2\u00a0commit of CoffeeScript with the comment: &#8220;initial commit of the mystery language.&#8221;\u00c2\u00a0The compiler was written in Ruby. On December 24, he made the first tagged and documented release, 0.1.0. On February 21, 2010, he committed version 0.5, which replaced the Ruby compiler with a\u00c2\u00a0self-hosting\u00c2\u00a0version in pure CoffeeScript. By that time the project had attracted several other contributors on\u00c2\u00a0GitHub, and was receiving over 300 page hits per day.<\/p>\n<p>On December 24, 2010, Ashkenas announced the release of stable 1.0.0 to\u00c2\u00a0Hacker News, the site where the project was announced for the first time.<\/p>\n<p>On September 18, 2017, version 2.0.0 was introduced,\u00c2\u00a0which &#8220;aims to bring CoffeeScript into the modern JavaScript era, closing gaps in compatibility with JavaScript while preserving the clean syntax that is CoffeeScript\u00e2\u20ac\u2122s hallmark.&#8221;<\/p>\n<p>Almost everything is an expression in CoffeeScript, for example\u00c2\u00a0<code>if<\/code>,\u00c2\u00a0<code>switch<\/code>\u00c2\u00a0and\u00c2\u00a0<code>for<\/code>\u00c2\u00a0expressions (which have no return value in JavaScript) return a value. As in\u00c2\u00a0Perl, these control statements also have postfix versions; for example,\u00c2\u00a0<code>if<\/code>\u00c2\u00a0can also be written in\u00c2\u00a0<code>consequent if condition<\/code>\u00c2\u00a0form.<\/p>\n<p>Many unnecessary parentheses and braces can be omitted; for example, blocks of code can be denoted by indentation instead of braces, function calls are implicit, and object literals are often detected automatically.<\/p>\n<p>The CoffeeScript compiler has been\u00c2\u00a0self-hosting\u00c2\u00a0since version 0.5 and is available as a\u00c2\u00a0Node.js\u00c2\u00a0utility; however, the core compiler does not rely on Node.js and can be run in any\u00c2\u00a0JavaScript\u00c2\u00a0environment.\u00c2\u00a0One alternative to the\u00c2\u00a0Node.js\u00c2\u00a0utility is the Coffee Maven Plugin, a plugin for the\u00c2\u00a0Apache Maven\u00c2\u00a0build system. The plugin uses the\u00c2\u00a0Rhino\u00c2\u00a0JavaScript engine written in\u00c2\u00a0Java.<\/p>\n<p>The official site at CoffeeScript.org has a &#8220;Try CoffeeScript&#8221; button in the menu bar; clicking it opens a modal window in which users can enter CoffeeScript, see the JavaScript output, and run it directly in the browser. The js2coffee\u00c2\u00a0site provides bi-directional translation.<\/p>\n<ul>\n<li>Source maps allow users to debug their CoffeeScript code directly, supporting CoffeeScript tracebacks on run time errors.<\/li>\n<li>CoffeeScript supports a form of\u00c2\u00a0Literate Programming, using the\u00c2\u00a0<code>.coffee.md<\/code>\u00c2\u00a0or\u00c2\u00a0<code>.litcoffee<\/code>\u00c2\u00a0file extension. This allows CoffeeScript source code to be written in\u00c2\u00a0Markdown. The compiler will treat any indented blocks (Markdown&#8217;s way of indicating source code) as code, and ignore the rest as comments.<\/li>\n<\/ul>\n<p>Iced CoffeeScript is a superset of CoffeeScript which adds two new keywords:\u00c2\u00a0<code>await<\/code>\u00c2\u00a0and\u00c2\u00a0<code>defer<\/code>. These additions simplify asynchronous control flow, making the code to look more like a\u00c2\u00a0procedural programming\u00c2\u00a0language, eliminating the call-back chain. It can be used on the server side and in the browser.<\/p>\n<p>On September 13, 2012,\u00c2\u00a0Dropbox\u00c2\u00a0announced that their browser-side code base has been rewritten from\u00c2\u00a0JavaScript\u00c2\u00a0to CoffeeScript,\u00c2\u00a0however it has been migrated to\u00c2\u00a0TypeScript\u00c2\u00a0in 2017.<\/p>\n<p>GitHub&#8217;s internal style guide once said &#8220;write new JS in CoffeeScript&#8221;, and while it no longer does, all the advice in the style guide references how to write good CoffeeScript,<sup id=\"cite_ref-22\" class=\"reference\">[22]<\/sup>\u00c2\u00a0and their\u00c2\u00a0Atom text editor\u00c2\u00a0was also written in the language.<\/p>\n<p>Pixel Game Maker MV\u00c2\u00a0makes uses of CoffeeScript as part of its game development environment.<\/p>\n<p>Above is a brief about CoffeeScript. Watch this space for more updates on the latest Trends in Technology.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CoffeeScript\u00c2\u00a0is a programming language that<\/p>\n","protected":false},"author":1,"featured_media":1413,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[288,154,7],"tags":[289,156,18],"class_list":["post-1411","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-coffeescript","category-programming-language","category-techtrends","tag-coffeescript","tag-programming-language","tag-technology"],"_links":{"self":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/comments?post=1411"}],"version-history":[{"count":1,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1411\/revisions"}],"predecessor-version":[{"id":1412,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1411\/revisions\/1412"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media\/1413"}],"wp:attachment":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media?parent=1411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/categories?post=1411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/tags?post=1411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}