在生产环境中使用CoffeeScript [英] Using CoffeeScript in a production environment
问题描述
我真的很喜欢对小型项目使用 CoffeeScript (1.1.1),到目前为止,它的效果非常好。但是,在更广泛的环境中使用它之前,我想听听关于在生产中使用它的第二意见。
I really like using CoffeeScript (1.1.1) for small projects and it worked out great so far. However before using it in a more broad environment I would like to hear second opinions on using it in production.
所以我的问题是:
- 语言本身有多稳定?
- 我需要注意即将发生的更改会破坏我的代码吗?
- 如果上面的问题的答案是肯定的:旧版本支持的程度如何?
- 是否有稳定(仅修复错误)
- 如果您已在产品/网站/等中使用CoffeeScript,请说明其使用范围和您的整体体验。
- How stable is the language itself?
- Do I need to watch for upcoming changes which will break my code?
- If the answer is yes to the question above: how well are older versions supported?
- Is there a stable (bug-fix only) and a separate development branch?
- If you already did use CoffeeScript in your product/website/etc please describe the scope in which it was used and your overall experience.
感谢!
注意:我已经听说在Ruby on Rails版本3.1。 (维基百科),这是伟大的,因为Rails社区的额外支持。
Note: I've already heard that "CoffeeScript support will be included in Ruby on Rails version 3.1." (Wikipedia) which is great because of the additional backing from the Rails community.
推荐答案
语言在过去六个月中一直稳定(1.1.1基本上只有1.0的bug修复)。这不是对未来稳定性的保证,但我不认为任何时候我的图书完全过时很快。
The language has been stable for the last six months (1.1.1 is basically just 1.0 with bugfixes). That's no guarantee of future stability, but I don't expect my book to be totally obsolete any time soon.
我想说避免版本问题的最佳做法是
I'd say the best practices for avoiding version issues are
- 在该版本下编译为JS,并将JS存储在某个位置
- 确保您已记录您的项目的CoffeeScript版本>有良好的测试覆盖率(以塞缪尔·亚当斯的话来说:总是好的决定!)
- Make sure you document the version of CoffeeScript that your project was written for, and
- Compile to JS under that version and keep the JS stored somewhere
- Have good test coverage (in the words of Samuel Adams: Always a good decision!)
方式,当一个新版本的CoffeeScript发布时,您有一个JS备份,以防您的CoffeeScript代码损坏。破解更改是一种痛苦,但它们是几乎所有语言的共同之处,除了 JavaScript - 只是问一个最近从1.8转换到1.9的Rubyist,或者一个还在迁移Python 2的Pythonista代码到Python 3。
That way, when a new version of CoffeeScript is released, you have a JS backup to use in case your CoffeeScript code is broken. Breaking changes are a pain, but they're a pain common to nearly all languages except JavaScript—just ask a Rubyist who recently made the transition from 1.8 to 1.9, or a Pythonista who's still migrating their Python 2 code to Python 3.
我可以提供的建议,以防止您的代码在CoffeeScript版本更改下打破,以避免语法边缘情况。例如, func a:b,c
用于表示 func {a:b,c:c}
现在意味着 func {a:b},c
。这是一个改进(旧的行为被认为是一个错误),但有些人被抓住了它的保护。因此,每当有暗示的暗示时使用显式标点符号;
The advice I can give for preventing your code from breaking under CoffeeScript version changes is to avoid syntactic edge cases. For example, func a:b, c
used to mean func {a:b, c:c}
, and now it means func {a:b}, c
. That's an improvement (the old behavior was considered a bug), but some folks were caught off-guard by it. So use explicit punctuation whenever there's a hint of ambiguity; it makes for more readable code anyway.
Jeremy必须评论 stable
/ master
的区别,因为两个分支都存在,而 stable
自4月(1.1.0之前)以来未更新。
Jeremy will have to comment on the stable
/master
distinction, since both branches exist but stable
hasn't been updated since April (pre-1.1.0).
这篇关于在生产环境中使用CoffeeScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!