
Ask YC: Should I use a framework or just write the code myself? - jgrahamc
I'm about to start working on a new web application and have been looking into different frameworks (such as RoR, Django, symfony) to see if it makes sense for me to use one.   I have to say that every time I read about one I feel like I'd be constrained by the framework for not a lot of gain.<p>Do YCers here have experience with or without a framework?   What would you choose?

======
bokonist
I worked on a large Python project before Django came out and ended up
building my own framework. Recently, when I used Django, I realized that
almost every feature it had was something I had ended up writing myself.
Django had a lot more man hours going into the framework and was much cleaner
and better tested than my implementation.

There are certain things you need for every project: -ways to handle
configuration files for different environments -a pattern to map URL's to
methods and templates -a basic ORM so you don't have to write SQL for every
single CRUD operation -a test framework that simulates an actual web request
-a way to handle SQL migrations -a way to get data to and from forms

Almost every production web site needs all of the above. Why spend time doing
it yourself when people have solved these problems already? The only reason I
can see for writing your own framework is as a pure learning experience.

------
nostrademons
I started with a very light framework (web.py) and then switched to Pylons.

I'd say it's mostly based on personal preference. If you don't use a
framework, you _will_ end up reinventing a lot of stuff that's in mainstream
frameworks. OTOH, the stuff you spend reinventing really won't take you much
longer than learning the framework, as long as you build off a decent set of
libraries ( _don't_ try to reinvent your own templating-library/HTML-
escaping/database-interface etc.) And if you do switch to a framework, you'll
probably be better able to understand the reasoning behind why the framework
did what it did.

One other consideration: frameworks make it much easier for somebody new to
get up-to-speed with your code, and often tackle thorny deployment issues that
you can spend a lot of time on otherwise. Keep that in mind when deciding -
for a startup, the priority is to get something up on screen so you can see if
you're on the right track, but you do eventually want to be able to grow and
scale.

~~~
jgrahamc
web.py is on my list to consider. It's lightness and simplicity is really
attractive.

One thing that bothers me in a lot of frameworks is the object wrapping of the
database. I can't see much justification for this, it just seems to be adding
a layer of complexity on top of a very clearly designed model. How much easier
is it to use an object abstraction when you could just do SQL directly?

John.

~~~
mrtron
I would take a serious look at Django. You can use it as scaffolding and get
rid of pieces as you write you own, the first to go will be the use of the
automated admin site, and I find myself writing a custom pieces across the
board.

However, being able to rapidly deploy a prototype has been priceless time and
time again, and they have the basics that you need down and well tested.

If you don't like ORM, or find yourself writing a lot of custom queries for
performance, that is fine. I would still use an ORM now and customize some
queries for performance later. The reason? Speed of building your app...I
think not writing the DB code saves me about 20% of my time.

I used to be always against using frameworks since they were massive, crappy,
and relied on so much magic you didn't know what was going on behind the
scenes. I am really glad I went with Django, it saved me from writing almost
the identical feature set.

~~~
jgrahamc
It's interesting that you mention Django. Of all the frameworks it's the one I
most liked as I was investigating for one major reason: the community around
Django seemed welcoming and open to ideas. This was very much in contrast to
the RoR community which seemed to have a "we know better than you" attitude.

John.

~~~
mrtron
The community is quite good overall.

It is especially good about allowing random people to contribute pieces of
code that are useful. I also like how their goal is to make everything as
straightforward as possible, and eliminate the 'magic' that most frameworks
have. If you have any questions about it, feel free to ask.

------
fauigerzigerk
I've used frameworks and written my own. Obviously what works better depends a
lot on how similar your problem is to what the makers of the framework
intended to solve. The dilemma is that as you build your app your problems
become more specific to that particular app and you tend to gain less and less
from the framework. Eventually the framework gets in your way. Not because it
forces you to do it in a particular fashion, but because you feel compelled
not to stray from the framework's path in the interest of consistency and
simplicity. Unfortunately, the same may be true of your own framework
creations, just the consequences are different.

Frameworks are great if you do a series of similar, straightforward projects
like many contractors would do. A framework allows people to get acquainted
with your code more quickly, so it's good for companies with high staff
turnover. It also has a name that HR can put in a job ad.

If you roll your own, try to do it as a collection of independent libraries,
not as a don't-call-us-we-call-you type of framework. That's my conclusion
after many attempts at framework writing. It has always been the case that
some parts were good and others were crap. You can't throw the crap out if
everything is interconnected. The code that connects everything needs to be
either the smallest part of the framework or part of the application itself.

But anyway, as long as you stay away from CMS, you're going to be fine.

------
teamhot
Sorry for the double post, but I would also like to add that SQLAlchemy and
Mako templates were more of a deciding factor than anything else for me to use
pylons. Pick the things that you will absolutely not be reinventing
(templates, orm, etc) and find where they play best together. Do you like your
templates simple and with very little logic? do you like them in xml? do you
like 'magic' orms? Also another thing is note how this app will be deployed.
If it is purely for fun and learning, this isn't an issue. Otherwise, read up
on how easily different frameworks play with apache mod_python, fcgi, scgi,
etc. because limitations in that area aren't easily mended. I did have to wage
a bloody war to get pylons running fcgi on my shared hosting server. Now the
war is won the solution really isn't that hard/complicated or obscure. It was
just lack of good documentation that needlessly killed hours and brain-cells.
I'd recommend looking for as much documentation in these areas. If you can't
find it fairly quickly, chances are you will be paying for it in the future.

