官术网_书友最值得收藏!

Why CoffeeScript?

CoffeeScript was certainly not the first (or last) language to target JavaScript platforms. Many established languages, such as Ruby, Python, C, and Java have one or more projects focused on compiling that language to JavaScript. And other languages have been developed specifically to target JavaScript—notably Dart, TypeScript, and Coco.

Note

The CoffeeScript wiki itself maintains an extensive list of other languages that compile to JavaScript. You can find it at https://github.com/jashkenas/coffee-script/wiki/List-of-languages-that-compile-to-JS.

While it's not alone in its approach, CoffeeScript has seen the most success of any language that compiles to JavaScript. It is the tenth most popular language on GitHub, it ships by default with Ruby on Rails, and it has large followings in both client-side and server-side developer communities.

So what makes CoffeeScript special? Just like Goldilocks and her pilfered porridge, CoffeeScript derives its strength from being just right. It is a marked improvement over JavaScript; we'll spend much of this book learning how CoffeeScript can help us write code that is more concise, easier to read, and less prone to bugs. However, CoffeeScript does not overreach on features. CoffeeScript has little to no runtime of its own—there is no extra metadata to track, no extra memory management, no non-standard data structures. Instead, CoffeeScript compiles directly to ordinary-looking JavaScript, much like what an experienced JavaScript developer might write. In fact, CoffeeScript is less a new language than it is a shorthand for easily expressing the best practices of JavaScript.

CoffeeScript is an eminently pragmatic language, and this is the secret to its success. It's easy for JavaScript developers to learn, and most expertise carries over. It doesn't incur performance penalties over plain JavaScript. CoffeeScript and JavaScript can coexist peacefully, so it's easy to introduce CoffeeScript into existing JavaScript projects. Perhaps most importantly, CoffeeScript avoids the "magic" that is so often a source of bugs when the developer's assumptions don't match the language designer's assumptions. With CoffeeScript, it's very easy to understand what the resulting JavaScript will do and how it will behave.

It might also help that CoffeeScript is fun.

主站蜘蛛池模板: 鹤壁市| 陇南市| 富裕县| 罗田县| 博兴县| 夏津县| 抚顺县| 桦甸市| 屏东县| 务川| 临湘市| 嘉兴市| 南宫市| 康马县| 南昌市| 都匀市| 凤台县| 石阡县| 穆棱市| 格尔木市| 嘉禾县| 毕节市| 江口县| 锡林浩特市| 北京市| 东明县| 义马市| 略阳县| 旬阳县| 喀喇沁旗| 怀柔区| 海伦市| 南郑县| 玛曲县| 福安市| 阿坝县| 华容县| 遂川县| 英超| 永靖县| 平顺县|