(Not logged on) | Register | Log On

You can subscribe to this discussion group using an RSS feed reader. The Joel on Software Discussion Group

A place to discuss Joel on Software

This community works best when people use their real names. Please register for a free account.

Other Groups:
Joel on Software
Business of Software
Design of Software (CLOSED)
.NET Questions (CLOSED)
TechInterview.org
CityDesk
FogBugz
Fog Creek Copilot


The Old Forum


Your hosts:
Albert D. Kallal
Li-Fan Chen
Stephen Jones

PHP vs. Rails - concrete examples

I have seen lots of posts bashing PHP or Java and praising Ruby on Rails but they never give some clear, simple examples that don't involve scaffolding.

It would help people tremendously if you could give some concrete examples. This is what I would like to read:

1. In the first day developing my application with Ruby on Rails I would do this: ... while in PHP I would do this: ...

2. I develop faster in Rails because Rails does for me: <insert concrete functionality examples>

3. In PHP it is time consuming to do .... while in Rails I can do this quickly because ...

Thank you.
Denis Pride Send private email
Tuesday, March 14, 2006
 
 
1. In my first day of developing my application with Ruby on Rails I enjoyed the fact that I was able to have a good solid MVC architecture from the get go.  I didn't choose PHP, even though it is more widely supported by hosting services, but I had been very turned off by how much bad spaghetti PHP code there is out there.

2. I develop faster in Rails because Rails:

* Frees me from XML config files

* Has a simple and easy to follow flow of data from the database, through the model, up to the controller, and onto my rhtml templates.  I'm rarely confused by "how would I do this?" questions.  Most of the solutions in Rails are surprisingly clear.  It as a breath of fresh air coming from a Websphere world.

* Allows me to debug faster since I can make and see changes as quickly as I can save and reload my web browser.

3.  PHP is time consuming because as a language it isn't as easily readable as Ruby, and since most hosts only support PHP4 still I don't get the pure object oriented benefits that I get with Ruby.

And for a bonus point of view:

4.  All of the above stated reasons even make me more impressed with Flickr after reading about the magic they pull only using PHP and a well designed MySQL cluster.
Larry Myers Send private email
Tuesday, March 14, 2006
 
 
So what are the benefits of MVC for web development?

As an application developer, I can compare MFC (a C++ framework) with VCL (the library that comes with Delphi):

MFC is a MVC library, and it's slow to develop in

VCL is a view-oriented library (no explicit MVC model, if you want one, you have to develop it) and it's fast and pleasant to develop using it, and it works well even for complex projects

So, my  conclusion is that MVC is overhyped and leads to frameworks that are unpleasant to develop width.


As the original poster has said, please be more specific.

Rails offers MVC. Well, that tells me very little. MFC offers MVC too, and it's crap.
George Send private email
Tuesday, March 14, 2006
 
 
MVC in web programming means that you retain all the flexibility of pure HTML, while making reuse of templates quite easy.

Also, with MVC you may get a single point of entry for your application, which is good enough for simple applications. Not to mention that many large applications use single point of entry as well. It's like saying that all the processing of your PHP application will be handled by only one script.php. It means less mess, maybe. :-) I recall that in CGI it was only one script sometimes, but in Rails it's different, you have the code of the framework which you don't need to know about, you have the controller of your application, you have the several files of views and the possible several files of the model. Most of the layout of the files is standard so you don't need to think about it.

Also, generally, with a framework like Rails your application should be more secure just by the good organization of the files and of the standard coding which should protect you from yourself.