------
teamhot
I started with this whole web framework thing writing my own crappy code in
perl. I found python, loved it, and immediately started learning django (the
0.96 version.) I quickly became dissatisfied with the limitations of the
framework as my apps grew in complexity. This was somewhat in part due to new
additions like newforms that were not yet completed or fully integrated.
Currently I'm using the pylons framework and I am absolutely loving it. It
sounds like if you are even 'considering' writing all the code yourself, you
should really pick a framework akin to pylons or web.py in your language of
choice. Ruby, Perl, Python, it's really all the same...

------
shayan
I had the very same question before, and even implemented many of the common
things that my application needed. But I am now looking at Drupal.

In general whichever framework you would like to use, will have its own
learning curve. Once you overcome that, it should be pretty easy and fast to
start working. I think there are some obvious advantages in using a framework:

1- you don't have to reinvent a lot of the stuff

2- the solutions offered to you have passed all their tests as there are many
people checking upon them, and many sites already using them

3- if you have a couple of ideas and are thinking of launching all, I think
once you finish your first project you will see a huge advantage starting the
other ones, and you will move a lot faster

at the end if you pick the right framework, that will satisfy your current
needs (the features and options you like to offer) and future needs (such as
scalability), you will feel like you are working with a huge group of
developers on your site. Its kind of like you have hired other developers and
formed a team for yourself.

Also make sure that the framework you pick will have a strong community as it
will come handy.

You should make a list of your requirements and make a chart of the frameworks
and which ones satisfy what. And in general I would take the following into
consideration when choosing a framework (depending on your needs you could add
to this list)

\- Ease to install \- Learning Curve \- User Control \- Session Control \-
Extensibility \- Scalability \- Themability \- xHTML/CSS

------
walesmd
CodeIgniter It's lightweight, scales exceptionally well, designed in a
language 95% of the web development community knows like the back of their
hand, and powerful.

You'll keep yourself from reinventing the wheel, yet you won't limit yourself
on capability by conforming to an obscure set of rules and development
practices.

~~~
jamongkad
Ditto on CodeIgniter.

------
Tichy
I feel like you - so far I have usually used frameworks, but there are always
aspects that make me unhappy (not even RoR satisfied me). Now I wonder if the
recent article about IDEs also applies to frameworks: if you insist on using a
framework, you probably won't be able to use the latest, coolest programming
languages, because there are no frameworks for them yet.

I am not sure how much work it is to create one's own framework, but I suspect
it is less than one might think. The hardest part to me seems serious OR
mapping+caching.

Personally, I would probably go the same route as Groovy on Grails and build
on top of Spring+Hibernate (so leverage existing frameworks, but in my own
style).

Also, I don't know any programmers who became famous for using other people's
frameworks.

------
edw519
I'm a caveman, trying to squeeze every bit of functionality and performance
out of my app. I roll out everything myself. May take a little longer, but the
OCD in me is happy.

<http://news.ycombinator.com/item?id=77136>

------
mechanical_fish
Flip a coin.

It doesn't have to be a balanced coin: I like Ruby, so my coin was biased
toward Rails. Ergo, I learned Rails, and will probably go on to play with Merb
and Camping.

Meanwhile, very smart people assure me that Python is nice, and I hope to
learn it before I die.

The important thing is to just get moving. Deciding between Rails and, say,
Drupal is complicated, with lots of technical, marketing, and business factors
in play. But RoR, Django, and the gang are so much alike that the decision
comes down to that simple coin flip.

------
kingnothing
If you can find one that gels with what you're trying to do, then by all
means, save yourself the time and go with it.

------
sohail
I think light frameworks are the best because they do not cause frameworkitis.

[http://uint32t.blogspot.com/2007/11/web-programming-
framewor...](http://uint32t.blogspot.com/2007/11/web-programming-
frameworks.html)

------
davidw
I use RoR and am very happy with it. Instead of "reading and feeling", try
coding your app and see how things go. Even if you switch, by coding, you'll
have made a lot of progress.

~~~
shayan
some points about RoR, (I checked it a few months back so they might have
changed!)

\- It _does not_ offer an out of box solution to allow authenticated users to
create content forming pages as part of a Web site. It offers you a web app
framework and you could build upon it your custom CMS from scratch (and it
will take you longer to do so)

\- but there is a nice binding to the database through the framework

\- at the time stability was a bit of an issue!

with all that said there are great applications built upon it such as
37Signals Base Camp

~~~
fauigerzigerk
Do you know of any great applications built on top of CMS? I don't.

~~~
shayan
I am not sure what kind of applications you are looking for, but in general
there are thousands of successful and big sites out there... for instance look
at the sugar network, its based on Drupal

also if you mean built on CMS out of the box, I don't either, and you will
have to customize it in order to make something useful, but the point is that
with RoR you have to pretty much build from scratch whereas with other CMS
like Drupal you already have many functionalities included in the core and you
don't have to really reinvent many things, you just customize or add the ones
you want

------
trekker7
True hackers code their Web apps in x86 assembly.

