芝加哥老板[chicagoBoss]

2011-04-22 01:55

芝加哥老板[chicagoBoss]

by jackyz

at 2011-04-21 17:55:28

original http://erlang-china.org/2011/04/21/chicagoboss/

Chicago Boss 这个名字听起来,怎么也让人联想不到 Web 开发领域。反而总让人不由得想起黑帮、枪战、还有私酒泛滥的 1920 年代(估计是最近看《大西洋帝国》给闹的)。但是,的而且确,这个玩意明白无误地就是 Web 开发领域的事儿。

先上亮点:

High Productivity

Compact query syntax:

boss_db:find(person, [age > 25])

Elegant controllers:

edit('GET', []) ->
ok;
edit('POST', []) ->
{redirect, "/somewhere"}.

Simple data models:

-module(person, [Id, FirstName, LastName]).

full_name() ->
FirstName ++ " " ++ LastName.

Rails-y records:

Person = person:new(id, "Joe", "Blow"),
Person:save()

Django templates:


Easy Comet – New in 0.4.5

BossMQ introduces a simple API for sending and receiving messages. Here is a complete long-polling chat backend:

send_chat('POST', [Channel]) ->
boss_mq:push(Channel, Req:post_param("msg")).

receive_chat('GET', [Channel]) ->
{ok, Time, Messages} = boss_mq:pull(Channel),
{json, [{time, Time}, {messages, Messages}]}.

With BossMQ, any controller action is a potential Comet endpoint. Thus, Comet endpoints have complete access to your entire application — databases, templates, the whole stack.

High Reliability

100% asynchronous network I/O

  • Under load, uses less RAM than synchronous apps (PHP, Rails, Django)
  • Comet long-polls won’t block the app server
  • Single-process model keeps CPU context switches to a minimum

Supports both SQL and schema-less databases

  • MySQL
  • PostgreSQL
  • MongoDB (NEW)
  • Tokyo Tyrant
  • Mnesia
  • Or write your own adapter — usually ~300 lines of code

Operational simplicity

  • Zero downtime code upgrades in production (NEW)
  • Standalone server does not require Apache, Nginx, etc.
  • Direct SMTP mail delivery does not require Postfix

Unique testing framework

  • Closure-based tests reduce test code size
  • Run functional tests in-memory — no network I/O
  • Integrated web and email testing

Future plans (not yet implemented!)

  • Full OTP compliance
  • Full test coverage
  • See the Roadmap

好吧我得承认,其中的一些亮点其实是来自 Erlang 语言本身的。

毫无疑问,这个项目提供了 Erlang 和 ruby on rails’ way 的跨界组合优势。比如说,在采用高生产力的 rails 方式来构建项目时,如果心存疑虑,担心某一天会被可能的性能问题跳出来反咬一口的话,那么现在又多了一个具有 FP 风格的选择了。

有必要表扬一句的是:chicago boss 的文档整理得相当靠谱,单就这一点而言,在众多的 Erlang Web 项目中,就很有走红潜质。此外,开发过程似乎也可圈可点,按照 roadmad 的特性持续升级,很让人看好。不过也有的地方让人感觉有点奇怪,比如说,源代码竟然是要下载的,而没有用“开源工业标准”的 github ,这多少有点让我不适应。

顺便 blah 一下,如今这世道, web 开发似乎已经渐渐地在更多转变为前端以 jquery 为基础的 ajax 开发了,换句话说,前端正在静态页面化。而所谓的后端系统也已经相对标准——更像是 restful 的 CRUD 接口再加上薄薄的一层业务逻辑。前端与后端之间的接口方式与约定已经相当之稳定。那么,比如说,有了 chicago boss 这么有生产力的架构,在后端性能开始吃紧的情况下,趁着系统升级的机会,简单地整一把,平滑地将后端系统“迁移”到更高效的平台上,未尝也不是一个不错的升级方向嘛。