`

一個在 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
分享到:
评论

相关推荐

    Ruby-GoOnRails使用Rails生成器来生成一个Golang应用

    `GoOnRails`是专门为Rails开发者设计的一个生成器,它允许在Rails应用中集成Go代码,创建Go API服务。这个工具简化了在Rails项目中使用Go进行后端处理的流程,使开发者可以利用Go的性能优势处理高并发请求,同时保留...

    Rails 101 入门电子书

    - 测试安装: 创建一个简单的Rails应用来验证是否成功安装。 #### 五、练习作业0-Hello World - **目标**: - 学习如何创建第一个Rails应用程序。 - **过程**: - 创建新项目。 - 设置数据库配置。 - 创建控制器...

    Rails项目源代码

    Ruby on Rails,通常简称为Rails,是一个基于Ruby编程语言的开源Web应用框架,遵循MVC(Model-View-Controller)架构模式。这个“Rails项目源代码”是一个使用Rails构建的图片分享网站的完整源代码,它揭示了如何...

    关于rails 3.1 cucumber-rails 1.2.0

    Cucumber-Rails 1.2.0是Cucumber的一个扩展,专门为Rails应用设计。Cucumber是一款行为驱动开发(BDD)工具,它允许开发者、测试人员和非技术人员通过一种名为Gherkin的自然语言语法来定义软件的功能。Gherkin语句...

    rails敏捷开发的购物车系统

    在本文中,我们将深入探讨如何使用Rails敏捷开发技术构建一个购物车系统,特别是在参考《rails敏捷开发第四版》中的示例。Rails 3.2.6是本文的基础框架,它是一个强大的Ruby Web应用程序框架,以其MVC(模型-视图-...

    使用Aptana+Rails开发Rails Web应用(中文)

    例如,要在Rails应用中创建一个新的资源,如博客文章,你需要在models目录下创建一个名为`post.rb`的文件,定义Post类,并设置属性如标题和内容。在controllers目录下创建`posts_controller.rb`,定义控制器方法,如...

    Rails

    标题 "Rails" 指的是 Ruby on Rails,一个开源的Web应用程序框架,它基于Ruby编程语言,遵循MVC(模型-视图-控制器)架构模式。Rails由David Heinemeier Hansson在2004年创建,其设计理念是强调代码的简洁性、DRY...

    Ruby-一个Rails引擎提供工作流程的基本基础设施

    在本案例中,"Ruby-一个Rails引擎提供工作流程的基本基础设施"指的是一个专门为实现工作流程管理而设计的Rails引擎。 工作流程(Workflow)通常涉及到业务流程的自动化,包括任务分配、状态转换和审批流程等。...

    rails2-sample

    这里还会涉及如何创建第一个Rails项目,以及如何运行服务器以查看项目。对于新手来说,这一步骤是至关重要的,因为它将奠定后续学习的基础。 #### 3. Introducing Ruby(介绍Ruby) Ruby是一种动态、面向对象的...

    Ruby on Rails Guides v2 - Ruby on Rails 4.2.5

    - **步骤**:通过命令行使用`rails new project_name`来初始化一个新的Rails项目。 - **结构**:新项目将包含默认的目录结构,如`app`、`config`、`db`等,分别用于存放应用程序代码、配置文件、数据库迁移脚本等。 ...

    rails2.3.2

    Ruby on Rails(通常简称为 Rails)是一个基于 Ruby 语言的开源 Web 应用程序框架,它遵循 Model-View-Controller (MVC) 设计模式,用于构建数据库驱动的 Web 应用程序。Rails 强调“约定优于配置”(Convention ...

    django step by step

    **:在Django中,实现一个简单的"Hello, Django!"页面涉及创建视图、模板和URL映射。与Karrigell不同,Django需要更多的配置和文件结构。 - **修改urls.py**:在Django中,`urls.py`文件负责将URL映射到相应的视图...

    Rails3常用命令行命令

    Rails3 是 Ruby on Rails 框架的一个版本,它提供了一系列强大的命令行工具,使得开发者可以快速地构建和管理Web应用。在本文中,我们将深入探讨Rails3中的常用命令,帮助你更高效地进行开发工作。 首先,新建一个...

    Ruby-RailsFootnotes在每一个Rails页脚展示应用程序的相关信息方便调试

    Rails Footnotes是一个插件,它可以在每个Rails页面的页脚处显示详尽的应用程序相关信息,从而简化调试过程。 Rails Footnotes的主要功能包括: 1. ** Sessions 显示**:在开发过程中,Session数据往往承载着用户...

    rails 项目起步示例

    Rails是Ruby语言的一个著名Web开发框架,全称为Ruby on Rails,它遵循MVC(Model-View-Controller)架构模式,旨在提高开发效率和代码可读性。本示例"rails项目起步示例"是一个购物系统,非常适合初学者入门学习。 ...

Global site tag (gtag.js) - Google Analytics