(Caveat: I don't use Rails.)
Lostacular
Tuesday, March 14, 2006
 
 
George --

My best advice is rather than me have to explain to you the detailed ins and outs of Rails in a very long post on this forum .. go check it out for yourself.

http://www.rubyonrails.com/

Give it a day or two to work through some of the intro tutorials (make a to do list, simple blogging app, etc) and you'll be able to come to your own conclusion better than if someone where to play 20 questions with you.
Larry Myers Send private email
Tuesday, March 14, 2006
 
 
I love the "PHP Sucks Because People Have Written Bad Code" argument.

How about:

$any_language_here . " sucks because people have written bad code";

Any language that gives you enough power to be useful, also gives you enough power to be destructive.

And I'd say that the reason you see more bad PHP code then, say, Ruby or TCL or Ada, for example, is because very few, if any, people go from creating a static HTML website to a Ruby-powered site or a TCL-powered site.

PHP is often the first language learned by people that microsoft calls "Morts" (i think that's Mort.. i might have my user roles mixed up) I've also had the pleasure of using Classic ASP (in both the VBS and TCL variety) and you get a lot of the same issues with that framework as well.
Shane Harter Send private email
Tuesday, March 14, 2006
 
 
Shane --

I believe my argument there is that:

PHP makes it easy to write bad code.

Ruby on Rails encourages and steers you in the direction of writing good code just the way the structure of the framework is set up.
Larry Myers Send private email
Tuesday, March 14, 2006
 
 
Ruby on Rails sandboxes you into a framework -- it forces you to write good code as long what you to accomplish fits perfectly with what it's designed for.  As soon as you vary off from that, you'll end up in bad-code territory just as with any language.

PHP is far more like C++ in that you have the freedom to do what you want.  It's also the freedom to screw up badly.
Almost H. Anonymous Send private email
Tuesday, March 14, 2006
 
 
"PHP is often the first language learned by people that microsoft calls "Morts" (i think that's Mort.. i might have my user roles mixed up)"

Mort is right.

Mort - Opportunistic/Beginner. VB.
Elvis - Pragmatic/Intermediate. C#.
Einstein - Paranoid/Advanced. C++.


http://wesnerm.blogs.com/net_undocumented/2003/09/who_are_you_mor.html
James Newton-King Send private email
Tuesday, March 14, 2006
 
 
BTW, I just found out something interesting:
RubyCLR (.NET) - http://www.iunknown.com/
Lostacular
Tuesday, March 14, 2006
 
 
Denis, it's all about what you need and want. There is no silver bullet, and both PHP and Rails produce the same eventual output -- a Web site/application -- so it boils down to what are your personal preferences.

Neither of them is inherently better or worse than the other -- they just have (mostly) different approaches and philosophies.

First of all, don't believe anyone who says that PHP can't be used for complex stuff. The main difference between the two is that PHP prepares for you only the most basic layer of Web development foundation -- you need to build everything else on top of it yourself. There are, though, numerous frameworks and libraries, both object oriented and procedural, that will make your life easier; essentially, a bulk of your development will consist of choosing the right framework.

On the other hand, Ruby makes your life simpler by making a lot of choices for you -- from how to set up your database to the fact that there is virtually no other Ruby-based Web development frameworks out there. This allows for an easy learning curve, but when the complexity of your application gets past a certain point you still need to delve down into the depths of Ruby.

Again, it all depends on your preferences. If you need a tool to quickly churn out a number of mostly db-independent CRUD Web applications, RoR will be perfect for that. However, expect that this advantages are offset by the low rate of RoR availability on commercial servers, and also by a limit after which the learning curve gets a lot steeper.

That being said, note that you can also quickly and easy write dynamic sites with PHP as well -- even easier than with RoR, because the setup is that much simpler. However, don't expect it to be anything more than a few glorified HTML pages with some server-based dynamism built-in. In a way, PHP makes it easy to write bad code because it makes it easy to write *any* code; for complex stuff of higher quality you need more discipline, in any language.

I think that we can say that PHP excels at the lowest level of Web development, while Ruby has an advantage on a more advanced rung (but have in mind that there is a number of PHP frameworks that are either clones of or inspired by RoR that fit this slot nicely). However, when you get to really complex Web applications, the exact same things that have previously made it simpler now stand in your way. PHP, being a wider platform, doesn't have such limitations, but expect to get your hands dirty and probably necessary to create your own architecture.

If you'll allow me a little pop-culture reference here, you might say that PHP is Millenium Falcon of Web development, while Ruby on Rails is a Nubian. It's up to you to decide whether you're more of a Han Solo or Princess Amidala.

The best advice I could give you is to try both of them and do some work in each. Anything else is just fan talk which won't really help you make a decision.
Berislav Lopac Send private email
Wednesday, March 15, 2006
 
 
You might want to check out Nola Stowe's blog.  She has been writing for about 3-4 months comparing various aspects of Rails and PHP.  And even wrote a simple MVC engine of her own on the blog:

http://codesnipers.com/?q=blog/7
KC Send private email
Wednesday, March 15, 2006
 
 
"If you'll allow me a little pop-culture reference here, you might say that PHP is Millenium Falcon of Web development, while Ruby on Rails is a Nubian. It's up to you to decide whether you're more of a Han Solo or Princess Amidala."


Already I can hear almost every RoR developer saying, "you developed in that? You're braver than I thought."


To overextend the metaphor I would say that this makes ASP a TIE fighter (draw your own conclusions ;)
Paul Brown Send private email
Wednesday, March 15, 2006
 
 
"To overextend the metaphor I would say that this makes ASP a TIE fighter (draw your own conclusions ;)"

Well, .NET would definitely be the Death Star: enormous, powerful and easily destroyed by a single small and agile craft. ;)

But we already had a similar languages metaphor discussion: http://www.abstract-factory.com/archives/23
Berislav Lopac Send private email
Wednesday, March 15, 2006
 
 
"But we already had a similar languages metaphor discussion"

I know - I enjoyed it a great deal.

In all seriousness though, the ability to "lash up" PHP is both it's strength and it's weakness - most of my recent development has been in PHP and getting what I want done has been pretty painless, but I may well change my mind when I come back in six months' time and try to maintain code in the form of:

-html-
-code snippet-
-more html-
-another code snippet-
-yet more html-
-code snippet with -html- in the middle-

etc.

Entirely my own fault; I should've been more structured when I wrote the code, but speed of development won over neatness and I may well pay dearly for this later.

("Don't worry, she'll hold together. You hear me? Hold together!")
Paul Brown Send private email
Wednesday, March 15, 2006
 
 
For my, PHP has always *looked* ugly, syntactically.  There is just something that always felt off about using it.  Very toy like.

Ruby *feels* nice and looks much better (though as strange as it sounds, perl looks the best).  Rails is a very nice framework and doesn't really get in the way if you play by it's rules.

To me the question is one of a conservative.  Will RoR be around three years from now?  Will I be able to hire talented people to work on a platform built around RoR?

PHP has critical mass.  You will not have trouble finding talent who can do PHP work.
Cory R. King
Wednesday, March 15, 2006
 
 
At least partially, you're comparing apples to oranges when you compare PHP with Rails.

PHP is a programming language, and Ruby is a programming language. Ruby on Rails is a framework. It would be more accurate to compare Ruby on Rails to Fusebox.
Anon to protect the guilty
Wednesday, March 15, 2006
 
 
1. In the first day developing my application with Ruby on Rails I got pissed because:

a) I'm impatient.

