Ask HN: Is it bad to dislike using frameworks so much?
I've been programming web applications since I was 13 years old. I love doing it, but lately, something's been bothering me. Up to this point, the entirety of my server-side programming has been done in PHP. I learned web development with basic PHP and MySQL, and now work as an entrepreneur in my own company, using that combination.
However, lately, I've been bored with PHP. Each time I make a website, I feel like I'm reinventing the wheel when I write new code for things like user authentification or account systems. I keep looking at Ruby on Rails tutorials, and salivating at the beautiful syntax and elegant, DRY expressions. I love the idea of using Rails, as a modern MVC framework that lets me get things done quicker and doesn't require me to re-invent the wheel.
The problem is, every time I start using frameworks like Rails, and create my first "Hello World" application, I am dissatisfied. It works- I can list, create, edit, and delete objects that I've specified in the code. However, it just doesn't feel right, because I don't understand how the framework is doing it's thing. What is being compiled into what when I run the app on the server? When Rails "magic" happens, what is really going on? If there's an error, how on earth will I know how to fix it?
-I feel like since I didn't code the framework from scratch, I can't use it because I don't truly understand how it works.-
Is this a justified sentiment, or am I just too used to working with PHP? Does anybody else feel this way?
Thanks for any answers you can give me, I really appreciate it.
14 comments
[ 3.5 ms ] story [ 35.7 ms ] threadThis is the way I feel with frameworks. At first I always wanted to code everything myself but I couldn't achieve anything because it was too much work. Then I started making websites on top of a CMS (I used CMSMadeSimple but anything will do really). It could do everything I wanted and really quickly, and at some point if there was something that I couldn't do in the CMS or there was a bug, I could easily dig in the source code and fix it myself. Just like a car, you can pop the hood and play around with the stuff inside, but since it's already built and working you shouldn't have to play inside it too much.
The end result is in order for me to accept ORMs I had to know the pattern. To know the pattern, I had to write a simple ORM layer on my own. It wasn't pretty, it wasn't as good as SQLAlchemy, by far, but it gave me enough insight to appreciate them, and to know when to use them. By all means, keep using CGI, but leave it to the small projects.
And yes, you're too used to PHP. Branch out, it's more fun.
So I should write the micro-framework in Ruby? Any suggestions for starting out with that?
When I first began toying with frameworks, I felt much you, chromium. I understood the concept and the idea behind everything, but some of it felt like "magic." So, I sat down and wrote a basic clone of rails in PHP.
It lacked a lot of features but it had basic routing, models, views, controllers. I even wrote some code to generate migrations and applying/rolling back those migrations.
I never even finished that little faux framework because once I got into it and started mucking around, everything kind of clicked into place for me as far as demystifying the "magic" of everything.
Raw PHP -> CodeIgniter (PHP) -> CakePHP -> Ruby on Rails
The reason this worked for me is that the CodeIngniter MVC Framework is so lightweight, well documented and well written that you CAN understand what's going on behind the scenes just be reading the source code.
In fact CodeIgniter is still my most used combination for web apps, CakePHP is a weapon of choice for bigger projects or when I want complex ACL and/or the kind of automatically linked MVC structure that Cake provides.
I'm still relatively n00b at RoR, but I suspect that will replace Cake in my arsenal once I'm better with it.
Hope this helps you.
as far as you need to.
Which of course - is no answer at all. How far you need to go down the stack depends on what you're trying to achieve - the particular stack you're working on, the difficulty of acquiring the skills... and so on.
Perhaps your anxiety comes from the fact that when using a framework that you don't understand you don't know how to fix stuff when things go wrong - when your app needs to scale... etc. I guess you have to try to make an assessment of the risks you face in this respect. Perhaps do research on apps similar to yours and the technologies they used.
But in general - much of the comments I've read here on HN about scaling and whatnot seem to suggest that it's something that you can only learn to deal with by living through it since every application scales differently.
I don't know - I use Django and haven't faced these problems. I choose not to fret about what might happen because there is too much to worry about in the here and now.
The top answer give book recommendations and tools to understand rails.
If it's too complicated at the beginning you can start by trying to develop your own micro framework to get more confidence with this and then retry understanding how the magic works.
By all means, dig around in the frameworks, but treat that activity like the hobby that it is.