用coffeescript重写了首页

下午有时间看了一下coffeescript,发现非常优雅。过去对JavaScript的工作,从dojo到jquery主要是在库的层面,这次coffeescript的出现是在语言层面对javascript做了一次加强。现在对语言的加强不再需要mozilla/microsoft/google/apple几家坐下来慢慢聊了,民间的力量就可以实现。

coffeescript的几个特点也属于博采众长:

  • 类似python的,以缩进取代代码块
  • 类似ruby/perl,方法调用括号可选
  • 类似ruby,无须return
  • 正常的类声明语法

在nodejs的环境里可以通过npm安装coffer-script,利用它的命令行程序,可以把coffeescript编译成javascript。不过最给力的是可以在网页里通过引入coffee-script.js来直接执行(其实也是编译一下)coffeescript。

于是我顺手重写了一下首页的js,改写成coffeescript。因为少打很多() {},手可以控制在键盘中心的,敲字的效率大大提高。用空你也可以尝试一下。

3 thoughts on “用coffeescript重写了首页

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>