b) The "Agile" book or "Bible" as some zealots preach is somewhat out of date.  This can be a good or bad thing because you can follow along for the most part, but some things I had to research on my own to get to work.

c) I found that even though I could write a shopping cart fairly fast with a very limited amount of code... that I didn't really need a shopping cart that fit that criteria.

d) That I was swallowed up by the hype for a tool I didn't even need.  Thinking back, feels like I saw an auto-action hammer on HSN and bought all the books only to find I don't even use/need a normal hammer... it just looked cool.  But good luck to you if you need a cool hammer, it is "cool."

I'm primarily an ASP.NET guy.  I like the extendable nature of .NET (writing apps against Active Directory, Win forms or loading a new app on to my Pocket PC that I wrote in the same language) is incredibly cool.  Most of the "grunt" work that people say Rails saves them so much time... yes... if you are starting out with PHP with no idea of what a framework is or how it helps you... then Rails can provide you with a significant time savings.  But I imagine most people are in the same camp as me as they have found a language they are very productive in and use existing frameworks or have rolled their own that enables them to be more productive.

That's not to say that existing frameworks don't have growth potential or Rail's isn't better or vice versa, you just have to pick your flavor and for me... Ruby isn't all that useful outside of Rails.

Another thing you will see is the flame wars going on in the blogs of RoR and DHH.  Just constant bashing of what Gosling said, or some C# expert, or why Zend is going to $hit when they see RoR 1.1... and sometimes I think 37signals and DHH attract more attention than Joel does! 

And I'm no huge fan of Joel or anything, but I did always value the context and technical level/merit of both developers and entrepreneurs here as a valuable resource... and recently the forums had been swamped with "review my photo site" or "look how I can save your bookmarks in XML and send it to Onstar," and although commendable and admirable that people are motivated and inspired... RoR has significantly lowered the technical barriers to web development for the average person... to whom had limited understanding of the underlying principles to begin with... and from there you have a raging crowd of people who love RoR because it brings Access to the web (not far from it with "default" MySQL install) and they have nothing else to compare it with or any idea how to advance Rails beyond it's current scope of crud. 

So as long as 37signals can keep that attention and roll out most of the changes themselves and with their closest "core" allies, great!  But it doesn't seem to have the long term appeal that PHP or Python will ever have... because they require a real understanding of what you are doing.

