Ask HN: Site from scratch or frameworks?

16 points by thatusertwo ↗ HN
I've developed my first serious web app / start up, its a social network and took about 300 hours to develop to where it is now. I built it from scratch using PHP, mostly because thats what im best at, but also because i like the idea of knowing all the parts and having total control.

To me it seems like using a framework would take away from that control.

What does hacker news think about this issue?

30 comments

[ 4.2 ms ] story [ 58.2 ms ] thread
its seems to be more of a 'my framework' VS 'someone else's framework'
Depends... what's more important to you, having control of every little detail of how underlying plumbing works, or increased productivity and the opportunity to spend your (finite) time on things that add value?

I mean, think about it... you already don't really have "complete control." You (presumably) didn't code your own OS from scratch in machine language... so why not? Did you code your own web-server from scratch? Your own PHP runtime? IP stack? No?

Seriously, nobody does that stuff from scratch because it takes too much time and they'd rather focus on the value they're actually trying to create, as opposed to re-creating the wheel. That said, having the ability to go down to the lowest levels of the stack does have value... when you actually need to change something to achieve your goals. Take the guys who originally built Beowulf clusters... they actually did go in and hack on network drivers and IP stacks and what-not, because they had a unique need (low latency) that required it.

Anyway, I'd say apply this by analogy to what you're doing. Focus on adding value and avoid re-inventing the wheel, unless it's just a hobby project for learning / experimentation... but reserve the right to go as low level as you need, if and when you have an actual need.

the site is my baby, I want to make a job out of it.(building it from scratch made my skills increase 10 fold).

I suppose though, now that its been made, I do have a 'framework' to work with.

Do you want to make a job out of your site, or building a framework for your site? These are two different things, and spending time one one tends to prevent you from spending time on the other.
by job i mean money maker...

That is true, probably build out the site and extend/fix the framework as necessary.

Isn't it the same thing though?

If you use somebody else's framework, they can extend and fix the framework so you don't have to.

And if that framework is open source, and somebody else isn't extending or fixing it for you, you can do it yourself. You can still hack on it, but you don't have to build it from the ground up.

I respect building something from scratch so you can learn from it (I once wrote my own OS), but that tends to be helpful only once. After you've learned from the experience, you tend to be better at judging what to tackle yourself, and what you can leave to other people.

i do use jquery for some of it, also got some methods from the internet to make some tasks easier. So its not totally from scratch.
This answer is 100% correct. Think about it in cash terms. The amount of time you spend writing the framework is time (money) coming out of YOUR pocket. There is ZERO point in writing your own framework or starting from scratch these days .. stand on the shoulders of giants and reach higher!
I spent 4 months developing my idea into a working wesite from scratch. As soon as I got a positive response from my users and started to show some traction I learned codeigniter and re wrote the entire site using a framework. The site is now more stable, secure, and I can add new features in hours rather than days.

Learn a framework, you'll be happy you did.

If you had learned the right framework, you would be able to develop your next project much quicker, and you'd be a more attractive candidate to companies who use that framework. I guessing the attitude of hn is use the right tool for the job depending on your requirements.

  > you'd be a more attractive candidate to companies
  > who use that framework
1) That limits you only to companies that use that framework 2) He/she's mentioned wanting to turn the site into a money-maker, which means not job searching.
yeah working for someone else is depressing to me.
(comment deleted)
I'd definetly go for the framework approach. After building apps with and without frameworks, its a lot less painful to build upon something which exists already.

There are so many advantages to go framework, I can't tell everyone: - frameworks are (mostly) under development, so you can benefit from trends and improvements in web development

- frameworks are well tested

- frameworks are more secure. Do you have all holes for XSS etc. closed? Are you sure?

- frameworks have almost always a community behind it, so you benefit from other users knowledge and plugins

- frameworks have plugins. You don't have to write anything from scratch, like DB connections, authorization or file uploads

- frameworks have documentation. Unless you are the sole developer of your app, you really want to have good docs.

Do frameworks have disadvantages? Sure, but I don't think it outweighs the advantages.

Agreed, a framework is just a toolkit of best practices and useful tools.

Another benefit of using a framework is it lets you 'work' with other amazing coders. I have increased my php knowledge many times over by using symfony. Sometimes this happens because you just have to dive into the frameworks sourcecode to see what's going on.

It's like having your own personal secretary do all the work and research for you to get the ground work up.. heh I like that analogy
indeed! gotta save this quote somewhere :)
Also, if you need help at some stage, it's much easier to find someone with some knowledge on a framework (say, Symphony, since he built in PHP) than having to train that person into your framework and then the thoughts behind your application/idea.
I've just spent a couple of years on a project that I've built 'from scratch' in PHP attempting to follow an MVC pattern and trying to do things the 'right way' as I understood them at the time.

