views:

195

answers:

4

I am a Ruby noob. Has any one in this community written a Ruby app without any frameworks? (edit:My goal is to write one on my own.)Tell us about your experience. How difficult is it? Whats the lowest abstractions you used? What are the pitfalls? Thanks.

+6  A: 

This ia a very, very broad question. Are you looking to write your own framework, or just a simple CGI-like application (you can do that with ERB quite easily).

The biggest pitfall I can see to not using a framework (including one that you've written) is that it will be much, much harder for other people to figure out what your code is doing, and why. Plus, you lose all the automated testing, data binding, packaging, document generation, and other goodies that frameworks tie together.

Of course, if you do all the tying-together yourself, you've just written a framework. :)

If not, you've written a horrible mess of spaghetti code.

What I'd do, since you're a beginning Rubyist, is read the Rails (or Sinatra) source, and try and figure out what it does. Not because it's necessarily a great example, but because your understanding of web frameworks will be a lot more complete by diving into a couple. And this is very, very valuable.

Edit:

I looked at a few of your other posts, and it looks like you're a student, so I'm going to caution you against writing your own framework, not because it's a bad idea per se, but because of what a software framework represents -- namely, the sum total of years of experience in working with language X.

Programmers are like beavers -- we want to build. We want to to build everything ourselves, always with the idea of fixing the shortcomings of the existing tools. While this is a very noble thing, it tends to lead people down the path of getting very little done, because they aren't willing to use tools that other people have written, often for what boil down to minor, cosmetic reasons. Younger coders are especially guilty of this, and I was no different -- I wasted literally years screwing around with writing webservers and database abstraction layers, instead of writing software that I could have made money with.

If I could go back and do things differently, I would have started contributing to the frameworks that already existed, rather than just trying to "do it right" from scratch.

Now, there is an exception to that rule of "use other peoples' work first", and that is when you've got the experience with the tools to know when it's time to build something new. DHH (the guy who started Rails) was a very long-time Ruby coder before he decided to write Rails.

As a Ruby newbie, you're probably better-served at reading what other people have cooked up, and patching/improving that, rather than just starting on your own. You'll learn more about the language, make a valuable contribution to the community, and give yourself some good resume fodder.

Don Werve
edit:My goal is to write a framework on my own. Are there good books that focus on CGI apps and discuss framework building? Thanks.
kunjaan
+3  A: 

You ought to ask yourself why you want to do this. A simple framework like Sinatra really isn't going to get in your way. Is this just for learning purposes?

At the minimum, you should consider using the Rack middleware to make life easier for you - connect your app to Rack, and use Rack to host the site through Passenger, Thin, Mongrel, etc.

AdminMyServer
A: 

Here are some of articles i found while surfing(hope theyre useful to others interested in frameworks):

Roll out your own framework

This ones in python:(

kunjaan
A: 

THIS IS WHAT I WANTED:

http://rubyconf2008.confreaks.com/writing-my-own-web-framework.html

kunjaan