4 ms·
When Rails Fails
- param 17y agoGood article that raises interesting points. I would also be interested in knowing what happens to experienced programmers using Rails - do they simply become used to the poor error messages (so this is just a ramp-up problem) or are you always stuck with making sure everything is without typos etc?
- tptacek 17y agoWithout conceding that these are poor error messages --- most of them are pretty direct, and the one that confused him the most actually gave him a step-by-step for diagnosing the problem --- I do think that addressing this post point-by-point would be another opportunity for Rails to charm web developers. Note that very, very few software development frameworks "gracefully" handle the typo problem.
- jbellis 17y agoIt's worse in Ruby though, because the "use maps for optional parameters" approach means you have to manually check for invalid keys in the map, whereas the same approach in a language that supports native named parameters would throw an exception about the invalid parameter. Several of the errors in this article would be caught by this.
- grandalf 17y agoTrue, but Ruby also allows for the Rails DSL to be fairly concise. If you assume a constant number of typos per typed word, the author would have made more errors in a more verbose language even if it had named params :)
- deleted 17y ago[deleted]
- jeremymcanally 17y agoRails does this many places already. It seems he probably just stumbled into one of the few cases where the flexibility is needed and therefore the parameters aren't easily checkable.
- pvg 17y agoThey strike me as fairly poor, while not catastrophically so. The fact that such messages are typical doesn't make them not-poor. They're not, though, something constrained to Rails and I'm not sure a Rails-specific rebuttal would help all that much - the difficulty is fundamental when the language and abstractions of expression are different from and essentially unknown to the system that's actually doing the runtime error checking. Another commenter spoke of the infamous JSP stack traces. Googling 'clojure error messages' brought up a thread on this as an error message: (ns foo.bar.baz (use clojure.contrib.core :only seqable?)) #<CompilerException java.lang.IllegalArgumentException: Don't know how to create ISeq from: Boolean (NO_SOURCE_FILE:0)>
- swombat 17y agoSummary: Rails has a learning curve. If you're a newbie, you will get confused. None of these errors are confusing once you've been using Rails for a couple of weeks.
- jister 17y agoI think that is the point of the article. The errors are confusing to a newbie - 1 day old
- jamesbritt 17y agoMaybe. I found routing errors to be massively useless until I spent way too much time finding out just what was expected to make things work. Rails seems to favor the approach of first reading many docs and tutorials, then working your way through a series of examples, and always doing things Just So. It's not so friendly if you decide to wing it and try things because your gut says it might just work. The funny thing is, one of the things I like about Ruby is that it works just the opposite; it's quite easy to jump in and guess at what to before reading much documentation. You'll often be right, or you'll (mostly) figure it out pretty fast.
- terrellm 17y agoI recently began working with Ruby on Rails after years in ASP.Net and I still have to refer to the API, Guides, and documentation so I consider myself an amateur. I'm having to get used to programming "better" since I no longer have the assistance of a compiler to catch these type of errors. As you probably know, Rails is about convention over configuration. This increases the initial learning curve but speeds up development once you understand the conventions. I read Agile Web Development with Rails and was able to make it over the initial hump of "what..why is this capitalized and this plural and the singular" stage.
- johnbender 17y agoThe bigger problem you're facing is that ASP.NET has been forcing you to use the, shotgun-in-mouth worthy, event driven model (I've done .net web dev). The rest of the universe has been using MVC for five or 6 years to do web development. Praise be to Microsoft for figuring it out.
- heycarsten 17y agoPoor attention to detail is going to bite you in the ass as a programmer no matter what technology you're using.
- jcapote 17y agogem install ruby-debug
- patio11 17y agoNot to put too fine a point on it, but this is what Rails does when the programmer fails. If you type in invalid identifiers, no programming language or web framework is going to be very happy with you. After that, it is a matter of taste and technical feasibility how the framework handles it. If you're lucky and using Java, you typed in an invalid identifier in such a way that the project fails to compile, and Eclipse will give you little red squiggles. (If you're not lucky, you get an undescriptive error message thrown up from a 700 line stack trace and have to guess what caused it then spend 30 seconds redeploying to see if you guessed right. For example, if you have a genetic predisposition against typing things correctly the first time, botching values in your XML configurations in such a manner than the XML is still valid is going to cause you a lot of pain.) Ruby is an interpreted language and can't feasibly do the red squiggle thingee, but the common errors are trivially debuggable after a few hours experience with the framework. If you see an error message talking about HommeController, you search for homme globally, find the one instance of it, fix the spelling and reload the page you were just seeing. Bam, that took you three seconds.
- smanek 17y agoAs a non-ruby dev, it isn't obvious to me that I should grep 'Homme' instead of 'HommeController' ... A statically typed language with a good IDE (yes, like Java) will find almost all these errors for you as you type (excepting config files, like you said).
- futuremint 17y agoI've found RubyMine to do a pretty good job with "red squiggly things". Its an IDE (yes, like Java) but for Ruby. A dynamic language. Static typing isn't a necessity for a good IDE, just look at Smalltalk.
- latortuga 17y agoAs another data point, a few of my coworkers claim Netbeans is a reasonably good Rails IDE.
- 17y ago
- kellishaver 17y agoThose all look like perfectly legitimate, thorough error messages to me, far moreso than many languages would give you. Would it be confusing to a newbie? Maybe, but they're called newbies for a reason. Pay attention to details + write tests + take the time to learn the framework = problem solved.
- grandalf 17y agoUh, not really. Anyone new to a framework should just stop learning at the first sign of frustration and write a blog post criticizing the framework.
- swerling 17y agoThe Rails backlash sometimes seems bigger then the hype ever was, and is cloying (so savvy, so de riguer). But this article is not one of those (you might think so from its title). The error messages really could use some TLC.
- futuremint 17y agoThe error messages could use some love, but the article is crap. He didn't break Rails in any predictable ways. Who breaks stuff accidentally by misspelling things? Spellcheck can be turned on just about everywhere in any modern IDE or Editor.
- silentbicycle 17y ago> Who breaks stuff accidentally by misspelling things? Wasn't there just another thread about '=' vs. '==' last week?
- kalendae 17y agoas a beginner, things like scaffolds and other generated code pretty much completely eliminate these typo driven mistakes, they also make great starting points for understanding the framework. so that mitigates the problems mentioned for beginners, and by the time you are not a beginner hopefully those error messages make more sense. Personally, i found most of those error messages pretty good. im currently using spring/hibernate as well as RoR very heavily, and trust me i pull my hair out way more on the spring/hibernate side than the RoR side, come to think of it, i pull my hair out exclusively on the java side =)
- gsiener 17y agoHe's right, rails doesn't improve speling.
- wgj 17y agoRails uses Ruby's metaprogramming capabilities extensively, and those capabilities are one of the reasons people choose Ruby, as well as the very thing that makes it possible for Rails to work the way that it does. This is, at least in part, why your code doesn't seem to be on the call stack. My question is, do other language environments do better at exception analysis when metaprogramming is used in this way?
- deleted 17y ago[deleted]
- dasil003 17y agoI don't think it was a good idea to write this article. Some of these messages could reasonably be improved, and some couldn't, but regardless of the merit of each individual complaint when I read someone listing out the result of a half dozen common typos along with a description of how bad these extremely common error messages are, I can't help but immediately judge the author to be one of those NNPP's who spends days tripping over ridiculously simple issues because they never really grokked how to debug in the general sense. I'm not claiming the author is an NNPP, I'm just saying when you get hung up on the basics like this that's the impression that is conveyed.
- gills 17y agoFriend, what you need is a compiled imperative language with verbose type declarations. Java comes to mind. Rails works by following conventions that feed metaprogramming and method_missing magic, and the kind of safety net which the author seems to imply is missing will just never be available in that sort of system. I find little errors like these totally worth it because of the time I save by using rails, and after the first couple of weeks (as many have already posted) most of these are non-issues.
- Zef 17y agoMy response to your criticism: http://zef.me/2355/a-when-rails-fails-follow-up http://zef.me/2355/a-when-rails-fails-follow-up