Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming Technology

Is Ruby on Rails Maintainable? 348

kale77in asks: "I've become a big fan of Ruby over the past few months, but I'm not at all sure about Ruby On Rails. Automatic code generation sets of alarm bells in my mind; so that, to RoR's promise of 'Web Development that Doesn't Hurt', I automatically add '...until you have to maintain it'. On the other hand, some writers and coders I respect (like the Pragmatic Programming mob) seem to be fans. I've mainly written generators in Python, to produce PHP/SQL/Java from SQL files, but I've always gone back to well-constructed objects, where extension and overloading offers more precise and maintainable customization than auto-generation allows. So is Rails just a nice RAD tool for disposable, cookie-cutter apps (which have a place, of course)? Is high-level generation just a bad OO substitute? And what has your experience of Rails' maintainability been?"
This discussion has been archived. No new comments can be posted.

Is Ruby on Rails Maintainable?

Comments Filter:
  • Uhm... (Score:4, Insightful)

    by Black Parrot ( 19622 ) * on Wednesday December 21, 2005 @01:56PM (#14310498)
    > Automatic code generation sets of alarm bells in my mind

    Do you have a beef with compilers and assemblers?
    • Re:Uhm... (Score:5, Insightful)

      by Pxtl ( 151020 ) on Wednesday December 21, 2005 @02:06PM (#14310599) Homepage
      Well, if you have to do maintenance work on the resulting machine code, then yes, it does alarm me. Otherwise, not so much. Likewise, any code gen environment where you're maintaining the generated code instead of working on the generator should worry people.
      • Re:Uhm... (Score:5, Insightful)

        by Bruce Perens ( 3872 ) * <bruce@perens.com> on Wednesday December 21, 2005 @02:14PM (#14310664) Homepage Journal
        You have two options with scaffolds: let them be generated every time the program starts, or get the code generated into view source code that you can edit from then on. So, you either have code that you don't have to maintain at all, or code that's yours. Pick the best for what you're doing. It's brief and clear code. If you use the generated-every-time option, you can override it method-by-method simply be creating a view source file for that method.

        Bruce

        • Re:Uhm... (Score:4, Interesting)

          by Jack9 ( 11421 ) on Wednesday December 21, 2005 @04:02PM (#14311547)
          Practical question about Rails implementation with Ruby.

          I concede that "scaffolding" is used by EVERY PROGRAMMER. That's the idea behind code reuse. "I'll adapt my authentication I made for a BB system to use as auth for an entire website." "I'll use my pretty table CSS from last year for displaying this data."

          Can you alter the templates generated? If I have coding standards implemented, I have serious doubts the default RoR scaffold templates specifically adhere to mine. If I can't alter these templates, the answer to the article is no. If I can alter these templates (I assume it's possible), the answer to the article is yes.

          How is this article generating all this Ruby-anti-Ruby nonsense when it's a question of Rail implementation? More importantly, why isn't there a PHPoR?
          • Re:Uhm... (Score:3, Informative)

            There are a few. I've never used them, so I can't speak to their quality, but apparently work is being done on exactly what you ask:

            Biscuit: http://bennolan.com/biscuit/ [bennolan.com]
            Qcodo: http://www.gadgetopia.com/post/4726 [gadgetopia.com]
            Cake: http://cakephp.org/ [cakephp.org] ... just to name a few. I just google'd for 'php rails', and got lots of interesting links.
          • Re:Uhm... (Score:4, Informative)

            by Marillion ( 33728 ) <ericbardes&gmail,com> on Wednesday December 21, 2005 @04:34PM (#14311823)
            RoR has explicit and implicit code generation. Model classes which extend ActiveRecord::Base have amazing amounts of implicit, runtime-generated methods which can be replaced with custom logic if that's what you want.

            The template generators are explicitly called development-generated blocks of code which are intended to be one-time only and edited by hand thereafter to meet business objectives.

            Between the two, I love the former and dislike the later. I usually don't use scaffold built views except for Quick and Dirty lookup table administration. I think the difference between the final view and an empty file is smaller than the scaffold view and the final view.

          • Re:Uhm... (Score:3, Informative)

            by Bruce Perens ( 3872 ) *
            Can you alter the templates generated?

            Yes. Either completely override the template for a specific method starting from zero with your own code, or get the code generated for that method and then alter it.

            How is this article generating all this Ruby-anti-Ruby nonsense when it's a question of Rail implementation?

            Because this is in part an instance of the perennial compiled-vs-interpreted argument.

            More importantly, why isn't there a PHPoR?

            IMO, because the developers capable of doing something like RoR 1)

    • Re:Uhm... (Score:2, Funny)

      by eclectro ( 227083 )
      Do you have a beef with compilers and assemblers?

      No, but interpreters have always slowed me down.

    • Re:Uhm... (Score:5, Insightful)

      by Bastian ( 66383 ) on Wednesday December 21, 2005 @02:11PM (#14310641)
      I think the author is thinking of this from an attitude of generating code using RoR and then maintaining the generated code. Which is the wrong way to do it. If there's a bug in the original RoR code, change the original code. If there's a bug in the generated code, you change code generator.

      If you're writing the original app using a code generator and making all subsequent modifications to the software by modifying the product of the generator, you've sort of missed the point.
      • Re:Uhm... (Score:3, Insightful)

        by Dracolytch ( 714699 )
        So the code generator should be able to automatically generate any potential output? Hmm... I'm not sure I agree with that.
      • by gfim ( 452121 ) on Wednesday December 21, 2005 @05:56PM (#14312474)
        Unfortunately, that's exactly what most Visual C++ programmers mean by code generation. The "wizard" generates a huge chunk of boilerplate code that the developer never understands. He would prefer not to even look at it, but occasionally has to make some minor tweak.

        When I use code generation, I generally write the generator too. As you say, there are two choices: you either generate the code once and then maintain it completely manually (i.e. it's just the scaffolding), or you maintain the generator and the input to the generator but never touch the output of the generator.

        Tools like Borland C++ Builder and Rational Rose try to give you the best of both worlds with the "round trip" code generation/reverse engineering. While they do have some advantages, in my opinion they aren't overly successful at it.
    • Re:Uhm... (Score:5, Informative)

      by publius_ovidius ( 870895 ) on Wednesday December 21, 2005 @03:34PM (#14311289) Homepage Journal

      Do you have a beef with compilers and assemblers?

      This is a valid question. Quite often when we have a robust low-level language generating high-level language (HLL) code, it's extremely well thought out and tested. However, many are dubious about HLL generating HLL code. I suspect (though I can't prove it) that this is because HLL -> HLL tends to be less widely used and thus is less thoroughly tested and less planned. When done properly -- particularly when covering a restricted and well-defined domain -- it can be extremely powerful. When done improperly, it's a nightmare.

      Rails has a large enough user base that most common bugs have been eradicated but from what I've seen, it appears to have a problem that many fourth generation languages suffer from: if your problem fits its domain, it's a piece of cake to solve. When your problem doesn't fit its domain, it can be extremely difficult to solve (anyone who's ever worked with the 4GL Easystrieve Plus can readily testify to this). Most web-based apps, though, are simple enough that folks working with Ruby generally don't seem to have much of a problem with it. However, I've heard horror stories about people trying to use their custom model in lieu of what Rails natively supports -- though I've not had first-hand experience.

      Compilers and assemblers tend to be general purpose tools which address a fairly wide problem space. HLL -> HLL tools tend to be special purpose tools and trying to get them to solve problems they aren't optimized for can be trying. In the case of Rails, one thing it excels at (CRUD apps) is a well-known problem space and Rails fits quite nicely.

      So I have to say that comparing Rails to compilers or assemblers doesn't quite fit simply due to the differing focus of said tools. However, all of them require that someone trying to work with them understand what they're doing (at least at a high level) and that brings down the maintenance burden quite a bit. Personally, I'm quite impressed with Rails and am happy to see it spread.

  • It's obvious... (Score:5, Informative)

    by eruanno ( 598239 ) on Wednesday December 21, 2005 @01:57PM (#14310500) Homepage Journal
    It's quite obvious that the concept of the automatic code generation done in Ruby On Rails was either not completely grasped or completely missed by the author. The whole purpose of the code being generated was to give you a basic structure to take and change until it was what you needed it to be. This is precisely why it is called 'scaffolding', because it gives you the framework to get started with.

    As far as the Ruby On Rails framework itself is concerned, it is extremely capable and flexible for handling a great deal of web application projects. Of course there will be specific functionality that Ruby On Rails will not handle very well — there never are perfect solutions.

    I wouldn't consider the reviewers objections completely devoid of import, just misguided. You must always be careful about anything you didn't do yourself, but you must exert the same care and attention to the stuff that you do create yourself! Often we put far too much confidence in our own coding skills.

    So, in the end, the concept of Ruby On Rails is simply to alleviate the mundane, rote programming that goes into the basics, particularly the structure and minimalistic database interaction, and make it surprisingly simple.

    M.T.
    • Re:It's obvious... (Score:5, Interesting)

      by qslack ( 239825 ) <qslack@@@pobox...com> on Wednesday December 21, 2005 @02:28PM (#14310763) Homepage Journal
      This is exactly right. The scaffolding is seen as the major feature of Ruby on Rails by far too many people. It's not. In fact, if anyone were making a serious, production-level app, they wouldn't even use the scaffolding. It serves only three purposes: to help newcomers to the language become familiar, to jumpstart a simple Web app, and to look amazing on the screencasts [rubyonrails.com].

      Ruby on Rails is great. At the very least, everybody should try it. It's no silver bullet, but it is a huge improvement over most everything else out there.

      Using Rails is a bit like using a Mac: you always run into these little helpful features that make you think it was created just for you.
      • Re:It's obvious... (Score:5, Informative)

        by bryanthompson ( 627923 ) * <logansbro.gmail@com> on Wednesday December 21, 2005 @03:55PM (#14311470) Homepage Journal
        I agree 100%. The scaffolding should be used to get a feel for how quickly developing *anything* on Rails can be. For newbies or J2ee migrants, the short videos on the Locomotive and rubyonrails.com site shows how scaffolding can be built, modified, etc. There's no way I'd put scaffolding into any site that others will see. It's quick, dirty, and easy. Use and extend it, but don't rely on it!

        Coming from J2ee-land, Rails has been really easy to pick up, and very easy to maintain--so far. If you visit the #rubyonrails irc.freenode.net, it's very active, and there are a ton of Java guys who want to see what RoR is all about. My biggest problem was figuring out the project structure and then figuring out the standards. Parenthesis, semicolon line endings, and block brackets not being required really turned me off at first. It felt sloppy and just weird.

        I think the biggest advantage is that all of the add-ons we were using are included in RoR. Log4j and hibernate, for example, can be hell to set up and maintain. With RoR, the logger is built in, and its migrations are just hibernate-ish enough to get the functionallity I wanted out of it. The pieces you need are there, and they are easy to use. For us OS X guys, Locomotive makes it ridiculously easy to start out also. I don't know about setting up a RoR app in a production environment... From what I've read there looks like a lot of initial configuration, but I had my share of difficulties with Tomcat also.

        Since we're still developing the app, I don't know how easy it will be in the future to maintain. I worry about Ruby updates and how they'll interact with old code. WHat happens when deployed in totally different environments? The API is total suck, and there really isn't a ton of information like there is on J2ee. I want to know the best practices and common ways of doing things, but all I find are blogs and random articles that don't really get into detail. The Programming Ruby and Agile Web Development with Rails books are great, but they don't get into these other areas.
    • Re:It's obvious... (Score:5, Insightful)

      by happyemoticon ( 543015 ) on Wednesday December 21, 2005 @03:46PM (#14311378) Homepage

      Here's how I'd look at the problem. I'm not a developer, but I'm decent with Java, C++, Python, and Perl. If I look at some random Java project, I can pretty much grok what it's saying and make the changes I need. The same is true for many languages I'm not really familiar with, like Lua and php (I've been updating a WoW mod that was dropped by its creator).

      Now, mind you I might just be upset because I looked at RoR and didn't instantly understand everything. But I was generally put off by the amount of things that were being invoked as if by magic, and I'm even less of a magician than I am a developer. At least with some Java project I've got all the code in that directory, and I know which parts of the standard API and which 3rd party modules are being imported. I looked at some of the stack traces that I got and I was totally bewildered.

      One thing that could alleviate this is good documentation. The majority of RoR docs I've found are written by people who either have no intention to truly impart knowledge or don't have the competence, and are directed at non-programmers. They're consummately infuriating. I would much rather hear the ugly truth (I read Programming Perl and Python in a Nutshell for leisure sometimes) than be treated like a child. This pretty much means I have to read the API specs, which ain't no walk in the park.

      What this boils down to is if I were in a management situation, I wouldn't know how to hire or deal with a Ruby dev. First off, I couldn't just get somebody I thought had good character, work ethic, an excellent track record and a portable skill set, I'd have to hire a Ruby on Rails Developer. I mean, there are some times when you really want an expert in the field, but those people are hard to come by. Then if I hired him I'd be like, "Hey John, what's this function over here do?" and he'd be stirring a black pot in a pointy hat while cackling, "Double, double, boil and trouble / Fire burn and cauldron bubble!"

  • Yes, very (Score:5, Interesting)

    by Bruce Perens ( 3872 ) * <bruce@perens.com> on Wednesday December 21, 2005 @01:58PM (#14310512) Homepage Journal
    Maintainability is a combination of several factors. Most important is: can you read and understand the code? Ruby on Rails wins in this category because it's brief - smaller and thus easier to comprehend than Java - without being cryptic like APL. Second most important is: is it easily modified? Here Rails wins again, because of the say it only once philosophy and because of Ruby's duck typing *. Say-it-once means that you don't have to track down the other places where you've had to say the same thing (as in Java) and change them. Duck typing means you can change an object substantially without the user of that object seeing the change, because the user only knows what methods the object is expected to respond to, not the object's type.

    Bruce

    * Duck typing: If it looks like a duck and sounds like a duck, it's a duck! Object types don't matter to the users of Ruby objects. What matters is that the object responds to a particular collection of methods. This is something like virtual functions, but does not require inheritance from any class or virtual class although inheritance from a Ruby module (sort of an abstract base class) is often the best way to implement those methods. So, a Ruby object might export a collection of methods called Enumerable and would respond positively to an is_enumerable? method to identify that those services are available.

    • Re:Yes, very (Score:2, Informative)

      If you had to use something more than once in Java, why not just write it once and overload the method or the object. That statement that you have to edit the same thing in different places does not make sense if Java is coded correctly.
    • On the other hand, just because a person quacks, it doesn't make them a duck. If you have an object with methods that you are calling, just because those methods exist, doesn't mean that they're doing what you want them to. If you have 2 objects with the same 5 functions, who's to say that the implementation of a function in one class has anything to do with the same function in the other class.
      • Re:Yes, very (Score:5, Insightful)

        by Abcd1234 ( 188840 ) on Wednesday December 21, 2005 @02:22PM (#14310726) Homepage
        Yeah! And if in, say, Java, you have a superclass and subclass, how do you know the subclass didn't override superclass methods to do totally different things!

        It's called not doing stupid stuff. Now, I don't know much about Ruby, but in Objective-C, these things are called Protocols, and in Java, they're called Interfaces, but the rule is that if you implement a given protocol, then you must conform to a given contract. Can a developer deviate from that contract? Yes. Are they fucking retards if they do? Absolutely! If you want to prevent that, your only option is to work with a language like Eiffel which incorporates design-by-contract at the language level... of course, even that isn't foolproof.
        • Hm. Is it possible to add DBC to Ruby? Has anyone already done it? There are enough instrumentation entry points in Ruby that you could probably do it without modifying the interpreter.

          Thanks

          Bruce

        • Re:Yes, very (Score:3, Insightful)

          by Hognoxious ( 631665 )
          how do you know the subclass didn't override superclass methods to do totally different things!
          And how do you know that a method does what its name implies anyway? Or that it works as intended? At some point, you have to trust the author of them. Or verify the source yourself.
        • Coincidental naming (Score:3, Interesting)

          by kabloom ( 755503 )
          The problem that he's referring to in ruby is coincidental naming.

          I implement a function with a name "join" without knowing what the rest of the world uses it for. (e.g. my "join" joins a chatroom, but the standard use of "join" is to concatenate all of the objects in an array together into a string.) Suddenly my object looks like a duck, and quacks like a duck, but doesn't act like a duck. Ruby thinks it can be used in the same context that everything else uses it in, but semantically it can't be used ther
        • And if in, say, Java, how do you know the subclass didn't override superclass methods to do totally different things!

          Well, if you make a method final in Java, the compiler generates an error when you try to compile an overridden subclass method. That's one way to take care of the problem :-) Perhaps Ruby has something similar...?

          RoR, codegen.. from what I gather, there's nothing there that wasn't done years ago. It's called WebObjects. [apple.com] So far, no one has mentioned to me or pointed out anything RoR does

      • Re:Yes, very (Score:3, Interesting)

        by Eivind Eklund ( 5161 )
        No, you're not guaranteed that something that respond to the same methods with the same parameter counts is really implementing the same interface. However, while writing an article and a bunch of code for type checking in Ruby, I read've read probably hundreds of discussions on this and certainly thousands of messages. I've not once heard anybody claim that they'd seen this happen or heard of it happening as a problem in practice.

        Eivind.

    • Re:Yes, very (Score:4, Insightful)

      by jarran ( 91204 ) on Wednesday December 21, 2005 @02:21PM (#14310720)
      Of course, Java doesn't require inheritence either. What you have described is exactly what Java interfaces are for.

      Ruby's lack of typing does make it incredibly flexible, but it has significant disadvantages to, namely that a whole class of programming errors which should be found at compile time, go totally unnoticed until the program tries to execute that code path and finds that it has an object of the wrong type.

      Don't get me wrong, I program Java at work and hate it, and I program Ruby for play and love it. But I still think we can do significantly better.

      Languages like O'Caml, manage to get the best of both worlds. For example, you can write a method in O'Caml which takes a object as it's parameter and uses a "compare" method on that object. Elsewhere in your program you try to call this method with an object that doesn't have a compare method. Not only will O'Caml detect this error at compile time, it can do so without forcing the programmer write type declarations everywhere.

      Sadly O'Caml isn't the answer either, it doesn't have a remotely decent web application framework. But I think that combining strong typing with type inference is the way to go for rapid prototyping environments.
      • Re:Yes, very (Score:3, Interesting)

        by Bruce Perens ( 3872 ) *
        Not only will O'Caml detect this error at compile time, it can do so without forcing the programmer [to] write type declarations everywhere.

        Only if the object's type is explicit at some point in the function call tree at compile time, I suppose. I can think of dynamic scenaroios where this would not be knowable at compile time.

        Static checking as you describe would involve propogating type information from the called function up through its callers while that call sequence is being checked. While nobody doe

      • Sadly O'Caml isn't the answer either, it doesn't have a remotely decent web application framework.

        I honestly don't know if it's something that could be considered remotely decent (I don't do web apps and thus have no first-hand experience with it, or well, anything else in the genre), but have you looked at AS/Xcaml [asxcaml.org]?
    • Re:Yes, very (Score:3, Insightful)

      by spludge ( 99050 )
      Most important is: can you read and understand the code? Ruby on Rails wins in this category because it's brief - smaller and thus easier to comprehend than Java - without being cryptic like APL

      I disagree with this. I recently had to debug some RDoc code to create a custom generator. RDoc a big chunk of mostly uncommented Ruby code. Trying to debug and understand it was somewhat reminiscent of trying to debug Perl. Ruby gives a programmer the same expressiveness that allows them to write highly cryptic sh

      • To be fair to RoR, RDoc isn't part of it.

        Thanks

        Bruce

      • Re:Yes, very (Score:3, Insightful)

        by jbolden ( 176878 )
        You describe the program as: mostly uncommented, highly cryptic short statements that are very difficult to unravel, modifies the runtime behaviour of an object from anywhere in the code. Why do you think it was written to be maintained by an external author? It seems to me the author hadn't intended a 3rd party to maintain his code. Further my guess is that he was conceptualizing the problem differently than you were. "Highly cryptic" usually means that you need to understand how the programmer viewed
    • Java Interfaces (Score:2, Informative)

      Java interfaces allow you to declare that something is a Duck, so it must be a duck. However, with Java, I can ensure that anything I think I want to call a duck does indeed fulfill the contract of being a duck. What in Ruby forces you to properly export the collection of methods in Enumerable when you defined is_enumerable to return true? Nothing?

      In Ruby, you can write code that assumes a parameter has a method called foo. In the future if I make a new object, I can add a foo method to it and pass it i
      • DBC is useful and would be a good feature to add to Ruby. But even DBC doesn't guarantee that anyone implements a method correctly, only that they return the right type. As I've noted elsewhere, some degree of static checking of Ruby is theoretically possible, and a compiler is in development.

        Bruce

      • Re:Java Interfaces (Score:2, Interesting)

        by Tamerlin ( 940577 )
        "Java interfaces allow you to declare that something is a Duck, so it must be a duck. However, with Java, I can ensure that anything I think I want to call a duck does indeed fulfill the contract of being a duck. "

        How? If I have an interface with a method "quack" that is supposed to print a message from a string you pass it, and I write a class implementing it that calculates the factorial of 1,023,342 instead, you can call it, and it will compile and even run, but still violate the contract of being a duck
      • Re:Java Interfaces (Score:3, Interesting)

        by Dalroth ( 85450 )
        Java interfaces allow you to declare that something is a Duck, so it must be a duck. However, with Java, I can ensure that anything I think I want to call a duck does indeed fulfill the contract of being a duck. What in Ruby forces you to properly export the collection of methods in Enumerable when you defined is_enumerable to return true? Nothing?

        I call BS. Just because a Java class implements an interface, does not mean it implements what is expected of the interface. If your compare method returns a -1
  • by blakeyez ( 827270 ) on Wednesday December 21, 2005 @01:58PM (#14310517)
    Rails is _not_ a code generation framework. Note the period on that sentence.

    Rails may provide the some simple scaffold generation, but that's only there if you _want_ to use it, and it happens to fit the way you'd like a particular part of your app to work. The code produced is concise, easy-to-follow, and thus easy-to-maintain.

    For my own applications, I barely ever use scaffolding. It works well for simple admin screens where I just want 'something' that works for now, then will spend some effort on designing it a little better, later.

    Rails is as maintainable as you make it. If you're a poor programmer, you're likely to write unmaintainable code, no matter what language or framework you have to help you. Rails helps point you in the right direction, but in the end, it's up to the _developer_ how maintainable his/her code is.
  • by Boss, Pointy Haired ( 537010 ) on Wednesday December 21, 2005 @01:59PM (#14310524)
    Rails has created quite a buzz in the Web 2.0 community, which means a lot of people jump straight into Rails without any prior knowledge of Ruby; and then when they find they can't get very far they blame that on Rails.

    It's like hacking the Linux Kernel without ever having programmed in C. You're bound to think it sucks because you won't have a clue what's going on.
    • Somebody mod this guy up!

      Myself, I'm in that situation. I've never done any coding professionally except to support my own work as network admin. Having started in Perl, every problem I come across I try to solve in perl (even when a simpler shell script would suffice).

      Now that I'm giving rails a try, I find myself frustrated because I realize I know nothing of ruby. So next step (for me) is to put aside rails and learn some ruby. Rails will come afterwards.

      If you want rapid application developement, I'
    • Christ, have you to be on smack. Have you ever LOOKED at the Linux Kernel code? There is some CRAP in there. Mountains of it. Solar systems of it.
  • by Anonymous Coward on Wednesday December 21, 2005 @01:59PM (#14310526)
    Ruby on Rails script/generate generates very little code. If you choose "File, New class" in Eclipse, you get the about the same amount of code, as you would get if you used rails generation features. The only difference is that ruby on rails also generates a test class for the model.

    Scaffolding generates a bit more code, but it is never intended to be actually used. It is ment to be slowly replaced, piece by piece, by your own code. So I don't think the disadvantages of code generation really applies here.

    So yes, in my experience a ruby on rails project is maintainable.
  • My limited use of RoR has been favorable - no issues, as of yet, regarding maintainability or spheghetti-O code

    It has worked as promised and I have been pleasantly surprised by its functionality
    btw, my main use was creating a new database for an intranet application
  • by old_skul ( 566766 ) on Wednesday December 21, 2005 @02:01PM (#14310543) Journal
    Devs are always looking for ways to reduce the amount of time it takes to code something. Admins are always looking for ways to automate their jobs. RoR is nice for devs but makes the admin tasks pretty hard - unless the admin knows his way around the product about as well as the dev does.

    Now add the additional idea of a custom-designed project that the dev put together - and didn't document (because devs never document, right?). Chaos ensues.
  • Bad OO Substitute? (Score:5, Insightful)

    by cheesedog ( 603990 ) on Wednesday December 21, 2005 @02:02PM (#14310552)
    I'll make a bold counter-claim: Object-oriented programming is a bad substitute for straight-forward dynamic binding and typing.

    I've been doing almost pure OO programming for the past 8 years (using mostly C++ and Java), but recently took up Python (for python-twisted and pyWxWindows) and Ruby on Rails (for server-side development), and I can tell you that it is much simpler, easier to debug, and quicker to get done than taking the time to create massive class hierarchies whose inheritance structures and interfaces only exist to satisfy type-safety requirements.

    Don't get me wrong. I like writing class hierarchies as much as the next guy. I've spent years doing it. But when I compare what I can get done in 30 minutes in, say, Python, to what I can't get done in 3 hours in C++, the advantages start to become very clear.

    • by Bruce Perens ( 3872 ) * <bruce@perens.com> on Wednesday December 21, 2005 @02:09PM (#14310625) Homepage Journal
      Ruby doesn't contradict the Object Oriented programming paradigm. If you go back to the origins of OO in Smalltalk, it was much closer to Ruby than some tightly-typed OO languages like C++ and Java. Perhaps the lesson to be learned is that tight typing of class references isn't that good an idea.

      Thanks

      Bruce

      • by the chao goes mu ( 700713 ) on Wednesday December 21, 2005 @02:41PM (#14310867)
        Actually Java's biggest problem in my experience is inconsistent typing. Why does the method to fetch a port return an Integer object, but socket connections want an int primitive? Or how about the eight million different date/time object types? I think if that mess were made even a bit more consistent, Java would have a significantly faster development cycle.
      • by IamTheRealMike ( 537420 ) on Wednesday December 21, 2005 @03:27PM (#14311230)
        Of course it isn't as simple as that. If it was, everybody would use Ruby or Python for everything and Java/C#/C++ would be dead.

        In practice, strong typing and the lack of Ruby-style dynamism allows compilers and runtimes to make optimizations they otherwise couldn't. Those matter, a lot, try looking at the memory usage or execution speed of your average Ruby program sometime! Worse, it's an unfixable problem, at least without modifying the language itself quite heavily.

        I think the way we're going to go with language design, as an industry, is more like Boo [codehaus.org] - a language which on the surface looks like Python and has many of the clarity and programmer efficiency features that make Python so much fun to use, but under the hood is actually a traditional strong/static typed language. In Boo, type inference is used to let you drop many of the redundant type declarations that normally clutter up Java/C#/C++ style code, and a smart compiler plugin system is used to let you add new features to the language easily. This is traded off against the ability to do things like add/remove methods at runtime which are hard to implement in a time/space efficient manner.

    • I totally agree with you here. I was writing a small configuration program in C and GTK when I had little experience with GTK programming. Been writing in C++ and C for years. After a few days of hacking at it, I switched to PyGTK and finished the thing in one day. Since then I've been trying out Python in all sorts of other situtations, and I'm really impressed. I'm really loving its clarity and dynamic binding, and it's incredibly useful for prototyping ideas even if I end up implementing them in ano
    • ### and quicker to get done than taking the time to create massive class hierarchies whose inheritance structures and interfaces only exist to satisfy type-safety requirements.

      I totally agree that a lot of coding done in static-typed languages is simply wasted, since it serves no other purpose then to make the compiler happy, however on the other side I love compile-time checks, far to many times I had some piece of Python, Ruby or some other dynamic typed language which ended up just being a *HUGE* pain to
  • by 5n3ak3rp1mp ( 305814 ) on Wednesday December 21, 2005 @02:02PM (#14310554) Homepage
    Try Ruby (the language) here [hobix.com]. Integral to understanding much of Rails.

    I released my first production Rails app last month. I like it a lot. I have a background in ASP/SQL Server/PHP. Not having to use Microsoft Windows itself is a huge win. But I like the design of the language and the framework and the built-in separation and a thousand little other things. Check out #rubyonrails on irc.freenode.net, great community there too.
  • Wrong Idea (Score:3, Informative)

    by AntiDragon ( 930097 ) on Wednesday December 21, 2005 @02:03PM (#14310568)
    The "Automatic Code Generation" is a slight misnomer. It would be better to think of it as "Semi Automatic Code Generation". (Mental image...hehe).

    It's just a part of the system that can *if you so desire* generate basic classes and parts of an MVC system by inspecting your database. It's basic and is designed to give you something to work with while you build the actual application you want.

    The real strength of the Rails framework is the various support libraries and the way it gently encourages you to follow specific coding conventions (Hungarian notation fans, run for the hills!). If anything, this not only speeds development but makes maintenance a breeze - Ruby is a very readable language when not abused.

    Hmm...that does all sound a bit fan-boyish, doesn't it? Well, I'm a PHP convert to Ruby and I have to say I wish I'd decided to take a look sooner.

    Short answer - Rails systems are probably more maintainable than your average ASP/PHP system.
  • by Boss, Pointy Haired ( 537010 ) on Wednesday December 21, 2005 @02:04PM (#14310574)
    Automatic code generation sets of alarm bells in my mind;

    You're reading too much into it. Just like when you're building a house; you put the Scaffolding up to give you something to work from. When you're done building your project, the Scaffolding is gone.
  • by fury88 ( 905473 ) on Wednesday December 21, 2005 @02:04PM (#14310576)
    To stay FAR FAR AWAY from Ruby on Rails here. In fact, they sent us java developers to the Java conference and we were forbidden to go into any of those seminars. Why? Probably because they don't want us picking up any bad habits.
    • My guess is that it is so you won't revolt.
    • fury88 wrote:

      ... they sent us java developers to the Java conference and we were forbidden to go into any of those [RoR] seminars. Why? Probably because they don't want us picking up any bad habits.

      I think it is more likely they didn't want to foment a general revolt amongst their Java devs. It kinda sucks to learn you can do the same things in 1/3 the time or less by changing languages.

      But perhaps you meant this all along and I didn't pick up on your subtle humor.

  • I think a lot of the "it's not maintainable or scalable" assessments of Rails come from people who have seen its code generation and "scaffolding" features and think that those are the main advantage of Rails. It's true that one can only do so much with the "scaffolding" which is simple and generic. However, the real power of Rails comes not from the scaffoldings but from the framework Rails provides in which to write custom code. I've written two Rails applications and maintained several others. None of th
    • Besides the scaffolding, what is it that differentiates RoR from any other language. Most languages have the same constructs when you get down to it. Loops, conditionals, functions, classes, variables. What really sets apart a language is either A) the Framework/API as in Java or .Net, or the ability to quickly generate code to do more complex things quickly. I can learn just about any language in a couple days. It's learning to use the framework/API and the other features of the language such as scaff
  • by TheUncleD ( 940548 ) on Wednesday December 21, 2005 @02:07PM (#14310607)
    Rails provides more then the scaffolding capabilities and simple framework of designing a blog as seen in the video. It provides the structure for fast and organized ruby application development by setting up for the user a foundation of modelling, views and controllers that are easy to use and distinguish. It is not the magic wand to a great web application. The magic wand comes with Ruby programming experience and learning to tie it into Rails application development. You could even go as far as stepping beyond the "narrow view" of what rails is doing and see the bigger picture, understanding that Ruby is supporting all of this webmagic and rails is providing the "rails" as it claims to. One challenge many of the "why is this better than Php?" questioners have difficulty seeing past is the far smaller community rails has, the less clear translation between what php can do and what rails is capable of, and the predefined examples of rails applications in action. Many people leap to using PHP becuase it provides pre-existing code snippets that make the same thing true of many php users, "simple cookie cutter codejobs." Rails offers you a chance at not only using a great framework, but also a great programming language that its built on to make more pragmatic and simpler design tactics to getting your website online and active. Another alternative to rails is Iowa which offers a lighter approach to maintenence, though remains less documented. It can be found here: http://enigo.com/projects/iowa [enigo.com] Whatever you choose to do, look deeper into the situation then the surface of what appears to be "cookie cutter" programming and realize that a powerful tool lies beneath all of this: Ruby.
  • I find it unfortunate that most of the 'newbie' tutorials jump right in to how to generate scaffold code. This code is a bit unmanageable and hard to modify, but I think it has a certain 'WOW' factor associated with it. Once the novelty wears off and you need to develop real applications, you will rarely use the generated scaffold code, and the code you write within the framework will certainly be manageable.

    Where I think Rails comes out on top is the fact that it includes a full blown ORM and an MVC i
  • I've been using Rails for several months, and I think it's "automatic code generation" is no big deal, and nothing to worry about. If you're worried about maintainability, it the wrong place to focus.

    The only time code gets generated for you automatically is at the very beginning of a project to create "scaffolding". That scaffolding is great, because it lets you get something up and running very quickly, but in my experience, it NEVER survives in the body of the project for long--you always want to do
  • by bloodroot ( 816177 ) on Wednesday December 21, 2005 @02:12PM (#14310642)
    Unless they're making a promotional movie on writing a slashdot replacement in 5 minutes
  • Eh kindof (Score:2, Interesting)

    by oGMo ( 379 )

    Rails is OK. It's a great way to get into the language and attract users, and for that I appreciate its existance.

    That said, as a fairly long-time user of Ruby myself, I wouldn't use it. Many of the features it provides are more academic proof-of-concept implementations than well-tested, well-polished ones. It requires you to do a lot of things manually that could easily be done automatically, and you still write bits of SQL in your code. Also, more importantly, it doesn't provide an application layer

    • Re:Eh kindof (Score:3, Informative)

      by brian_olsen ( 564201 )
      "It requires you to do a lot of things manually that could easily be done automatically, and you still write bits of SQL in your code."

      Which type of things can be done automatically, you see? Also, what is so bad about writing SQL queries *for complex queries*? I know in my case, I will not be hopping from database system to database system to worry about SQL compatibility issues.

      "Also, more importantly, it doesn't provide an application layer that entirely abstracts the functionality from the interface. Th
    • Re:Eh kindof (Score:5, Informative)

      by znu ( 31198 ) <znu.public@gmail.com> on Wednesday December 21, 2005 @02:51PM (#14310951)
      I've been using Rails for about 7 months, and have done two major projects in it. I completely disagree with your assessment. For starters, it's not at all tied to MySQL. PgSQL support is also very good. My understanding is that Oracle support is not so great at the moment. But I expect that will change. My real point here is that Rails is not inherently tied to any specific database; it's just a matter of what ActiveRecord adaptors happen to be out there right now.

      As far as requiring the user to write SQL code, yes, you do have to write fragments of SQL code, sometimes. But SQL is a useful way to describe queries -- that's the whole point. Would using some other query language, that got translated to SQL, be any better? I don't see why it would.

      Your comment about Rails not abstracting functionality from interface seems off base as well. Rails adopts a standard MVC architecture, which is pretty much the standard method for abstracting functionality from interface. If you're not getting such abstraction in your Rails apps, you probably just need to think about exactly what should go in the models, what should go in the controllers, and what should go in the views, and rearrange things a bit. Like any other MVC environment, Rails can't prevent you from e.g. putting view-specific code in your model. All it can do is provide a structure that allows you to properly separate these things if you take the time to think about your design properly.

      Finally, on the charge that Rails only provides proof-of-concept features, I think you've misunderstood one of the major design principles of Rails. Rails is intended to provide a framework to build on, not a bunch of components you can plug together to get a web app without writing any code. As such, many of its components focus on the core functionality that's really useful, to the exclusion of other stuff. That other stuff might sometimes be nice to have, but it frequently locks you into doing things the way the framework does them, instead of the way that's most appropriate to your app. The Rails approach is a very refreshing change, for me anyway, and I hope the project will continue to maintain this focus.
  • by wackysootroom ( 243310 ) on Wednesday December 21, 2005 @02:15PM (#14310669) Homepage
    Judging by how this article was written you haven't used rails at all, or maybe used it for something extremely trivial. The "automatic code generation" (scaffolding) is only there to help you get started on a project. You can completely bypass it if you want.

    I'd be willing to bet that if you used rails for an hour or two, you wouldn't have written this article. In fact, the entire article depends on your assumption that the code *has* to be generated automatically.

    So what are you waiting for? Try it and see! [rubyonrails.com]
  • TurboGears (Score:3, Interesting)

    by ultrabot ( 200914 ) on Wednesday December 21, 2005 @02:23PM (#14310733)
    In the meantime, if you want rails-like development but with Python check out TurboGears [turbogears.org].

    It's been raising quite a storm lately, and for a good reason!

  • I'm interested to hear what the Slashdot community thinks is the best templating system for Ruby on Rails.

    I'm a PHP / Smarty developer and have really liked it.

    I know there are some great templating systems out there, like Canny (very closely based on Smarty but not made for Rails).

    Ideally I'm looking for something that works seamlessly with Rails and is close to Smarty in concept and functionality. Canny for Rails would be perfect. (Or has someone found a way to use Canny with Rails?)
  • The author's concern could be expressed about the maintainability of generated code, whether in Ruby or Otherwise.

    To talk about this intelligently, lets split it into 2 kinds of generation: the 'one-off' code generation that occurs once, in order to get something up and running, which is then maintained on its own, and the 'generate every time you build' mentality of things like XDoclet (to mention one of many). Both have their pros and cons.

    With one-off code generation, (which is what Rails is), you gene
  • Wow - what a bogus premise: off course Rails based web applications are maintanable. I consider maintenance and modification costs to scale fairly linearly with code size and Rails applications are concise.

    After heavy experimenting with Common Lisp, Python, and Smalltalk based frameworks I have decided to base my consulting business on just Ruby on Rails and a subset of the Java J2EE stack. I am a little prejudiced on language choice since I have written 5 Java books and I am working right now on a Ruby boo
  • Before posting a question like this, how about researching RoR just a little.

    RoR generates complete, readable code for you when you ask it to (the scaffold), but once you've done that, you're typically going to go modify that yourself. It's relatively simple, logical code. And it's a one time deal. You will typically intentionally go modify that scaffold code, unless you're doing something really simple.

    Besides, if you wanted to know how maintainable RoR code was, you could have followed any of the many
  • by NardofDoom ( 821951 ) on Wednesday December 21, 2005 @02:51PM (#14310953)
    You've obviously never worked with ASP.NET.
  • by Whatchamacallit ( 21721 ) on Wednesday December 21, 2005 @02:56PM (#14310983) Homepage
    RoR (Ruby on Rails) is simply a very nice API for doing web apps with Ruby. It will auto-generate some code via what Rails calls Scaffolding. This is meant to get something working extremely quickly and it allows you to enter some data into a table with minimal fuss. The code it generates is quick and dirty and you are supposed to re-write each method as you move forward. That said, it's not a real code generator in the traditional sense. The Wow factor of the videos on rubyonrails.com show off the Scaffolding but that is only a very small part of Rails development.

    Ruby itself is very maintainable because the syntax is so very clean. However, it's up to you to document your code with meaningful comments, check it into CVS or Subversion, and implement your own Unit Tests, and include RDOC tags in your comments, etc. All code regardless of language is maintainable if you eliminate the code monkey bad habits. i.e. if you've been coding in PHP and all your code became unmaintable then it's your own fault and not that of PHP. Ruby in my opinion is better organized then PHP and encourages good code standards but ultimately, it's up to the programmer. If you are a neat freak and are very detail oriented and you tend to go back and cleanup, test your code before you check it into your version control system then your code will always be maintainable.

    I like the way the RoR ActiveRecord mapping system; maps my classes to database tables and objects to my records. You can programatically create records in the table by creating additional objects. The scaffolding will read an existing database table and generate working classes so you can utilize CRUD functionality. You don't have to use scaffolding but it comes in handy for me even when I throw it out one method at a time and re-write it.
  • Granted that RoR is a nice alternative from Java or scripting--can RoR generated code be a nightmare to maintain?

    Yes, if poorly written and

    Yes, when applications get very, very complex--which is a given. And they will get very complex, just wait 2 yrs.

    Consider the great development tools of RoR such that you end up with a Microsoft environment/paradigm--great for RAD, not so great for critical systems that need to be up 24/7, 100%.

    I'd still go with XML Schema-based code generation, much more stable

  • by Erisynne ( 10654 ) on Wednesday December 21, 2005 @03:15PM (#14311136) Homepage
    As others have noted, what Rails generates for you are stubs. Even if the stubs are full-featured enough to let you add, edit, view, and delete objects, they're still stubs. It's just that RoR is succinct enough that generating 150 lines of code (including action views and layouts) is all that's necessary to provide all of that functionality in a very basic way.

    But, two links for your consumption.

    My article on the topic of what I call Scaffold Withdrawal
    http://www.slash7.com/articles/2005/12/07/the-fall -from-scaffolding [slash7.com]

    Structure generation vs code generation (from the Rails' creator's blog)
    http://www.loudthinking.com/arc/2005_10.html [loudthinking.com]

    It's true that "Ask Slashdot" is vehicle for enlightenment, but I didn't think it was a vehicle for the basest laziness. I don't understand why someone would go Ask Slashdot instead of looking at a couple F/OSS Rails app packages and deciding for himself whether or not they look "maintainable."

    If the submitter did, he'd find that it's clear that maintaining Rails apps is no problem. You don't have to know much about a given app to even do serious "maintenance" on it. As long as the programmer hasn't tried really hard to break all the benefits Rails brings to the table (regular file structure, MVC separation, clean models, helper classes, etc), then you'll already know a lot about how the app is structured before you even unzip it.
  • by TheNarrator ( 200498 ) on Wednesday December 21, 2005 @03:33PM (#14311280)
    Ruby is not statically typed, which means that if you have a very large program and you change an API in that program you have to go and find all the instances of calls to that API in your program yourself, either through running automated tests or seeing the broken calls in the debug log of your application. Compiled langauges on the other hand such as Java,C,C++,C# have static calling conventions which means that when you break an api the compiler will point out all the broken calls to you and not let you run your program till you fix them all. This tends to make statically typed languages more maintainable. If you need to break out of static calling conventions you can in Java at least using introspection and bytecode enhancement but this is usually only done in well defined scenarios inside of application frameworks instead of for every class like in Ruby.
  • by guinsu ( 198732 )
    One thing that disappointed me when I had a look at Ruby was its SQL interface (at least on Windows for SQL server). I find myself writing the same repretitive code in ASP to connect to a server and execute stored procedures. Same thing in Java with JDBC. I did a quick survery of other scripting languages to see if any had features to let me cut down on this copy and paste coding. Ideally I'd love to just call a stored procedure like a method and let the computer sort it out (you know, let the machine d
  • Vlissides' generation gap [ibm.com] pattern can help solve a lot of the maintainability issues with code auto-generated from a DB's structure. The idea is that you use some tool to auto-generate stubs from your model, and then you extend (in the formal OO sense) those stubs. When your model changes, you can regenerate your stubs without trying to do some ugly merge between your customized templates and those that reflect the new structure.

  • I've believed for the last few years that automatic code generators (*) are a bad idea.

    I haven't spent too much time looking at RoR, except for reading some introductory docs. But when I ran across the code generation bit, that set off alarm bells.

    I've used automatic code generation systems a few times. It was always inconvenient. There were always instances where you wanted to do something the code generator couldn't do by itself, so you had to drop into the programming language itself. One syst

  • by meowsqueak ( 599208 ) on Wednesday December 21, 2005 @04:01PM (#14311531)
    I have no experience with Ruby or RoR but I am a software engineer like many people here and I would like to stick up for automatic code generation. Modern software is extremely complex and even when excellently designed and implemented by a skilled person or team it is still subject to faults. Automatic code generation, when done properly, is an excellent way to reduce the effort and risk associated with creating certain types of complex systems. A classic example is a parser - hand writing parsers can be done, of course, but they can be notoriously difficult to test and small grammar changes can upset the entire structure of the parser. In this situation, automatic code generation is not only useful, it's also safer and more reliable. If you have to change the grammar, you just reconstruct the parser code.

    A compiler is a form of automatic code generation - you don't compile your source by hand, usually, you let the compiler do it. The compiler becomes a cornerstone of your industry and is trusted perhaps far beyond what it really deserves. But the important thing is that it is hopefully consistent and can compile to a lower form much more accurately and faster than you or I or anyone can. You can make large scale higher-level changes without worrying too much about the effects of these at the lower level.

    Unfortunately all generalisations fail when you talk about specifics and the implications of this don't need stating, but I think it's unwise to say 'automatic code generation sets off alarm bells' when it is more accurate to think 'writing it manually should set off alarm bells' for many implementations.
  • Generated Code? (Score:3, Interesting)

    by misleb ( 129952 ) on Wednesday December 21, 2005 @04:40PM (#14311878)
    I started my first real Rails project with generated scaffolding, but after a few days there was almost nothing left of it. And I almost wish I had never generated the scaffolding because I had to spend time cleaning up tons of files and method stubs that I was never going to use.

    I do, however, use the basic "scripts/generate " scripts. They save me a minute or two of creating files and directories and class definitons. Handy, I suppose, but I am not sure if this is considered "generated code." The only "code" that Rails really generates for me is HTML and SQL (Tag Helpers and ActiveRecord) which is pretty nice, actually. The less HTML and SQL i have to write and more I can focus on the actual code, the better.

    Re: code generation replacing OO model:

    I have no idea what the OP is talking about. RoR is pure OO.

    Probably the only thing that I find a little frustrating about RoR is the shear volumn of files involved in a project. Navigating through them gets gradually more time consuming.

    -matthew
  • by Chief Typist ( 110285 ) on Wednesday December 21, 2005 @06:25PM (#14312715) Homepage
    I've been using Rails and Ruby for the past few months -- I had no prior experience with either.

    The thing that has become clear to me is that the hard part of Rails is learning *how to do it right*

    The "automatic code generation" (scaffolding) is helpful for learning *how to do it right* but as you get deeper into the framework, you find yourself coming up against difficult and/or domain specific problems. In all cases I've encountered so far, there are simple solutions to these problems -- the hard part was finding the right way to solve the problem.

    You have to take the time to read the documentation, dig through the source code, think about design patterns, and write elegant Ruby code.

    Often, this code is only a few lines long. For example, I had an issue with SQL statements including NULL values when I wanted to pick up a default from the table schema. The solution was a single line of code to remove the named attribute from an array in a Model subclass. It took a few hours of research & prototyping to figure out that one line of code.

    So as far as maintainability is concerned, I'd say it's pretty good. That one line of code mentioned above is easy to understand for someone doing maintenance. Less is more.

    One final observation that I've made regarding Rails and Ruby -- it's a lot like Cocoa and Objective-C (another excellent framework backed by a dynamic language.) When you find yourself writing a lot of code, it's a good sign that you are doing things wrong.

    -ch
  • by oldCoder ( 172195 ) on Wednesday December 21, 2005 @06:52PM (#14312923)
    But the programmers API isn't nicely documented in RoR, although there is a web page that claims to do that. For example, to search the RoR API web page you have to use google. Half the time I come up with a blank document. That is, the entry for the function I want is a blank page, and there is no context (no "up" button) so I can't use it as a starting place for more navigation.

    The result of the somewhat sloppy documentation is that if I find a function that does something (like by looking at the source) I don't know if it is guaranteed to be there next release. The existing book ("Agile web programming...") is too chatty and not complete and accurate like a reference manual would be.

    So I'm somewhat blindly following the examples and when something doesn't work I have to backtrack. Still, all in all, I like it. I need the speed.

    And, like a lot of people, I found I had to go back and study Ruby a few times. The existing Ruby docs are great.

    But I desperately want a good Rails reference manual.

  • by l00k ( 910333 ) on Wednesday December 21, 2005 @07:29PM (#14313168)
    The idea that developing in Rails is 'code generation' is a common misconception amongst /.ers - in fact the last time a Rails article was posted sometime last week I had to do battle with a number of people that thought this.

    I hope that the number of highly-modded responses which have had the chance to clarify what code generation is in Rails, and what its purposes are within the development cycle, will allay some of the FUD. When I began learning Rails I was under no impression that code would be generated beyond the scaffold, and that the scaffold was only there to get some meaningful database interaction happening right away. This tutorial [onlamp.com] which I began learning Rails from explained it clearly:

    Of course, these actions and views are very plain--not the sort of thing you'd want users to see (unless they are total geeks). The good news is that we can leave the scaffolding in place and slowly, one at a time, provide our own versions of the actions and views. Each time you create one of the actions or views it will override the scaffold's version. When you're done, simply remove the scaffold statement from the controller.

    The way I imagine the misinformation formed is from certain people hearing the sentiment of "faster development in Rails" and jumping to the conclusion that there must be some sort of cheat involved. Watching the video demos probably fueled this, as the demos are showing Rails off, and the scaffolding is a selling point.

The Tao is like a glob pattern: used but never used up. It is like the extern void: filled with infinite possibilities.

Working...