Ask HN: Site from scratch or frameworks?
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 ] threadI 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.
I suppose though, now that its been made, I do have a 'framework' to work with.
That is true, probably build out the site and extend/fix the framework as necessary.
Isn't it the same thing though?
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.
Learn a framework, you'll be happy you did.
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.
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 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.
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.
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.
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.
Thanks for clearing this up for me!
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.
For PHP, Tyler Hall's 'Simple PHP framework' is a good example.