作者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