(Full disclaimer: I work at Automattic and am a speaker at PHP conferences.)
A couple days ago, Gina Trapani posted an interesting article on learning to program.
This reminds me that some people may take the wrong points away in my last article on the subject, the priority shouldn’t be what language you should learn, but rather, what is going to get you motivated to learn. PHP is a popular language because it naturally invites “immersion” style learning, not because it makes a good teaching language—which it doesn’t. That is, assuming the thing you are immersing in is “building a website”. As I like to say:
In the comments, I wrote:
After [the first] chapter, I’d say [PHP and MySQL Development]offers the most “immersion” gratification (at the least cost) than any other language’s textbook. The chapters are easy and by the end of it you have an eStore written and working from scratch. What do you get at the end of the Learning Python book? And how easy was each subsequent chapter? I’d say much less and much harder.
[Unfortunately,] it’s that first chapter that does the first timer in.
The caveat here is that while HTML and CSS are languages—they are not programming languages; they are markup languages. Learning them is no different than “learning WordPerfect” back in the 80’s. You are not a programmer if you have learned HTML or CSS.
Now here is where I take a big exception to Gina’s piece:
But more importantly, I have a problem with server-side web frameworks in general:
About Web Frameworks
One day, I was at a ZendCon and I happened to be eating dinner where three other PHP developers were talking amongst themselves—one developed Zend Framework, another develops Symfony, and the third develop CakePHP. All three are server side-web frameworks, and I had a well-known reputation for disliking all web frameworks. (Some of you misinterpreted this as a dislike for the Ruby on Rails framework, but I’m actually an equal-opportunity hater. 🙂 )
So I said:
“Hey what are you guys doing talking to each other? You should all be talking to me. Convincing me to use your framework would be a ‘Nixon Goes to China’ moment!”
We all had a good, content-free laugh.
The history of frameworks
But seriously, it’s not like the web world invented software frameworks. There are many of them out there. Here are some (off the top of my head): Boost, MFC, Cocoa, J2EE…
But if you look at it, most frameworks fall into two categories:
|programmatic architectural frameworks||user interface frameworks|
By and large, this categorization has had two historical outcomes:
|programmatic architectural frameworks||user interface frameworks|
With few exceptions, to the extent that frameworks have tended to providing user interface they have succeeded/supplanted their competitors, to the extent that frameworks have abstracted core algorithms, they have failed.
So what is my problem with web frameworks?
They very clearly fall into the former category.
To the extent that Rails was the first web framework to have paired so intimately with a Web 2.0 Ajax framework like script.aculo.us, it has succeeded among its peers. In fact, in the comments of my original article on Rails, I wrote:
Ruby hitched their cart to the Web 2.0 bandwagon and then claimed that they were the ones pulling it.
Today, I wouldn’t be surprised to find out that there are as more Zend Framework developers out there than Ruby on Rails ones.
While a viable business segment by itself (much like J2EE), because it doesn’t live up to its hype, this goes down as a FAILS.
The rock and hard place
A more interesting question is: why do programmatic architectural frameworks “fail”?
I believe because they are often stuck between a rock and a hard place.
The “rock” is the fact that there may already be an application written that meets your needs already: like WordPress, Drupal, Joomla, MediaWiki, phpBB, Magento, SugarCRM, etc.. As Chris Shiflett once quoted::
“Ruby [on Rails] is really good at what it does. The problem is, for what [Rails] does really well, I can download WordPress.”
The “hard place” is that a project that is long-lived ends up falling victim to the Pareto Principle: the 80% of the codebase the framework wrote for you would have only taken 20% of your time had you written it yourself. The code you visit all the time might have taken less time had you written it from scratch to consider your application in mind.
“Ruby on Rails is making it easy to develop the sites that have been already been developed, but it is not necessarily making it easier to develop the websites of the future. And maybe at that point, the Pareto Principle becomes the determinator and we meet the hard place.”
It’s not that there are no uses for a framework. It’s the space of problems between the rock and the hard place is rather narrow.
The missing framework
Which finally gets me back to the issue I have with Gina’s article. A suggestion to learn a web framework is a bad idea, because the usefulness of a framework is mitigated by the time it takes to learn a framework in the first place.
The only exception is that general purpose languages like Ruby and Python have a huge barrier for web programming at all. This barrier is partially mitigated by learning a framework like Rails or Django. There is nothing wrong with learning Rails if you are already a Ruby programmer (and have a web project) or learning Django if you are already a Python programmer (and have a web project), asking you to learn Rails in addition to programming Ruby, or Django in addition to programming Python is really like asking you to learn two languages to code one.
Learning a language in order to use a framework is as absurd as saying you should learn PHP just so you can use Smarty!
But most importantly, the example that Gina uses is a lie. I’ll bet the first serious (and impressive) web application that the editor, Adam, built with a web framework was not in Ruby on Rails, but in PHP on WordPress. WordPress? You know, the software framework which powers that website as well as his personal blog?!
Not “built?” Then why is one of LifeHacker’s most popular article on how to trick out your WordPress blog?
Not in a “programming framework?” Well, maybe not initially. But I find it hard to believe that LifeHacker doesn’t have more than a few custom plugins. Just the other day, I had an editor of TechCrunch mention to me about the problems of managing WordPress plugin and custom plugin compatibility there. Read the documentation on developing a WordPress plugin and tell me that this is not similar to developing inside a web framework.
Not “impressive?” I’ve actually heard of LifeHacker (and you probably have also). I have not heard of (and neither have you) of whatever that website was that Adam built.
Sure, it is good advice to not advocate a particular programming language. But to turn around and advocate that people learn a web framework tied to a language when such things have very limited uses and a more immersive strategy is staring you in the face?
You just fell victim to others telling you how to learn experience, instead of examining your own experiences learning!
Not all frameworks fail, the ones that don’t seem to focus on providing libraries that assist in user-interface. Programmers don’t like to do user-interface because it is a pareto-trap: a huge amount of code that takes a huge amount of your time to write or debug. This makes frameworks that provide graphical user-interfaces very attractive.
Let me complete the hypothesis:
|programmatic architectural frameworks||user interface frameworks|
|server-side frameworks||client-side dhtml frameworks|
|Rails, Django, J2EE, CakePHP||YUI, jQuery, script.aculo.us, DojoToolkit|
I’m not saying it’s worthless to learn Rails, Django, J2EE, or CakePHP. There are many gainfully employed Rails, Django, and J2EE developers out there…and maybe one or two CakePHP ones 😉
I’m saying if you are doing web work, you’ll get more out of learning YUI than Rails, more out of jQuery than Django, more out of script.aculo.us than J2EE, and more out of Dojo than Cake.
If you’re interested in more about learning and teaching programming, I highly suggest Eugene Wallingford’s blog… and not just because he quotes my article twice. 😉
18 thoughts on “Learning Programming Part 2: Programming Frameworks”
I just wanted to point out that Lifehacker (and all Gawker Media sites, such as Gizmodo, Kotaku, and io9) do not run on WordPress, nor have they ever. A few years back, we were running on MT, but that has long been scrapped for a custom-built PHP framework.
Sr Platform Engineer
@Ian Van Ness: Thanks for the correction, and sorry about that error. I should be more careful when I refer to blogs run by Gawker, Weblogs, Inc., and HuffingtonPost.
I guess the Pareto principle holds with large blogging networks, though I think these days that’s getting squeezed by WordPress MU: http://wordpress.org/showcase/flavor/wordpress-mu/
Rails has failed for many reasons, but I say that coming, Christ I had said as much on Sitepoint a few years ago.
My… how I laughed at those who jumped on the RoR bandwagon and how I still laugh today, knowing then and been proven now just how much of a failure RoR has been.
A complete waste of time, so for those who took it up, congratulate yourself for picking a donkey.
There are a few jobs in Rails development so I suppose it hasn’t been a complete waste for some. The LifeHacker article is advocating learning a framework (and Rails gets top billing) so that would imply learning Ruby and Rails is still heavily advocated as a first language (and bad advice).
I know someone who talked to a product manager about learning web software development and the PM suggested learning Ruby on Rails as a first language/framework. (Though I think this advice speaks volumes about the PM).
I also think a lot of good stuff recently has come from the Ruby community (and dare I say Rails?): GitHub for one, a lot of cloud computing management tools, etc. It’s probably an interesting article to discuss how and why that happened. 😉
While some of your thoughts are valid, they're just blasphemy unless you first straighten up some facts. The biggest one is the statement that RoR comes with script.aculo.us. Well, that's not true, at least not in the way you've meant it. RoR comes with http://prototypejs.org and http://script.aculo.us is an extension to prototype, just like jQuery UI is an extension to jQuery and dijit is an extension to dojo. You see, your lack of knowledge makes every other statement about Ruby and RoR pointless, because you can't comment on something you don't know. You make yourself look like a Klugscheisser.
Another bold statement is that script.aculo.us (actually prototype) is tightly coupled with RoR. That's not true. Prototype is a stand-alone JS framework. It is just nicely integrated into prototype. And how about dojo and ZF? Are they loosly or tightly coupled? Well, in both frameworks there are ways to use different client-side library, it's up to the developer, it's up to the project.
I think you really should try to overcome your hatred about Ruby and RoR and first try to achieve something with this tool before commenting on it. After all programming languages are tools and there is one right tool for a given job, you won't bang a nail into the wall with a rubber hammer, now won't you?
@Nikola: I appreciate your response. While I admit that I gloss over the details and my analogies are not perfect in order to emphasize a general point (the general point is that Ruby on Rails was a marketing success to the extent that they "hitched their cart" to Web 2.0), where did I actually claim that Ruby on Rails comes with script.aculo.us? Even if you take my analogy of PHP and MySQL to an extreme, PHP never came with MySQL—it just came with libraries to bind with MySQL.
Which is to say, I do appreciate the correction, but not the spirit of the correction. Given the already large size of the article as well as the target audience (first time developer using web-based development as the model of immersive learning), I'd be lucky if they sit through the article, let alone have gone through this entire bit.
Regarding your second statement in the same way, I hope you see I'm correct in the same manner. First it's not like MySQL is the ONLY database PHP uses, far from it! The only real thing that marks the key to its symbiotic relationship (to the extent that both are successful and their success is paired) is that MySQL has a special position among databases in the PHP world, not to the extent that you can't do PHP without MySQL. Compare this to your criticism of me my "bold statement" that it is "tightly coupled." It certainly would not be bold at all to say that PHP and MySQL are tightly coupled, though you could argue differently in detail.
As for your final paragraph, perhaps it is you who needs to overcome an inferiority complex that drives an incessant need to defend against imaginary attacks on your favorite language. In one of the comments above, I chastized an anti Ruby on Rails tirade by pointing out that for the better the Ruby language (and dare I add Rails) has given the programming world some nice things like GitHub and a bunch of tools for managing cloud computing (and continuous integration). But the tirade was correct in spirit, if not detail. To the extent that Ruby on Rails grew in Web 2.0, it was inevitable that this growth would be temporary. Remember, digg was using script.aculo.us before there was any Rails website of note. Compare your correction to the developer at Gawker. Even though his correction was much more damning to the thessis of my article than yours, and yet he didn't do it in a manner that took any offense. One can argue about whether or not I have "hatred" about Ruby and RoR, but it's clear by comparison that you are overly defensive about a perceived slight when none was given nor intended.
When you learn the initial level programming then you can switch over the second level of the programming like the advance c++, advance Java etc.. But the choice is depend on you.
I definitely agree that learning a full stack frameworks is not the best way to start out. Instead, new programmers should look to component libraries like PEAR or ZendFramework (not the MVC). This gives a nice balance of learning how to do things yourself while not leaving a bunch of security holes in your application.
I always suggest Python as a first language due to its structure structure and PEP's, but if someone is trying to crank a website out it is hard to argue against PHP.
My recent post Why I am not running to Solar
Whoops did I say Lars, I meant Rasmus… damned Northern European names… they all sound the same 😉
here is obviously a lot to know about this. I think you made some good points. Congratulations