作者nfsong (图书馆我来了)
看板PCSH91_305
标题Rails 3 的野望 (Rails 合并 Merb 後目前的进展)
时间Fri Sep 11 13:18:46 2009
http://blog.xdite.net/
http://yehudakatz.com/
Rails 3 的野望 (Rails 合并 Merb 後目前的进展)
这一篇想写很久了,一直忘记。
大家应该还记得,Merb 在 2008 年底宣布了一个决定,他们决定并入 Rails。而 Merb
的 Team Leader:Yehuda Katz,也将加入 Rails core team 开发。於是未来 Merb2 将
直接等於 Rails3。
当时,这件事是非常令人震撼的。原因是 Rails 虽然是一个非常先进的框架,但是还是
有非常多开发者,因为它的包山包海(笨重、效能不彰)而却步。於是,他们选择了另外
一套框架 Merb。Merb 的想法和架构其实是很棒的,它既可以是一个 full stack 的
Framework,又可以让开发者用 cherry pick library 的方式建构网站。有很多 Merb
派的开发者,甚至就是因为前述原因才跳槽过来的。
因此它们的合并,无异是向社群投了一个大炸弹。很多 Merb 的拥护者当时纷纷表示不能
接受,甚至大家都涌上「Merb core team 的人是集体脑袋烧坏掉了吗」的强烈疑惑,认
为 Merb 选择被 Rails 整并是大错特错的愚蠢决定。
我当初也这麽想,但近半年来,追看 Edge Rails 的发展,我才发现所有人(包括 DHH)
,都被 Yehuda 骗了。
在 DHH 当初的 Announce 提到了 Rails 3 将会有的是:
* Rails core: Yes, Rails is a full-stack framework and will remain so,
but there’s no reason we shouldn’t also make it possible to run with less
than the full monty. Rails 3 will make it easy to run just a bare minimum and
then allow you to opt in just the stuff you want, if that’s necessary for
your particular situation. Think “rails myapp—core” (and “rails myapp—
flat”).
* Performance optimizations: Merb has a lot of Rails pieces rewritten to
be faster. We’ll be bringing all that good stuff over. We’ll also bend the
architecture in the places where that’s necessary for a big yield. In short,
Rails 3 will get all the performance attention that the Merb guys are known
for.
* Framework agnosticism: Rails will always have a default answer to every
question within the stack. If you don’t care about testing frameworks, you’
ll get test/unit. If you don’t care about which ORM, you’ll get Active
Record. But some people do care and want something else. Some people want
RSpec for testing, others want to use Sequel or Data Mapper for ORM, others
again prefer Haml for templating, and some might prefer jQuery for Ajax. All
these people should feel like Rails is welcoming them with open arms. Yes, we
’ll have a default, but we shouldn’t have any form of discrimination
against alternatives.
* Rigorous API: Too many plugins break when Rails is updated because it’
s not clear where they can safely hook into the internals and when they’re
monkeypatching and should expect things to break. The Merb guys committed to
a public API with tests to ensure that it wouldn’t break. They’ll bring
over that line of thinking and give Rails 3 a tested and documented API for
extensions that won’t break willy-nilly with upgrades.
大家看到 Rigorous API 这段 一定以为 Yehuda 当初的提议是的改版是,发明一套神奇
的 API,让 plugin 不再烂掉。再加上前三条以上 blahblah 的好处 …不过大家看的半
信半疑,感觉上好像都是虎烂,应该完全做不到吧….。
OK。但到目前为止,结果 Yehuda 目前的成果到了什麽地步呢?
Merb 反过来吃掉了 Rails,顺便叫 Sinatra 也不用继续再玩了!
他现在做的事,并不是发明什麽神奇的 API 。而是把整个 Rails refactor,具体的作法
就是把整个 Rails 全部拆散成 API 形式再组起来 ……这不仅是空谈,而是已经有非常
具体的成果了。
1. 现在 Rails 的效能跟 Merb 一样好!! ( 2008/08/09 )
merb
2. Fully API ( 这在他最近在世界上的各场 ruby / rails conf 演讲 影片/ 投影片
都有 demo )
3. 因为现在通通拆开了,所以 Rails3 达成 framework agnosticism 是完全没问题的…
4. 因为现在通通拆开了,very flat 版 rails 也是没有问题的…
5. 他最近甚至无聊到火力展示(炫耀)一个东西,如何用 Rails API 拼出一个
Sinatra 。XDDDDDDD
6. 还顺便分享了一篇 refactor 技巧(因为公开翻修了 Rails 这个 opensource
project ):6 Steps To Refactoring Rails (for Mere Mortals)
完全令人想不到而且伟大的结局啊,完全做的到而且比当初宣告的更屌….。
真期待年底 Rails3 的正式 Release ….
====
Update : 刚刚重回去看
Merb gets merged into Rails 3!,想仔细找找有没有什麽我写漏的。结果看到 DHH 在
当初的文章里强调了这次的 merge「This is not a big bang rewrite」。我噗吃一声,
笑出来了…………
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.161.98.57
1F:→ nfsong:it works 09/11 13:19