And don't take me for saying everyone who uses Rails is a web moron, because that's simply not true.  Just a general trend I've noticed and I'm glad that the RoR/DHH blogs/forums have attracted that kind of userbase away from JoS.  So for the rest of us here who have decided that Rails is an exciting and useful technology, it's likely because you tried it with some understanding what you had to do before... and therefore respect it on technical merit and not because Basecamp/Backpack is "OH SO COOL like MySpace!!111"

So try it for yourself and your own experience will tell what it can do for you.

It does nothing for me.  To each his own.
Phillip Zedalis Send private email
Wednesday, March 15, 2006
 
 
People who think PHP is great don't have enough experience to come to this conclusion.
Absconditus
Wednesday, March 15, 2006
 
 
PHP isn't great, it's good enough.  Lets face it, C++ ain't great either for much of the same reasons.
Almost H. Anonymous Send private email
Wednesday, March 15, 2006
 
 
"People who think PHP is great don't have enough experience to come to this conclusion."

True. The same applies to people who think PHP sucks.
Berislav Lopac Send private email
Wednesday, March 15, 2006
 
 
"PHP is a programming language, and Ruby is a programming language."

Er, not entirely. PHP is actually a programming language merged on top of a quite thin Web framework layer. You can't use PHP in quite the same way as you can Ruby.
Berislav Lopac Send private email
Wednesday, March 15, 2006
 
 
Well, it is entirely if you consider webpages Files and the databases the computers!
Rick Tang Send private email
Wednesday, March 15, 2006
 
 
Each language has a great MVC framework. There's no reason to force yourself into learning Ruby if you don't have to.

If you want to use Java, use Struts.
If you want to use Python, use TurboGears.
If you want to use PHP, use Symfony.
If you want to use Perl, use Catalyst.
If you want to use Ruby, use Ruby on Rails.
Cletus Send private email
Wednesday, March 15, 2006
 
 
Symfony [http://www.symfony-project.com/] seems interesting. Has anyone used it?
YaYa
Thursday, March 16, 2006
 
 
I'm sorry, but Struts is not a great MVC framework! It does very little for you. Ruby on Rails is light years ahead. Some of Rails' features are only possible because it's built using a dynamic language. And yes, I have used both frameworks.
John Topley Send private email
Thursday, March 16, 2006
 
 
This discussion is amazing. A guy asked a simple question - to know (in concrete terms) how is Ruby on Rails development faster and better than PHP development.

Responses:

- "PHP sucks, Ruby rocks"
- Ruby offers MVC, so it rocks

This is amazing.

I'm a Delphi fan. However, I can explain why Delphi is better than other alternatives for Windows development in concrete terms, without saying "Visual C++ sucks, and Delphi rocks" or "Visual Basic sucks, and Delphi rocks".

Why can't the Rails guys explain this? Perhaps because Rails is just hot air?
Delphi fan
Thursday, March 16, 2006
 
 
"Perhaps because Rails is just hot air?"

To be fair to them, it's more likely that what makes something "better" than something else is just too subjective (although that doesn't excuse the "your language sucks" comments).

To give a case in point, whilst you have a list of things that you like about Delphi, I don't find Delphi particlularly wonderful, although I do admit that the last version I used was circa 4.0 which was a long time ago. The visual facilities of Delphi were good, but the Pascal language structure doesn't feel natural to me.

This should not be interpreted as "Delphi sucks" in any way; my personal languages of choice are PHP and Java and yet even I can find reasons to criticise both of these, it's just that the positives outweigh the negatives to me. To someone else they might not.
Paul Brown Send private email
Thursday, March 16, 2006
 
 
It amazes me when people don't get some and they start to bash it. It is pretty obvious that some people chiding rails don't quite understand it. I have developed enterprise apps for over 10 years. I started out in C, moved to Perl then Java/J2EE and my current day job is all about .NET. Ruby and Rails is just the next step.

Perl was a step up from C in the old CGI days. Java/Servlets/JSP (used in the proper way, of course) was a step up from Perl (Tapestry is by far the best thing to ever happen to web development, but I will save that for another time). .NET is not better than Java/Spring/Hibernate/Tapestry, but it does allow people who love MS products to come close to that system.

But with Rails, we are looking at where all of these systems will eventually be. There is nothing about Rails that "boxes you in" and then won't let you do something. I can't think of anything that you can't do in Rails that you can do in another language/framework. If you can think of something...at least say what it is instead of saying "you don't have the experience to comment".

Basically, if you don't understand rails, you fail to grasp the finer points of MVC. If you don't like MVC, fine...I won't argue that right now. I would, however, suggest you try to do something before you just write it off. Otherwise, you just speaking from ignorance....
Jason Send private email
Thursday, March 16, 2006
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz