What MVC framework for web development?

Answered in Quora:

Q: Why should I learn the combination of Python/Django rather than PHP, JS/Node? I am a web designer moving to web development. What is the scope of Python/Django?

Python/Django is like learning Ruby/Ruby on Rails. The equivalent in the PHP world would be PHP/Drupal or PHP/Laravel. Equivalents in NodeJS is not Node/JS but NodeJS/Meteor or NodeJS/Sails. In all those examples above the first part would be the underlying web language, and the second would be a MVC framework on top of the language.

(There exist web frameworks that do not provide MVC but just the web server and HTTP request-response plumbing. This isn’t common in PHP since it is embedded in a web server such as Apache or nginx, but in Python it would be flask and in NodeJS it would be Express or Koa— these are sometimes referred to as “microframeworks.”)

However, unlike on the front-end with things like Vue.js, React/Redux and AngularJS, full-service MVC web frameworks have increasingly less utility on the back-end. This is because most the the advantage a framework provides is to do heavy-lifting of tedious but repeatable tasks that require a lot of code (very common when building a user interface) the bulk of which has been moved onto the client in web development. What value is a MVC’s templating system and router when both have moved into javascript on the client-side and all interactions are through an API? This becomes more extreme with standardization of the data interface (a la GraphQL) and the prevalence of more service-oriented architecture popularized by microservices or serverless FaaS architectures.

MVC web-frameworks still provide things such as a configuration management, a data object model and abstraction, but even those can get in the way as a website becomes more mature and this pre-fab approach becomes a hinderance to future scalability and optimization.

Also, when not building to scale or building proof-of-concept, a full MVC architecture will help you starting out on server-side web development because it does all the heavy lifting for you. So it might be good to start out with one, though YMMV (your mileage my vary).

Continue reading about the state of web frameworks after the jump

On being a beginner (again)

Compiled from three separate discussions on IRC, twitter, and in person:

“Whatcha do with your time these days? Learning Rails? ?”

I did pick up Objective-C again after an aborted attempt at learning Swift. Mostly I’m trying to catch up on the javascript frameworks that have come out since I stopped coding. Right now it’s AngularJS—I figure I can jury-rig React into it if performance becomes an issue.

On the non-programming side, I’ve been messing with Ansible because I just got tired of doing things by hand—and I never needed to learn this because I’ve always had operations engineers working with me.

The ripping on Rails thing is over with me because there’s no point in arguing over how to solve a solved problem—today, the web problem is the easy part. What I find strange is people still feel the need to defend Ruby on Rails. I mean who the fuck cares what your middle layer code is written in when everything is an API to something written in Javascript?

“I don’t like that everything is an API to something in Javascript. As a user, the Web feels slower and flakier than it used to.”

I don’t like that everything on the front-end is pushed toward a single-page application. The reason for this is that the DOM-based model of front-end javascript (e.g. jQuery) gets so taxing when the application gets big because you’re bolting feature-on-feature, library-on-library to get it to work as smoothly as you envision. At a certain point, a true MV(VM) javascript framework (e.g. AngularJS) gives you much more because it abstracts all that in a consistent manner.

As soon as you buy into one of these, you’re invested into a huge initial javascript payload which causes you to not want the user to leave the page to unload anything, which then forces you into an API-based model with HTML partials and a client-side route/sitemap and more crap in the payload until you have a single-page application.

And then pretty soon your website is like Flickr where I swear every tenth click I’ve got to reload the page because the UI became non-responsive and I’m deciding to open the app in my iPhone just to do something without that frustration. How fucked up is that?

But then I look at Bootstrap and I figure, I’d rather have a SPA than everything looking like it was designed by some Apple-loving hipster (and this coming from a person who has used and loved Apple products longer than they’ve been alive).

“I’ve always enjoyed your talks and lamented that you didn’t remain on the PHP speaking circuit.”

Maybe I’ll start speaking when I have something to say. Like I’ve said before, PHP solves the “web problem” very well, but the web-problem is not a hard problem anymore.

Remember, it’s been four years since I’ve done any UI programming so everything is new to me. Basically, I’m a newbie, and I don’t think anyone wants to hear from someone who doesn’t know what they’re talking about.

But I did notice this from managing engineers: the worst problem a coder can get into is fear of having to start over. You get good at what you’re good at and when things pass you by, you feel the need to protect what you have because its what you know.

That’s how I feel about Ruby on Rails and that’s how I feel about me and PHP.

So, I’m a beginner again.

You lost me there, bub

Reading [this blog post ranting on PHP][phphorrors]

> No corporation supports PHP’s growth & maturity like Sun & Google do for Java, Google (Guido van Rossum) for Python (jnc Django framework), Ruby (inc RoR) by 37 signals etc…

37Signals & Ruby? Thank his noodly appendage PHP’s support isn’t as terrible as that company on that language.

You lost me there, bub.

When it comes to engineering choice, programming language is not even in the top 10 of important choices a software architect has to make. If you’re worried about the language, you’re worried about the wrong thing. (I’m also a little amused that the author holds Python as a language with great unicode support.)

[phphorrors]:http://www.theroadtosiliconvalley.com/technology/php-coding-horrors-poor-excuses/ “PHP: coding horrors & poor excuses—The Road to Silicon Valley”

It's just a tool

Previously: [Part 1][programming1], [Part 2][programming2], [Part 3][programming3], and [Part 4][programming4].

I received an interesting question the other day from a recruiter:

> Would you be open to moving away from PHP?

My answer:

First, by analogy. I’m a photographer, most of the cameras I own are manufactured by Nikon. This is like asking if I’m open to using a Canon.

I happen to be very adept with using a Nikon. However, I don’t think [the photons bouncing around care much what logo sits on front of the camera][camera purchasing] they are in. I’d be a poor photographer if what I did was care about the brand of camera I carry instead of the picture I am taking.

PHP is designed to solve one problem: the web problem. It solves it very well—as evidenced by marketshare and its continuing durability. At nearly all other stuff, PHP happens to suck at.

However it (the web problem) [isn’t that difficult] of a problem (having been solved repeatedly by languages such as Ruby, Python, C, C++, Java, Javascript, etc.). The real difficult parts are invariably outside the “web problem.” (Example: Twitter’s web problem was solved in Ruby using Rails, but their real problems were not web problems and of those problems, the most prominent was solved in Scala.)

I happen to be very adept at PHP. That pretty much means knowing that there is a better tool than to use PHP to solve the problem at hand at hand, and using that instead of PHP: MySQL, Apache, memcached, MongoDB, CouchDB, Scala, Erlang, Puppet, CruiseControl, AWS, etc.—none of which, to my knowledge anyway, written in PHP.

I’d be a poor programmer indeed if I thought that the problems I solved cared much the language I was adept in.

I’m not a poor programmer.

The Short answer: “Yes. Depends on the problem and the existing environment.”

(Recruiter was amused by my answer because he was owns a Canon. I suggested we “get on either side of the street and start making threatening dance moves at each other like [the Jets and the Sharks][west side story].”)

Another question I got:

> Which do you think is better [some programming language] or [another programming language]?

My answer:

They’re just tools. That’s like asking a handyman which they think is better: a hammer or a screwdriver.

(That elicited a laugh.)

Using a programming language is simply [a choice][making choices]. There are many things that go into making a correct choice that are far beyond what language one prefers for a problem that happens to be not that hard to solve in the first place.

[programming1]: http://terrychay.com/article/learning-programming.shtml “Learning Programming Part 1: 5 million”
[programming2]: http://terrychay.com/article/learning-frameworks.shtml “Learning Programming Part 2: Programming Frameworks”
[programming3]: http://terrychay.com/article/learning-programming-part-3-c-cplusplus-superiority.shtml “Learning Programming Part 3: C/C++ superiority”
[programming4]: http://terrychay.com/article/programming-is-hard.shtml “Learning Programming Part 4: “Programming is Hard””
[camera purchasing]: http://terrychay.com/article/camera-purchasing-aphorisms.shtml “Camera purchasing advice”
: http://terrychay.com/article/is-ruby-the-dog-and-php-the-dogfood.shtml “Is Ruby the dog and PHP the dogfood?”
[making choices]: http://terrychay.com/article/simple-prescriptions-and-making-choices.shtml “Simple prescriptions and making choices”
[west side story]: http://en.wikipedia.org/wiki/West_Side_Story “West Side Story—Wikipedia”

Largest Ruby on Rails app?

Seen in a brochure at PayPal X:

LinkedIn uses Joyent infrastructure to run the largest Ruby on Rails app with over 2 billion monthly pageviews.

  • I thought LinkedIn was Java, when did they switch to Rails?
  • 2 billion monthly? When I left my last company, our (PHP) app was doing over 7 billion monthly, and wasn’t even in the top 10 PHP applications out there. Surely there are Rails apps bigger than that.

Confoo: PHP without PHP

confoo.ca Web Techno Conference

If you are attending confoo this year, I’ll be giving a talk at the beginning of the conference. Even if you aren’t a PHP developer, I think you’ll find the talk useful—as there is no language religion in it. I’ll be pleased if you attend.

It’s going to be a little different from my recent talks (less cussing). Believe it or not, there was a time I used to be a speaker who didn’t resort to scatalogy to get my point across. 🙂 In fact, George once told me that his favorite talk of mine was the first one I gave—nary a cuss word to be found because I was so nervous! This talk is an attempt to return to the more-focused application of philosophy that I had done starting out.

Since my session is in the beginning of the conference, and I’ll be there until I have to leave for SXSW, I’d appreciate it if you still came up to me and talked to me about anything on your mind. Don’t worry, like a terrier (terryer?), I’m all bark and no bite.

I’m trying to reset the way I approach web development and so this may very well be the only conference I’ll be speaking at this year. I’m sure any discussion you have will be worthwhile—even if it isn’t about my talk or web development. Confoo this year is going to be about so much more than PHP, and I’m very interested in new developments on the web, even if it is happening in the Rails community. ;-). Besides, PHP gets nowhere without stealing from our betters. 🙂

See you there!
Continue reading about the post presentation stuff after the jump

1500 Lines of Code

Original article posted to PHP Advent 2009, Click to jump to discussion. Happy Holidays to you and yours!

Even the best of us can only write 1500 lines of code a day, so we need to make those lines count.

There were so many great articles in PHP Advent this year, that I couldn’t think of a good topic—I like to believe my peers stole all the good ideas this year… 🙂
Continue reading about Read about 1500 lines of code after the jump

Learning Programming Part 2: Programming Frameworks

A selection of programming language textbooks ...
Image via Wikipedia

(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:

PHP is the shortest distance between two points on the web.

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.

Continue reading about More about learning web programming after the jump.

Web development as torture

Apparently one commenter found my April Fools articleham-handed.”

ham-hand⋅ed
clumsy, inept, or heavy-handed: a ham-handed approach to dealing with people that hurts a lot of feelings.

I’m sorry that some people didn’t realize that an article was meant to show off someone else’s April Fool’s prank. I guess the snippets of code showing the joke, putting it in the “humor” category, and adding the words “april phails phools” to the URL just wasn’t enough for some people 🙁

Next time, in order to prevent hurt feelings, I’ll be sure splay across the top the words: “Look, Phails is an April Fools Joke, Please don’t take it seriously (pretty please?)” in 42-point Charcoal typeface.

On second thought, why bother? 37Signals has me beat in the tact and sensitivity department. Notice how they introduce Ruby on Rails as…

The very definition of integrity

Great moments in Truth in Advertising™ just ask Twitter.

(And when I replied that this was madness, he kicked me into some CAT-5 ethernet cabling with the words, “THIS IS SPARTA!!!”)

(I heard that Web development is so hard that Rasmus had John Yoo write up a torture memo lest any Guantamano detainees put up a website between waterboarding sessions.)

Thank God, that I learned Ruby on Rails so I no longer have to deal with the pain of writing a SQL select.