-
Website
http://loopj.com/ -
Original page
http://loopj.com/2009/05/23/a-django-developers-views-on-rails/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
ellisgl
2 comments · 2 points
-
alain94040
1 comment · 1 points
-
inovak
4 comments · 1 points
-
CraigLebowitz
3 comments · 1 points
-
bandito40
5 comments · 1 points
-
-
Popular Threads
I'm a Ruby/Rails guy with some Django experience, and I think you did a good job of hitting some of the bigger differences. I think you're absolutely right that these are more preferences than game-changing differences. I happen to like Ruby, but I come from a Perl background. So there you go.
Anyway, a few points, and corrections:
1) You can use regular expressions in Rails routes in just the way you can in Django. It's just not particularly common or well-documented. But you can do it.
2) I totally, totally agree with you on the view code. It is a very bad practice to throw app logic into the view, but people do it, and Rails allows it. As with all things Rails, however, there are options: Liquid, for example, is a port of the Django templatting language to Rails. We are looking at starting to use it for our projects as a "safe" alternative to erb -- so we can allow view code to be changed without worrying about exposing the full power of ruby in a view.
3) I'm surprised you didn't mention with Django admin, which almost all Django folks do. It is a big plus over Rails. There are plugins that kind of do the same thing, but (at least the last time I looked) nothing is anywhere near as good.
4) I'm equally surprised you didn't mention Django's seriously underwhelming ORM. I know it's getting (or maybe has gotten? The last version I touched was .96) a major re-write, but it was nowhere near as complete as AR for Rails.
4a) Of course, most Django folks don't see AR as a plus, given all the behind-the-scenes magic. They have a point, and at least right now we're sort of stuck with it. But there is hope: Rails 3 will make swapping in datamapper or sequel or another ORM easy as pie (we hope).
5) Loose coupling within Django apps is a HUGE win for Django, and I've wished there were something like it for Rails. Rails Engines are close, but the idea that you can just drop one app into another and off you go is pretty slick indeed.
Anyway. Nice piece.
By The Way, Streamlined and Hobo are pretty cool for admin UIs
I think you'd be surprised with how awesome the Rails community is. Don't let a few people skew your view of the Rails community as a whole. Please check out http://railsbridge.org/ as an example.
You make a good point with the multiple apps in a project concern. But that's being addressed in Rails 3. There's also an interesting trend in the Ruby community (well, maybe not a trend just yet) of building several small, limited responsibility apps that talk via HTTP/REST. The Sinatra guys gave a talk about this at RubyConf 2008 (http://rubyconf2008.confreaks.com/lightweight-w...) That approach definitely keeps your logic separate and contained, but makes your data available between apps. It's probably not the best approach in all situations but it works well for some.
Right now, a major part of the next version of rails is the addition of sub-app structure in the form of Rack apps (stolen from WSGI in python) which manage distinct parts of the app on their own. They're independently testable, but can share libraries and model definitions.
Most people do not use the perl-legacy conventions (such as $! for most recent exception). I very rarely see them, and when I do, they are strictly in command-line experimentation or hackery scripts not meant for long-term use.
'TIMTOWTDI' is practically not a problem for most people because the 'right' way to do it is the only one commonly used.
Ditto views, which are theoretically unlimited in what you can include, but practically used in a way nearly identical to smarty. Any substantial code is put into a helper, which works like Smarty's definitions for adding new template functions.
One problem you don't discuss is the excessive level of metaprogramming used in the Rails core, which is both slow and confusing. This is one of the major problems I run into on a routine basis (stack traces ~30 layers deep routinely) Luckily they're remedying some of that for the next version, which will use more sensible modularity in code design and fewer layers of stack to accomplish the same tasks.
Also, can't help but point out that Python has lots of inconsistencies. For example, in something as simple as a method call:
Want to split a string on spaces into a list?
"some string".split()
Want to get the length of a string?
"some string".length()
oops! Sorry:
len( "some string" )
I mean, wtf.
I see arguments like this all the time where someone says, "Ruby/Rails lets you do this....so it's a bad language/framework to use". What a language or framework allows isn't necessarily the issue, but rather how the programmer uses it.
more that it was more open to developer abuse.
Thanks for the comment.
they are different and talking about pain points in transition.
If you've ever worked on a project with crazy developers you can probably
appreciate what I'm saying.
What's wrong in that?
"having multiple ways of doing the same thing" is not a problem for me, I like that, I like to have options and *choose*
"Multiple Apps in a Project" -> what about the engines? perhaps rails3' mountable apps will solve this issue.
Anyway, I'm not sure what he's talking about exactly when he says "rack apps." Whether he literally means microframeworks like Sinatra, or Rails own internal microframework, Metal. Both are very cool, but have sort of niche appeal.
If he's talking about Engines, then let me say +1. It doesn't quite get us to Djangoland, but it comes close.
The bottom line is it's good to see these frameworks growing and learning from one another... migrations to Django; engines to Rails.
1) Python documentation is significantly better than the equivalent Ruby documentation. If you want to learn Python or look up a function, you go to the Python website and you're done. For Ruby, you can find a large number of third party tutorials and published books... The same comments apply for Django compared to Rails.
2) Based on relatively little experience but I get the distinct impression that Rails is willing to make seriously backwards incompatible changes for relatively minor reasons. The few Rails developers I've had a chance to talk to personally also aren't too thrilled about this aspect.
3) Ruby makes much heavier use of magical function names. If you know what they are, that's all fine and good. If you need to consult documentation or are trying to link it back to how it was created however...