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

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.

主站蜘蛛池模板: 于田县| 阿坝县| 湖北省| 深泽县| 象山县| 浠水县| 彭山县| 芦山县| 阳谷县| 大田县| 青浦区| 苏尼特右旗| 修水县| 额济纳旗| 咸丰县| 修水县| 东兴市| 青冈县| 博乐市| 桂阳县| 辽中县| 电白县| 抚宁县| 青龙| 三台县| 泽州县| 许昌市| 永胜县| 闻喜县| 江门市| 陵水| 辽阳县| 休宁县| 惠东县| 崇阳县| 平果县| 江安县| 百色市| 六盘水市| 大洼县| 易门县|