The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Rails Flexibility

Hello my beloved Rails friends. I have never posted here before, so let me say that I am positively beaming in doing so.

I pretty much stick in Java right now. I like it. Intuitively Java makes a lot of sense to me; the structure of the language itself just makes me all warm and familiar inside.

With that said, there are some things I wish I could avoid- namely, the verbosity. I feel like I'm spending more time than I should be spending. I'm not knocking Java per se (there are many frameworks and other development tools that I'm not taking advantage of), but I do think I could get more out of Rails (or PHP or other language) faster than I could if I spent the time figuring out an in-depth framework in Java.

I've seen the screencasts, I've walked through a couple of articles and tutorials, etc. I at least have a broad feeling for Rails. I have a project or three upcoming by the end of the summer and I'm thinking about trying Ruby for it. The thing I'm wary about is flexibility. Yes, it looks brain-dead easy to do a lot of things in Rails, but do you ever feel like you're "slotted-in" any sort of scenario due to these tools and routines available to you? They save time, I'm sure, but is that at the cost of the ability to do what you want to do when you want to do it? Obviously there are ways to customize different aspects of a project, but sometimes it's the small stuff. Do you feel frustrated ever in that you have to go out of your way to do something that might be more straightforward elsewise?

Thanks. I'm obviously interested in checking all of this out, and a hearty discussion on this would be a great help. I love you all.

Rails is very flexible, but that not because of Rails, but because of Ruby. You can always change everything. If you want to add a method to ActiveRecord, for example, you can. If you want to add a new template language, you can.

Could you give an example of something that needs flexibility, then we can find out if it's possible/easy in Ruby on Rails.

I didn't really have any specific examples in mind; I just was wondering if you felt as a developer kind of cornered into specific ways. Rails obviously has all of these routines that quickly gets stuff done (like the blog creation screencast they have), which is well and great, but if you want to use that as a starting point to something a lot different (maybe make a multi-author CMS or something from that one starter blog), how hard is it to stray from the nice clean path Rails set for you?

To put it simply: is it a pain to go your own route since you're off the pretty Rails pre-built stuff, or do you actually feel more free? (The ActiveRecord example you mentioned is actually quite cool... something I didn't know yet.)

And heck, two birds with one stone... might as well. Any Rails converts from Java that can comment on the switch specifically?

Rails is very opinionated software but I don't think I've ever felt constrained by it - there has often been situations where I felt a particular feature would be useful or something could be done better, but all that does is prompt me to flex my Rails plugin fingers.

I don't think a multi-author CMS would be difficult in Rails (very easy actually). Rails doesn't do everything for you though, you still have to do some things. Rails does set a "nice clean path", and I think you don't have to leave it. If you want to do something Rails doesn't native support for, you have to create a few metres of the path yourself. I don't think this is a problem at all.

To put it simply: is it a pain to go your own route since you're off the pretty Rails pre-built stuff, or do you actually feel more free?

With Rails, I feel much more productive. One commonly misunderstood example would have to be scaffolds. Some interpret it as a sort of "Shake and Bake" of application development, but it's actually fairly good for creating, destroying, reading, and updating database rows just for the sake of having test data. Since scaffolds can be dynamic (Add one line of code, "scaffold :model".) you don't have to worry about scaffold remains cluttering your application unless you use a static one. It's a nice alternative to firing up the command line and interacting with your database server of choice. Once you learn more about Rails you will find yourself using scaffolds less, there are even more effecient ways to go about things. Not to mention being able to go from concept to prototype in little to no time is nice.

Anyway, I suggest looking at Ruby the language first. Its a great language, that I still haven't learned thoroughly, but I do like it so far. It does have its annoyances but what language doesn’t.

For me, I wanted to learn in-depth Ruby, before even trying rails. The reason for this is that Rails is at a very high abstraction level and is almost a language in itself with all the methods you have to remember. You can write some web stuff with Ruby without any framework by using the CGI library. Which is nice for learning, because (for me anyway) I don't need a lot of console apps.

Things that always annoy me about frameworks is that you have to learn how to use them. Rails is so "opinionated" that you have to learn how to do it right, which means learning all Rails little shortcuts, which aren’t obvious at first. So, there is a learning curve with a framework as extensive as Rails. Also, you WILL run into problems with rails (the law of unintended consequences) and the error reporting in Ruby is poor to say the least. Ruby people will tell you that you should be testing, which brings me to my next point.

I am not an expert programmer...Ruby and Rails enable good programmers. It does not enable lesser programmers. I have yet to be test infected (I wish to be), so it is difficult for me to follow the best practice things Rails and Ruby people insist upon. You do get your fair share lesser programmers in Ruby too. Just go to the ruby irc channel and you will see how many people think rails methods are native to ruby.

I am currently learning Ruby. After that I will try to write an app with Rails, but I am still learning how to be a "good programmer" so I won’t put the cart before the horse, like many others. My opinion is to learn Ruby, and forget Rails and all the Rails hype. A lot of Ruby people use Nitro and other frameworks, and these people are "good programmers". When you have learned Ruby try Rails and evaluate it as a Ruby person.

In closing, Ruby is slow. It’s getting a new interpreter in Ruby 2.0 and this should definitely propel Ruby to new heights. Until then it does tax a server more then I like. Rails people will say, you can just throw more hardware at it, but this only works with a strong economic model, which has a fee system which scales with your hardware costs. Making money on the web is usually secondary to the sites purpose, where expenses are kept low because revenues are low. Meaning, faster languages will be used because 80% of sites on the internet don't have a proper economic model to handle Ruby and Rails. I truly hope these changes in the future, because Ruby is a very appealing language.

I hope that helps lo0ol.

"A nerd who gets contacts
and a trendy hair cut is still a nerd" - Stephen Colbert on Apple Users

The New Guy: You don't need to know Ruby in depth to work with Rails, you need to know the parts of Ruby that apply to Rails. There is a book devoted to the subject, Ruby for Rails. However, that doesn't mean that one shouldn't explore Ruby further, it is an amazing language. Ruby may not be as fast as the likes of PHP, but that really isn't an issue. One example would be MOG, according to this thread (Which also discusses Ruby and it's scalability.) it's serving up 1.5 million hits per day. However, that is using Mongrel, Apache and FastCGI can be less then amusing at times. Ah well, just my opinion of course.

The New Guy: You don't need to know Ruby in depth to work with Rails, you need to know the parts of Ruby that apply to Rails. There is a book devoted to the subject, Ruby for Rails. However, that doesn't mean that one shouldn't explore Ruby further, it is an amazing language. Ruby may not be as fast as the likes of PHP, but that really isn't an issue. One example would be MOG, according to this thread (Which also discusses Ruby and it's scalability.) it's serving up 1.5 million hits per day. However, that is using Mongrel, Apache and FastCGI can be less then amusing at times. Ah well, just my opinion of course.

Yah. But like I said that is putting the cart before the horse and leads to all sorts of problems. I hate. HATE the idea of learning framework, without learning the language it was built on.

I have already read the stuff on MOG, but we don't really know whats going on the behind the scenes. And like you have said (and others) you almost have to be an apache god to get peak performance.

I am not saying ruby sucks, and your post feels like the typical ruby evangalist response.

"A nerd who gets contacts
and a trendy hair cut is still a nerd" - Stephen Colbert on Apple Users