222 points · by snprbob86 · 16y ago · 133 comments
Yeah, there is a non-zero chance of that happening. However, I keep discovering more and more Rails design choices that either match or closely align with my preferences.
The three biggies comparing to Django are:
1) Powerful templates (including the convenience of "Helpers")
2) Non-declarative schema ORM with full migration support
3) Form validation and generation with Rails doesn't suck
Lastly, Rails feels battle tested and production ready. Everything from the Rake tasks, to the framework surface area, to the plugins available seems tuned for real applications. Python stacks I have tried often require a lot of hackery to handle server configurations, deployment, content builds, template helpers, ... the list goes on and on.
It's awesome you built something so quickly with Rails - I have a similar experience with Django (a tiny amount of time to build a really deep application).
I personally found it amusing/bothersome that you were lauding a fairly magical and opinionated framework when you had old posts deriding Django (and it's ORM) in the past.
It isn't the magic about Django (and it's ORM) that I didn't like. It was the design decisions that didn't match how I think (and approach of declaring the DB schema in code).
Hmm... resonates. Sounds like an insight.
That would implicate flexibility in languages, editors and frameworks -- so you can tunnel through the wall.
More Ruby/Perl than Python and more Emacs/Vim than most IDEs. Etc.
I.e. you don't have a "filepath varchar" field, but a "photo=ImageField(thumbnail_size=[320,200])".
I've had a good experience with South for database migrations, used it in every Django project I tried ... the only things bothering me is that the generated files are too verbose (not much of a problem, since you don't need to modify the auto-generated code), plus a migration-based system doesn't really blend if you've got multiple apps in the same project (refactoring becomes painful).
Other than that, Rails is pretty good because of its declarative APIs. Django has too much boilerplate for my taste ... but I like that for complex projects where I need to tweak things.
3) I don't understand how anyone can prefer another framework's form tools after using django.
Like others have said, considering your past posts, it's just a matter of time before you starting hating Rails. To each their own, but I don't see any of your points as being a valid reason to like Rails over django.
That being said, both #1 and #2 above are plain wrong.
Django template tags are a PITA to write, have weird inconsistencies (largely due to the first issue causing them to be implemented in a very hack-ish way) and don't have access to any request or application state that isn't explicitly added to the template context. Rails template helpers are powerful, easy to write, and ubiquitous. Those properties also make them easy to abuse for functionality that should absolutely be in a model or view function.
South, on the other hand, is powerful, complex, and not part of the Django core. That simple fact immediately makes is less useful. Any Rails developer (and by extension, any Rails codebase) will be familiar with AR migrations. No extra dependencies, training, or versioning issues to worry about.
I mostly agree with #3, though I definitely still find some funky edge cases with Django form validation. They aren't a terribly gently introduction to the "Right Way" of doing form handling for someone more comfortable with HTML than Python, either.
It is a subtle, but fundamental distinction: Django expects me to declare my schema in Python. Rails (and optionally SqlAlchemy, which I like) operate via schema reflection. The declarative approach is redundant, error prone, and resistent to migrations, even with South. The reflection approach matches what you'd do with a bag of Bash scripts in the absence of any framework; as such, it works better in a real world deployment.
I'm pretty disappointed with HN being party to the same smug, knowing, tongue-in-cheek Rails (and to a lesser extent, Ruby) hating that you constantly see on Slashdot and elsewhere. There are merits to Rails, and also drawbacks, as there are with every tool. It isn't magic, or anything close - the code is all there for you to read, and it is just Ruby, no pixie dust anywhere.
Calling it a honeymoon period is not too far from the truth, everything seems rosy and pretty.
As I commented elsewhere in this thread; god knows Python/Django/Zope/Etc have plenty of things to improve and get better at.
I don't code Ruby, so maybe I'm not as sensitive to these things, but I haven't noticed this here at all.
Anyway, I concur. HN seems very pro-RoR to my eyes.
RoR allows lots of HN-types (hackers, people prototyping web business, etc.) to build products quickly. In fact, that's exactly what TFA is an example of.
I'm actually constantly surprised at the number of HN readers who seem to hate on RoR out of general principal.
> There are merits to Rails, and also drawbacks, as there are with every tool.
I think that was exactly his point.
> It isn't magic, or anything close
The black magic reference is from the article itself.
I miss scaffolding though, as I think that was the 'killer app' to RAD, but I'm to the point where I feel like even my simpler apps feel constrained by either Rails or Django at this point (though I'm probably just not knowledgeable enough), and have started doing everything with Tornado and SQLAlchemy, which, while they're currently kicking my ass, doesn't give me any sense of constraint whatsoever.
Of course, upper bounds have always been something that bothered me, even when they were realistically well about my own limits. When I was learning to play guitar, I went out and bought a Les Paul, for the comfort of knowing that whatever else goes wrong, I can't blame the tool. In reality I know that only poor craftsmen do that, but every time I get stuck trying to remember the 'Django' way to do something, I feel like I'm in a box I want to climb out of.
On the whole though, it's quite lovely.
What feels like aeons ago, python-land created the huge monolithic monster, the Zope framework, which was absolutely great at the time. Then people were bitten by writing classes that would unexpectedly manifest some behaviour "as if by magic." The problems became (1) determining whether you would one day out of the blue have code "act weird", (2) figuring out where this behaviour was coming from.
Save to say, many people got bit/burned/scarred. Lessons were learned. There is a fair bit of cross-polination going on; I can't think of any python framework that has not tried to learn from this, and also from the successes/challenges of others (and that includes those of Rails btw).
So when a "battle scarred veteran" makes a terse statement such as this, I don't think by any means it expresses a "better-than-thou" attitude. But you can understand why there might be (rightly or wrongly) an anticipation of pain to come.
When pythonistas look as Rails (for example) and say "hmmn, this pattern looks sort of familiar, wonder how they're going to avoid that type of pain we had", surely this is neither unfair nor over critical, it's just part of the technical dialogue that ultimately advances everyone's "state of the art."
And I don't think anybody in the python world really claims to have the "one true answer." Rather it's more the case of "there is no one true answer, only many flawed attempts; so if you think you've found nirvana, be prepared for some disappointment down the road."
Generally people acknowledge that it's a difficult problem and that we're all dealing with variations of the same issues, irrespective of language or framework. A bit like a balloon; you can squeeze it in one place to make it "thinner" there, but likely it will pop out some place else.
Between that, and the regular stream of ridicule about Rails , Node or just about anything else not Python it just seriously rubs me the wrong way. I don't see anyone changing my opinion of that; nor am I asking them to.
This includes fellow python-oriented people. Myself included.
This is one of those things that sounds true, but falls apart on further inspection. Aren't you allowed to genuinely like your language or tools?
Obviously there are tradeoffs with using any implementation of anything, but people can be completely satisfied and happy with their tools without being starry-eyed morons ...
And I'm sure you arrived at that number in a completely rational process.
He didn't say that at all.
Wow. That sounds exactly like you're talking about Ruby/Rails.
Is this just snark, or are you familiar with cases where Rails' "black magic" stopped working and caused problems? Because I'm not.
Phew. I thought this had turned into Reddit.
Also, don't be afraid of the black magic, read the source, its just plain old ruby down there.
In particular, there is a comment[0] that I think is particularly worth reading:
There are two different definitions of magic in play here.
1. The use of advanced language features in a manner that might be confusing to a novice programmer.
2. The use of ANY language feature to automate some process that a programmer would not expect to be automated.
I am of the belief that the second is the proper definition, which is something that is not usually solved by reading sourcecode, as the question is "Why?", rather than "What?" or "How?".[0]: http://www.b-list.org/weblog/2009/jul/23/magic/#c118751
The real question for any interesting application is not the how or the what, but the why. You can't answer the why just by reading the code. You need to understand the problem and the trade-offs, and for that you need comments and documentation.
I think some people feel like rails went a little overboard on things like this.
A few of the "magic" things I've encountered thus far in Rails can be easily demystified by looking at the code. However, like magic shows, knowing how the trick is done doesn't mean that I can't enjoy the spectacle of it. The execution of the trick is every bit as important as the mystery.
I'd put forth this definition, which applies to both magical performances and magical code:
Magic is taking something which is traditionally considered impossible and making it look effortless.
Some magic tricks really are effortless. Others require painstaking setup and flawless execution. Same thing with code, but only the former is really valuable in production systems.
Sometimes the black magic is great, especially if you're trying to rig a prototype together. Also the configuration is almost always really easy so it's not difficult to start burning through a project.
Other times it's like "too much framework". I've never really been a fan of the all the javascript hocus pocus that occurs and prefer just writing it out on my own.
I also started to get frustrated with the active record query interface and started writing my own queries out because it was faster (for me).
Visual object-relational mappers allow you to integrate different DB schema and classes/objects, instead of deriving one from the other. What do people think of them? They aren't appealing to me, because they aren't very code-like... however, some relationships between disparate type-systems are much easier to express graphically than in code.
URL parameters: http://rails.nuvvo.com/lesson/6371-action-controller-paramet...
I really prefer Sinatra's way of doing this; and it's probably even more appropriate for prototyping (but not for big projects, where separate directories help handle complexity.) It's just amazingly simple and intuitive: http://www.sinatrarb.com/intro.html
get '/hello/:name' do
# matches "GET /hello/foo" and "GET /hello/bar"
# params[:name] is 'foo' or 'bar'
"Hello #{params[:name]}!"
endmatch '/hello/:name', :to => 'hello#index'
My favorites in the Python world are Google App Engine and Tornado (both with my bag of helpers). I like both of them because they are both very practical and embody best practices that I can understand and agree with. Of interesting note, both of them are fairly minimalistic relative to Rails. I thought it was the minimalism that I enjoyed (and to some extent, it is), but in reality it's just that they fit my mental model.
Rails fits my mental model and provides loads of convenience. I'm not saying that it is a panacea. I'm saying that I was pleasantly surprised by how much, and in what ways, it differentiated from the Python world.
IIRC GAE's Python SDK is web.py-inspired. (And Django.)
I mean, i clicked on the link intrigued by promise of [rare] occurrence of female programmers expressing their views on Python vs. Ruby, and read the article somewhat surprised and confused by its tone, style and thought flow - as it was dude's thinking, not gal's :) It is a misleading and deceptive advertising practice :)
[1] Followers of the Mexican revolutionary Zapata, supposedly.
For instance, 'barista' applies to both men and women in Italy.
There are exceptions to the rule, like the one above (Zapatistas) or some professions like "doctores" or "jueces", but they are exception not the rule. There are also many words that dont have a feminine plural, i.e "las soldados", "las jueces", etc
In Italian it is true that the last letter is not a perfect indication of gender... even for people's names (e.g. Andrea should be a male name). But it works pretty well. Not sure if Spanish is similar (i.e. there are exceptions) or not.
The Python case is similar to the widely used "fashionista" for females and "fashionisto" for males in the fasion. Thus it is expected to be "pythonisto" and "pythonistos" for male(s) until there is some gender confusion :)
As soon as you attempt to step outside of what Rails is built for
Rails is a tool for building database-driven websites. It does this well, and I'm confused as to how you can "step outside of" this. Admittedly Rails probably doesn't help you built a GUI application well.
or need some new piece of functionality
Wait, what?
How did you arrive at this conclusion? Rails doesn't ship with authentication, but there's no less than two (authlogic, restful_authentication) major frameworks for authentication, and countless smaller libraries or self-written tools. The same goes for uploading files (attachment_fu, paperclip), testing (rspec, cucumber, steak, shoulda, ...). The list goes on. Rails' active community is one of the main benefits of using Rails in the first place!
Rails is painful to scale
Rails is no more painful to scale than any other web framework. The bottlenecks for scaling usually come down to application design, not your ORM.
Have you ever even used Rails, or have you prejudged it based on posts by people who also have never used it?
Also, while scaling may be a non-trivial challenge, going to over ~100,000 page views a day (95% are between 8am - 6pm) was pretty easy, and very little fuss.
To me real scaling is where you're having to run a cluster since a single server is inadequate to handle the traffic, where you're having to implement or leverage various application caching schemes, etc...
The major issues with scaling was that Ruby in general is absolutely horrible in managing memory, and was constantly having to be restarted. We ended up replacing the app with one built on top of Java which instead of requiring 6 servers with load balancer in front of it, to just 2 servers, one for the front-end and one for the backend. Java served the needs much better, faster, and didn't require the same amount of administration to constantly make sure that everything is still running properly.
Could the same have been done with Rails? Maybe. Are we happier with the Java based solution, its stability and speed? Yes absolutely.
Regardless, I subscribe to the belief that scaling is a good problem to have.
who scales?
Its no wonder when DHH and 37 signal espouse no features philosophy, since implementing them is hard and ruby + rails dont help.
You would rarely find any other engineer worth his salt saying that inability to implement a highly requested feature is a virtue and not a failure.
The only legitimate beef we have as developers is when the choice of tools is not our own. If that bugs you, go and do your own thing.
<for-everybody-commenting-here> Internals of Rails 3 are much much more simpler and well organized compared to Rails 2.x -- I would seriously recommend getting rid of your fears of "black magic" by diving into the source. :) </for-everybody-commenting-here>
Infact a major reason i feel people seem to love NoSQL is not because they have application specific needs which nosql solutions can cater well, but rather they are too bored to actually learn a useful language/system.
They just want all the "just works" stuff.
This is another reason why ruby seems to be popular with HTML/CSS crowd.