开发者

Ruby on Rails Drawbacks

Ruby on Rails is maybe the most praised web development framework exist. There are tons of reasons for that, but every framework, even the best of its kind, has its dr开发者_高级运维awbacks.

I'd like to know the most common problems you run into when developing Ruby on Rails applications and the issues you often struggle with.


Frequent version updates to the framework make it hard to keep your app up to date - upgrades can break in obscure places.

MonkeyPatching - can cause serious problems for anyone that has to maintain a large codebase over a long period of time.

Performance/Power - Easy to shoot yourself in the foot with memory-consuming database queries using Ruby iterators with ActiveRecord.

But I'll take it over Java or PHP any day


I'm not thrilled about Rails' use of global variables for everything. Model classes find the database connection through a global variable (ActiveRecord::Base.connection), there is the Rails class which is a global access point for things like the logger, the current environment, for caching, etc. ActionMailer makes global variables out of your mailers, and so on and so forth. Rails is built around the use of global variables, so that whatever you do, at any level of the application, you can always reach for a global variable.

This makes testing ugly. If Rails was built on Java, it would make testing really, really hard, but since it's Ruby it just gets ugly. Tests need to stub out a lot of global context in order to run in isolation, and that can easily make tests seem nonsensical. It's not uncommon to see five or ten lines of code that stubs out different global variables, followed by one or two lines of actual test. It's not that five or ten lines of setup for a test is a problem, but without reading the code under test you can't easily see what impact the global state will have, and how it is significant. This makes many tests unnecessarily ugly.

I find it a bit ironic that the Rails community is the most test savvy of any that I've been part of.

Having said that I wouldn't trade Rails for anything that is currently available. The speed at which you can get things done, and the huge number of plugins and gems that removes all the tedious work just blows me away every day.


Like any tech, there's a learning curve. But as a relatively new framework, DHH et al, have been able to "stand on the shoulders of giants" (predecessors) and have produced a great framework.

I've been very happy with choosing Rails as the framework for my commercial sw.

Disadvantages? Not as many libraries as older frameworks such as Java and Perl. -- But there are ways around that problem. Eg call those libraries from Rails or port them.

Performance is usually mentioned in the disadvantages category but cheaper hardware and improvements in later versions of rails have taken care of that. Same with "stability."


For multi-threaded applications, Ruby Threads are called green threads, which are not OS level threads. This can't provide true multi-threading.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