It's got to the point now where mistakes are coming back to haunt me, and some things that should be easy are not due to decisions made previously. This is compounded by the fact that growth of the code has been somewhat organic, and I didn't have a chance to anticipate some of the things we've done in the last year.

The upshot of all this is it's now time to re-write everything, taking the project as it now stands as the 'spec' for the rebuilt version.

I've learnt a lot during the project, and I'm a very different coder to the one I was at the beginning. One of the main things I've learnt is that I don't have enough time to be working on the "would be nice"'s in building your own framework, getting results ends up taking priority over taking time to 'do it right'.

So for this rebuild I'll be using an existing framework for several reasons.....

The people building the framework have time to concentrate on how the underlying code is built, and don't have to worry about a specific implementation

As I don't have to worry about designing my application, I have a spec, I can spare the time to learn the framework properly as I re-implement

Once I'm up to speed with the framework I should, in theory, be able to design and build anything in future much more rapidly.

I won't have to write any more bloody boilerplate that I've been re-doing due to my lack of knowledge/foresight in growing my current codebase

It's fun to learn, and peeking inside the framework (possibly because I'll need to bend it to my needs) should teach me new tricks.

I don't think a decent framework should take away control of your code. I've had the luck to be able to take 4 weeks evaluating some of the options both in PHP and other languages and anything that leaves the underlying code in a 'black box of magic' has been discarded. There are plenty of options out there with excellent docs and api's and lots of room to bend things to your will.

My personal choice is to go onwards with Yii, but framework choice is fairly subjective and a whole other conversation.

This discussion has a lot of good points:

http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_swit...

Basically, you're not alone in liking that degree of control, but the guy admits that simply using a framework like Rails can help you develop better coding skills in any language, especially if you're unfamiliar with MVC architectures.

(comment deleted)
I do not want to weigh in on the issue as a whole, but rather shed some light on an aspect you as a single coder have probably not given much thought to: accessibility and maintainability.

When I started using ruby on rails, adhering to all the conventions DHH came up with, especially the directory structure, felt like giving up a lot of control. And I, too, liked control.

But I had an epiphany when I first had to work with other people's rails code: Never before did it take me so little time to dive into and familiarize myself with someone else's code. I was productive at day one, while my customer did not really expect any results for the first 4-5 days.

So, if you ever plan on having someone else work with you on your code, or you need someone to take over maintenance of it, having a foundation that other people are already familiar with and where there is tons of documentation available, is a huge advantage.

But even if you stay alone on this project. With all you have learned, it is possible that you will approach your next project in a completely different way. In that case coming back to your old codebase in 6 months or a year will be painful. Having a consistent framework for all of your projects helps mitigate this kind of pain a lot.

As a long-time PHP developer, I've worked on both frameworks and from-scratch applications, and from my experience, having even a minimalist's framework goes a long way toward organizing your codebase; it takes a lot of discipline and foresight to keep a from-scratch project organized.

If you enjoy maintaining control and knowledge of your entire stack, then I would highly recommend using the CodeIgniter framework. It's designed to take care of most of the tedious bits, while staying completely out of your way when it gets to the actual meat of your project. It's very easy to modify or extend if you need to, with IMO excellent documentation of its API. Yet it still manages to offer enough structure that even I can keep my projects organized with little effort.

I know there are a couple forks of CodeIgniter, such as Kohana, but I don't think they manage to capture or maintain the same level of raw simplicity or lightweight feel of the base CI framework. YMMV ofc.

When you guys discuss frameworks, what exactly are you referencing? I've heard people use that word in reference to languages, CMS', etc...

Thanks for clearing this up for me!

well the problem with control is that if you need to stuff people you loose it as nobody would understand yours codebase and try to rewrite it anyway. Framework forces convention over configuration so it easy for newcommers just to grab docs and start coding. Also you can try to stuff some framework-experienced people.
Having been through a similar circumstance (built a huge application by myself, which later grew into my job) -- one of the major difficulties you'll have is in finding anybody else that can understand your code.

One of the hidden features for a framework, of any sort, is the general understanding of where things are, or can be expected to be. If I work within the conventions of Django, then when I'm hiring somebody, I can ask them if they know Django -- assuming all other things being equal, they'll have a much shorter learning curve ramping up to learn what I've built because they'll know, in general, where to look for certain kinds of things.

If you intend to ever hire anybody, then I'd take every spare minute you have where you aren't coding, and get to documenting the framework you've built.

Absolutely - for me one of the major benefits of a framework is documentation and user base. Developers new to the framework can easily get up to speed if it is well-documented. A good framework can also be easily extended to accommodate the custom aspects of your site/application.
There are some 'skeleton' frameworks available. These provide only the very essentials, like a database abstraction layer, user classes and some useful function wrappers.

For PHP, Tyler Hall's 'Simple PHP framework' is a good example.