一個在 Rails 跟 Django 徘徊設計師的真情告白



AjaxWhoIs 這個網站的作者最近發表一篇文章 Why I moved from Ruby on Rails to Python/Django and back,講解他開發 AjaxWhoIs 2.0 的時候為何先用 Rails 開發,後來採用 Django 開發,最後還是轉回 Rails 的紀錄。

Any newcomer to Rails will quickly discover why it is so talked about. First of all, even though I don’t consider myself anywhere near a decent Rails programmer, I am now at least twice as productive with Ruby on Rails than with ASP.NET and C#. Thanks to the MVC (Model, View, Controller), DRY (Don’t Repeat Yourself) and Convention Over Configuration mindset of Rails.

他一開始是一個 ASP.NEt 跟 C# 的程式設計師,所以他是第一次使用 Rails ,但是當他使用 Rails 開發的時候,他發現 Rails 的三大法則 MVC ,DRY ,Convention Over Configuration 至少讓他生產力比原本很熟悉的 ASP.NET 快了兩倍以上。

I found out that Mongrel was known to not play well with 64 bit Ubuntu (I lost the links to this evidence, unfortunately). Mongrel was patched accordingly, but it didn’t solve my problem. It still crashed many times a day and I just couldn’t figure out what was wrong. I asked my good friends Rich Collins and Adam Thorsen (of Guruza.com) who are both experienced Rails developers and they had no idea either. I was stuck.

但是當他寫完AJAXWhoIs 2.0的時候,他發現到 Mongrel 跑 64bit Ubuntu 的時候有詭異的問題,導致 Mongrel 常常當機,屢試不爽。

I picked up a Python book and rewrote the whole site one more time, in Python using the Django framework this time. I had never programmed in Python before and much less used Django. However, the switch was easy enough since Ruby and Python are somewhat similar.

相當令人覺得很了不起,也相當令人覺得不可思議的事情發生了。他已經寫完了整個 Project ,只是遇到了這個 Hardware 問題,他居然跑去用 Django 重新寫了一次 AjaxWhoIs 2.0,而且這還是他第一次寫 Python。一般人應該都會換台機器跑就好了不是嗎 @@!

However, I soon missed Ruby and Rails. Ruby supports “real” private/public/protected methods (Python just fakes that with its naming convention) and it’s syntax is more forgiving (the need for () at the end of each method call in Python was killing me). Django is not as straightforward as Rails, and requires more code to get things done. There are also many little things that don’t “feel right” in Django, like the need to manually pass variables to a view. Data access is confusing at best while Rails’ ActiveRecord is god-sent. These little things really add up.

但是當他寫完的同時,他開始相當懷念 Rails 了,有許許多多小地方他認為 Rails 做的比 Django 來的好,Rails 作法也比 Django 來的更 straightforward 。要完成同樣一件事情,Django 也需要比 Rails 更多 code 。 Django 有太多東西讓他覺得 don't feel right了。

On the flip side, Python is faster than Ruby and less memory hungry. I was also surprised to actually love Python’s significant indentation ( see example). But more importantly, Python and Django just worked! I never experienced weird crashes like I did with my Rails stack.

的確,Python 比 Ruby 快,需要 memory 也比較少。而且最重要的是,Django 可以動,Mongrel 在 64 bit CPU 不能動。

So, why am I back to Rails for my next project? 3 letters: FUN. I find Ruby and Rails to be pleasant to use. The community large, active and very helpful. The number of freely available Rails plugins and the fast evolution of the core code are also welcomed additions. Rails requires less code, less self.__awkward_method_calls(), has built-in AJAX and REST support, and has much more flexible data access and templating engines.

而為何他又要跑回 Rails 了呢?Just for FUN。他發現到 Ruby on Rails 會讓人非常愉快,社群很大,活動力強,而且都會互相幫忙。免費的 Rails Plugin 跟 code 快速的進展都很棒。Rails 需要較少的 code ,較少的可怕的 method call,而且還內建 AJAX 跟 REST。而且 Data Access 跟 template engine 都更有彈性。

But what about those crashes? What about the speed issue? Well, I don’t have the crashes anymore. Don’t ask me why, I don’t know, but it’s fine now, I swear! Something somewhere got fixed and it seems to have solved the problem. However, speed is still one of the low points of Rails. Using caching and proper code optimization should take you a long way, though. Matz, the author of Ruby, is working hard on a new virtual machine that should make Ruby just as fast, if not faster than Python.

最神奇的是,當他回去 Rails 時,Mongrel 不再 crash 了@@!不知道Mongrel 哪裡修正了,反正問題解決了。但是效率依舊是一個問題所在。

My recommendation is, try both for long enough to figure out what works and what doesn’t for you. If you are a long-time Python user, Django might be more compelling for you, but if you are coming from a Java, Perl or Smalltalk background, Ruby and Rails will most likely be what you’ll end up using. Either way, I don’t think you can go wrong.

他的建議是如果你是 Python 長期的使用者,用 Django 吧,如果你是 JAVA,Perl,Smalltalk背景的人,來用 Ruby on Rails 吧。

我的小結論:

從他的字裡行間可以看出幾件事情

  1. Rails 跟 Django 開發時間都很快速
  2. 他真的很不會利用時間,居然用 Rails 跟 Python 各開發了一次,只是因為 Mongrel 對 Hareware 有點 bug
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值