Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use a web framework (like rails) over php?

This isn't a question about what framework to use. I've learned both Rails and Django, and I write all of my webapps in PHP. My question is why bother with the frameworks? It's always taken me longer to use a framework than to reuse old MySQL code and build "models" with phpMyAdmin. I also like writing everything myself, because I know what's going on. I can still reuse functions, etc. and do things how I want, and this freedom seems to be missing from most frameworks.

I'm not saying that my way is right; in fact, I'm trying to figure out where my logic fails. The hype can't be just thin air. What am I missing?

like image 780
ankur Avatar asked May 16 '09 20:05

ankur


People also ask

Is Ruby on Rails better than PHP?

We have made a very general comparison of Ruby on Rails vs PHP where Rails has a significant advantage thanks to its architecture, many ready-made solutions, and a large community, which contributes to the speed and high-quality development of projects in this programming language.

Which is faster Ruby or PHP?

To tell you like it is: PHP is much faster due to the language architecture, history and most importantly its philosophy. PHP vs Ruby speed: The majority projects that are built with PHP are simple and doesn't consume a lot of memory.

Does Netflix use Rails?

Some of the popular companies that use Rails for web development include Shopify, Groupon, Zendesk, GitHub, Netflix, and Hulu.

Is laravel better than Rails?

Ruby on Rails vs Laravel Stack Overflow Survey 2022 In the recently released Stack Overflow Survey 2022, Laravel leads the competition to Ruby on Rails in terms of preferred backend framework with 9.45% respondents vote whereas Ruby on Rails falls behind with 5.83% respondents vote.


2 Answers

The basic idea of a framework is to allow you to work at a higher level of abstruction and write only the code you have to write to implement your specific requirements. All the other repetitive stuff is handled for you by the framework, and probably with far fewer bugs and security holes than if you did it yourself.

It may feel like it takes longer to learn a framework than to just do it yourself using basic language features and standard APIs, but it's simply not true - not if the framework is good and the app is non-trivial, and especially not once you have learned the framework (using a different one for each new project would of course be idiotic) and factor in the time it would take to find and eliminate all the bugs and correct all the design mistakes that have long since been found, eliminated and corrected in the framework by its developer community.

Almost every developer has cowboy coder instincts that tell him "Doing things yourself is much more fun than using code others have written, and I'm sure I'm good enough to get it right the first time, so it will even be faster and better!". These instincts are almost always wrong.

like image 73
Michael Borgwardt Avatar answered Nov 15 '22 21:11

Michael Borgwardt


Frameworks allow you to concentrate on the application itself rather than worrying about the boilerplate code that you'd otherwise have to write for every application. They allow you to structure you site in a much more logical (mostly object-oriented) way, using tried and tested design patters such as model-view-controller. The code in framework is generally more mature and of a higher standard than code you would write yourself for one-off projects as framework have a large community of developers perfecting the code perfecting the code over year. This means that framework-driven sites often perform better and are much more secure.

You also mentioned you like writing things yourself - I know where you're coming from. My solution to this was to write my own framework - I get to reuse and improve my code with every project I do and I know the entire codebase inside out.

like image 27
HarryM Avatar answered Nov 15 '22 20:11

HarryM