Ruby vs. PHP

Hello

My company is trying to get big contract for creating and maintaining
HUGE website (nation wide portal). We’re trying to convince investor
that Ruby (i don’t mean rails) with custom tailored MVC framework is
best solution, we’re going to make prototypes in rails FAST, then port
heaviest and most frequently used parts to my custom framework, rewrite
AR into tuned SQL queries etc.

investor was quite impresed with speed of development but of course
there’s trouble in paradise … he hired a consultant :confused: - this guy AFAIK
did lot’s of work but only in PHP and he is trying to convince investor
PHP is way to go.

could you please help me find some benchmarks comparing speed of PHP vs
Ruby (especially YARV/JRuby, if ound some benchamrks that show Ruby is
slower in interpreter), mayby comparsions of security(in Rails it’s
preatty imposible to do sql injections if programmer is carefull enought
to use properly constructed queries).

also I’m open to any arguments(preferable documented, with showcases,
and understandable by investor(who never had much expirience with
computers except for e-mail and www)) that would help convince him that
ruby is much better then php :slight_smile:

and I’m also looking for big sites that adopted ruby / ruby on rails
(especially with huge number of users / hit’s per s)

Marcin R.

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=ruby&lang2=php

On 10/1/07, Waleed H. [email protected] wrote:

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=ruby&lang2=php

This has been discussed a lot on this list, and I believe that a
majority of the community is concerning the shootout site a site
without any value.
For sure I do.

Cheers
Robert

On 10/1/07, Marcin R. [email protected] wrote:

Hello

My company is trying to get big contract for creating and maintaining
HUGE website (nation wide portal). We’re trying to convince investor
that Ruby (i don’t mean rails) with custom tailored MVC framework is
best solution, we’re going to make prototypes in rails FAST, then port
heaviest and most frequently used parts to my custom framework, rewrite
AR into tuned SQL queries etc.

Why is this a good idea?

investor was quite impresed with speed of development but of course
there’s trouble in paradise … he hired a consultant :confused: - this guy AFAIK
did lot’s of work but only in PHP and he is trying to convince investor
PHP is way to go.

PHP beats Rails in certain aspects; for instance if development of the
site is seasonal in nature, as opposed to continuous, the customer
is likely to be hiring as they need. The large availability of PHP
developers plays in its favour.

could you please help me find some benchmarks comparing speed of PHP vs
Ruby (especially YARV/JRuby, if ound some benchamrks that show Ruby is
slower in interpreter), mayby comparsions of security(in Rails it’s
preatty imposible to do sql injections if programmer is carefull enought
to use properly constructed queries).

Well none of that is true, or really important. Sure its easier to
secure Rails.
But if you are making a large nationwide portal (I am going to assume
that
that means you have high activity) then the performance of your
rendering
component (PHP or Rails) doesn’t actually matter.

PHP isn’t exactly assembler speed itself. Ruby is in the same league
(slower
with 1.8, faster with YARV). There is a reason that PHP is a central
component
in a LAMP stack - probably the solution of choice for websites with high
user
load. In principle Ruby can do the same, in practice we have only had
about 2 years
as a community to get big Ruby sites up. You also have an equivalent ASP
stack based on windows components.

All of these stacks are glued together with languages that are at least
an order
of magnitude slower than Systems languages like Java.

also I’m open to any arguments(preferable documented, with showcases,
and understandable by investor(who never had much expirience with
computers except for e-mail and www)) that would help convince him that
ruby is much better then php :slight_smile:

There’s plenty of sites out there doing pretty heavy stuff with Rails,
but beyond
Rails there is not much evidence that shows pure Ruby custom web
solutions
to scale. Rails has a lot of features and best practices built in to
help it scale.
In a pure Ruby solution you are committing to re-writing all of that
from scratch.

Based on your questions/responses here, I think the consultant is right;
that
PHP is a better solution for the customer.

Robert D. wrote:

i found this one, and also it’s interprete ruby not YARV or JRbuy

I wouldn’t sweat it much.
Show them good sites built with these things. Explain the reasons you
use what you use.
If they hire a consultant who only recommends one technology, then
he’s a shill.
He could just as easily be an ASP shill or a Java shill or anything
else.
Ruby and Rails are still small compared to PHP, but booming and not
shrinking.

You might want to show a bit more of the ongoing history of
insecurity that is a lot more rampant with PHP sites, and even
recommend a little security through obscurity. (that’s what kept VAX
systems going until HP end-of-lifed the OS)

But in the end, if you don’t get it, chances are they’ll go with a
cheap and mediocre PHP shop. It’s a lot like the cheap and mediocre
Microsoft-based shops. There are lots of them, but there are lots of
bad ones. Good PHP shops are probably more expensive (and busier)
than you.

The truth is, the language used is only one small part of many things
they should be carefully considering. Server (hardware/software) /
web hosting can be as/more important. The language really shouldn’t
matter all that much. Google, Yahoo, etc… don’t use strictly one
language or framework in house! A decent programmer / team of
programmers should be able to select the technology they feel will
work best for them AND the project together. In some cases Ruby might
be the wrong choice.

Everybody and their dog touts themselves as a nationwide high-traffic
portal site to be, but if that were true or even likely, they
wouldn’t need a consultant, they’d have a CTO of some kind who would
have already decided these issues. Sounds more like your selling lawn
care services to a guy from the desert who has only heard of grass
and is planning to build a golf course.

I don’t take responsibility for the quality of articles linked here -
but here’s a blog post gathering links arguing right what you seem to be
looking for. Maybe it’s worth checking out.

http://rubythis.blogspot.com/2006/12/justify-your-choice-of-ruby-on-rails.html

mortee

Finally a topic I like :slight_smile:

rails forces good practices like MVC
I believe this is debatable. What we should not forget
is that, while this uniform maintenance is a good
thing in general, rails also forces you into its world of
thinking.

The truth is, the language used is only one small part of many
things they should be carefully considering. […]
The language really shouldn’t matter all that much.

I will take another approach and claim that the language
used is and will be the biggest most influencing factor.
It is exactly the reason why PHP became popular today -
it beat Perl cgi scripts. It was easier to learn than perl.
It had a good online docu. It concentrated on the web +
database aspects.
Every language has different pros and cons, and there may be
some cases where php really has more advantages than ruby.
But in general ruby as a language is simply better than php.
That includes the world wide web, but unfortunately there
are a little problems. Rails for example, forces you to
think in the rails-way, for the good or for the bad.
(By the way, it would be cool to be able to
embed ruby straight into a .php document… right now
I am porting my legacy .php scripts to ruby, it takes
quite long :stuck_out_tongue: )

also I’m open to any arguments(preferable documented, with showcases,
and understandable by investor(who never had much expirience with
computers except for e-mail and www)) that would help convince him that
ruby is much better then php :slight_smile:

Easiest way to convince is code examples. Focus on simple tasks that
have some reallife usage value to him (the investor). But of course
the comparison must be fair, so dont make it too complex :wink:

It would actually be nice to have a way to compare PURE php (+solutions)
with PURE ruby (+solutions for web-tasks:

  • Post data into a “web formular” in both languages
  • retrieve data from a mysql database
  • run automated “comparisons” and other data manipulations
    from a “web formular” (i.e. something for your investor
    that makes working with it easy)

Personally, I am a bit unhappy that PHP is compared to Rails so
often … PHP should be compared to Ruby, and then if we can,
Ruby should improve on the area where PHP has a slight edge.

To me, speed was NEVER a reason, and to be honest, I think
some people really overrate the speed issue at first hand.
At least it should be untied from OTHER reasons, such as
the online docu part for example, where I think PHP still
has a lead over ruby in that aspect. :wink:

Richard C. wrote:

Why is this a good idea?
why not?
rails is easy to prototype but is painfully slow and hard to optimize, i
know caching is going to play huge role but optimized complex sql
queries are also important

possibility of continous development is one of strong points of rails,
and that’s why i’m advertising it, code writen by that large group of
php developers is usually unmaintainable. I had plenty of expirience
with php and i know how strangely can be php written, and rails forces
good practices like MVC, and ruby i much cleaner langue then php to
begin wth

could you please help me find some benchmarks comparing speed of PHP vs
Ruby (especially YARV/JRuby, if ound some benchamrks that show Ruby is
slower in interpreter), mayby comparsions of security(in Rails it’s
preatty imposible to do sql injections if programmer is carefull enought
to use properly constructed queries).

Well none of that is true, or really important. Sure its easier to secure Rails.
But if you are making a large nationwide portal (I am going to assume that
that means you have high activity) then the performance of your rendering
component (PHP or Rails) doesn’t actually matter.

if it’s easier to screw up in PHP with security, then here it’s REALLY
important, try to imagine hacker group logo in something like msn/yahoo
main page

PHP isn’t exactly assembler speed itself. Ruby is in the same league (slower
with 1.8, faster with YARV). There is a reason that PHP is a central component
in a LAMP stack - probably the solution of choice for websites with high user
load. In principle Ruby can do the same, in practice we have only had
about 2 years
as a community to get big Ruby sites up. You also have an equivalent ASP
stack based on windows components.

what is the reason? php was never solution of choice for high-load or
professional websites, it was promoted becouse suposed ease of use and
installation

but beyond
Rails there is not much evidence that shows pure Ruby custom web solutions
to scale. Rails has a lot of features and best practices built in to
help it scale.
In a pure Ruby solution you are committing to re-writing all of that
from scratch.

any examples? i know google is starting to use Ruby.

thanks for your response, it rises valid point that i have to think over

John J. wrote:

that is a lot more rampant with PHP sites, and even recommend a little
security through obscurity. (that’s what kept VAX systems going until HP
end-of-lifed the OS)

But in the end, if you don’t get it, chances are they’ll go with a cheap
and mediocre PHP shop. It’s a lot like the cheap and mediocre
Microsoft-based shops. There are lots of them, but there are lots of bad
ones. Good PHP shops are probably more expensive (and busier) than you.

One of main reasons why my (small and new) company is considered is
becouse productivity using rails is so high that even if i want much
more money per hour of work then php professional i finish same thing
properly secured with rails before php developer finishes collecting his
tools and code snippets

The truth is, the language used is only one small part of many things
they should be carefully considering. Server (hardware/software) / web
hosting can be as/more important. The language really shouldn’t matter
all that much. Google, Yahoo, etc… don’t use strictly one language or
framework in house! A decent programmer / team of programmers should be
able to select the technology they feel will work best for them AND the
project together. In some cases Ruby might be the wrong choice.

I feel ruby especially thanks to JRuby (possibility to use java
libraries), ruby:inline(possiblity to use c/c++) and IronRuby(same for
c#) might be best choice to tie all together, and i can use rails to
make it all work in record time

Everybody and their dog touts themselves as a nationwide high-traffic
portal site to be, but if that were true or even likely, they wouldn’t
need a consultant, they’d have a CTO of some kind who would have already
decided these issues. Sounds more like your selling lawn care services
to a guy from the desert who has only heard of grass and is planning to
build a golf course.

well, mayby i described size wrongly, first of my country is much much
smaller then US :], money are diffirent, and stage of IT also.

CTO’s usually depend on consultants anyway, but this one agrees that
ruby is good choice and need a little push, so I’m asking you all to
provide me with arguments i can use in php vs. ruby battle :wink:

I know pros and cons, and I personally prefer ruby (i have solid
background in php, never liked it, had horrible 4 months while i tried
to maintain code written by php “programmers”, which was full of sql
injection holes) so I “know” i want to write in ruby / ruby on rails,
and think it’s right decision to use this technology.

mortee wrote:

I don’t take responsibility for the quality of articles linked here -
but here’s a blog post gathering links arguing right what you seem to be
looking for. Maybe it’s worth checking out.

http://rubythis.blogspot.com/2006/12/justify-your-choice-of-ruby-on-rails.html

mortee

thanks that’s exactly what i was looking for.

from a "web formular" (i.e. something for your investor
that makes working with it easy)

since i have background in php i can provide investor with code samples,
but I know that ruby is better for me, problem is to convince investor
that know nothing about programming

Personally, I am a bit unhappy that PHP is compared to Rails so
often … PHP should be compared to Ruby, and then if we can,
Ruby should improve on the area where PHP has a slight edge.
that’s why I’m asking about advantages of ruby (read my post carefully)
and in second order rails - if I’m talking about rails i should compare
it to cakePHP or Smarty or something like that

To me, speed was NEVER a reason, and to be honest, I think
some people really overrate the speed issue at first hand.
At least it should be untied from OTHER reasons, such as
the online docu part for example, where I think PHP still
has a lead over ruby in that aspect. :wink:

Problem with online docu is that there’s TONS of shity, ugly,
exploitable code online for php and noone cares - i even saw statistics
saying that 80% of php code have serious sql-injection vulnerabilities.

as for speed - it doesn’t matter if something is 2-3 times slower then
same thing in J2EE, it doesn’t even matter if it’s 10 times slower, but
if one request to rails takes 5 seconds on modern server it DOES matter
:wink:

Wayne E. Seguin wrote:

I highly advise checking out the up and coming release of Merb for your
framework. You can hop on irc.freenode.net#merb and ask any questions you
have there about speed, features, etc…

Good luck.

~Wayne

Thanks i was talking with Ezra Zygmuntowich on irc a while ago, and i
borrowed lots of ideas (and some of code) for my own microframework.

If there were any interesting changes in merb I’ll take a look, but my
framework was designed to do exactly what i needed (which was to handle
AJAX and forward to remote servers, then parse request and send to
application when next AJAX request hits) and did job right :slight_smile:

On 10/1/07, Marcin R. [email protected] wrote:

Hello

My company is trying to get big contract for creating and maintaining
HUGE website (nation wide portal). We’re trying to convince investor
that Ruby (i don’t mean rails) with custom tailored MVC framework is
best solution, we’re going to make prototypes in rails FAST, then port
heaviest and most frequently used parts to my custom framework, rewrite
AR into tuned SQL queries etc.

I highly advise checking out the up and coming release of Merb for your
framework. You can hop on irc.freenode.net#merb and ask any questions
you
have there about speed, features, etc…

Good luck.

~Wayne

On 10/1/07, Marcin R. [email protected] wrote:

Richard C. wrote:

Why is this a good idea?

why not?
rails is easy to prototype but is painfully slow and hard to optimize,

Well thats a claim you will have to back up. I don’t see it as being
harder than any other optimization work.

i know caching is going to play huge role but optimized complex sql
queries are also important

And Rails/AR etc. support multiple levels of caching, and you can always
do find_by_sql. ActiveRecord dynamic finders are fun and all, but have
no
place in a production app.

possibility of continous development is one of strong points of rails,
and that’s why i’m advertising it, code writen by that large group of
php developers is usually unmaintainable. I had plenty of expirience
with php and i know how strangely can be php written, and rails forces
good practices like MVC, and ruby i much cleaner langue then php to
begin wth

Fair enough. Win for Rails.

if it’s easier to screw up in PHP with security, then here it’s REALLY
important, try to imagine hacker group logo in something like msn/yahoo
main page

Agreed. But the default security in Rails is not bulletproof. Its also
not
difficult to replace or improve. Edge Rails is bringing in protection
for
Cross Site Request Forgery.

PHP security is probably going to remain a gaping wound for some time to
come. Win for Rails.

professional websites,
Ah no. PHP is provably in use in many of the largest sites on the
internet, like
Wikipedia, Facebook etc… The foundations of why a basic language like
PHP works in this
environment is easy to understand: PHP doesn’t give you many sharp tools
to hurt yourself with so its runtime characteristics are very
predictable.

ASP stacks work the same way.

Rails is imitating those stacks. So it should reap the same rewards,
but the biggest
Rails website (twitter I think) is currently not in the same league as
the biggest PHP
and ASP sites.

Win to PHP. But not for much longer I suspect.

There’s plenty of sites out there doing pretty heavy stuff with Rails,
but beyond
Rails there is not much evidence that shows pure Ruby custom web solutions
to scale. Rails has a lot of features and best practices built in to
help it scale.
In a pure Ruby solution you are committing to re-writing all of that
from scratch.

any examples? i know google is starting to use Ruby.

Well no not really. The last really good writeup on the internal
workings
of google, came from Steve Yegge a couple of months ago (see his
blog on Rhino on Rails).

Ruby is not yet one of the Google sanctioned languages (C++, Java,
Python
& JavaScript).

thanks for your response, it rises valid point that i have to think over

I am not being hypercritical of your choices. In your situation, I would
go
with Rails over PHP as well, for much of the same reasons (performs
well enough, rapid delivery, long term maintenance).

But you have committed to an ActiveRecord rewrite, and your reasoning
is not clear. It sounds like you have read something that ‘ActiveRecord
doesn’t scale’ without investigating thoroughly.

Rails gets a lot of its productivity from ActiveRecord. By getting rid
of it,
you lose that, and you also close the door on the community development
of ActiveRecord and its supporting plugins.

Well no not really. The last really good writeup on the internal workings
of google, came from Steve Yegge a couple of months ago (see his
blog on Rhino on Rails).

I heard they are STARTING to use ruby from one of google employes.

I am not being hypercritical of your choices. In your situation, I would go
with Rails over PHP as well, for much of the same reasons (performs
well enough, rapid delivery, long term maintenance).

But you have committed to an ActiveRecord rewrite, and your reasoning
is not clear. It sounds like you have read something that ‘ActiveRecord
doesn’t scale’ without investigating thoroughly.

I didn’t “hear” anything, i performed tests and benchmarks, with few
ORMs (AR, Og, sequel) and pure postgres library and obviously pure hand
made SQL is best - of course i can use AR’s find_by_sql, and sometimes i
do but it’s slower then pure call.

personally i never had to use pure postgres driver except for one small
script that was loading xml to database(where switching from AR to
postgres driver changed execution time from 12 min into 7 min)

Rails gets a lot of its productivity from ActiveRecord. By getting rid of it,
you lose that, and you also close the door on the community development
of ActiveRecord and its supporting plugins.

I’m planning to use ORM, and use pure sql for most frequent calls (like
checking for new messages, or new stories) that are made by ajax

On 10/1/07, Marcin R. [email protected] wrote:

I’m planning to use ORM, and use pure sql for most frequent calls (like
checking for new messages, or new stories) that are made by ajax

Marcin,
In this case I recommend also evaluating the Sequel ORM.

~Wayne

Marcin R. wrote:

Well no not really. The last really good writeup on the internal workings
of google, came from Steve Yegge a couple of months ago (see his
blog on Rhino on Rails).

I heard they are STARTING to use ruby from one of google employes.

I’m sure google will try anything that will give them an advantage, but
Google has already made their choice for a scripting language: python.
Google hired Guido, who is the python BDFL(i.e the Matz of python), and
they have other significant python hires. With python wizards in house,
I don’t think they are going to be switching to ruby any time soon.

On Tue, Oct 02, 2007 at 01:29:57AM +0900, Marc H. wrote:

I will take another approach and claim that the language
used is and will be the biggest most influencing factor.
It is exactly the reason why PHP became popular today -
it beat Perl cgi scripts. It was easier to learn than perl.
It had a good online docu. It concentrated on the web +
database aspects.

Actually, while PHP is much easier to pick up for web development for
the
majority of people who know nothing about programming and a fair bit
about (X)HTML, it’s not easier to learn in and of itself. This is
largely a side-effect of the other major reason, besides ease of
learning, that PHP has become so popular for low-end web development:
its
availability as a markup-embedded templating language is ubiquitous,
whereas in most cases working with Perl requires CGI scripts and either
SSI or generating markup from those scripts yourself.

Perl has better online documentation than PHP, in my honest opinion.
For
one thing, it’s more comprehensive and less likely to lead you astray.
It’s hard to beat perldoc (which is available on the web in addition to
being available with the standard Perl distribution).

Every language has different pros and cons, and there may be
some cases where php really has more advantages than ruby.
But in general ruby as a language is simply better than php.
That includes the world wide web, but unfortunately there
are a little problems. Rails for example, forces you to
think in the rails-way, for the good or for the bad.
(By the way, it would be cool to be able to
embed ruby straight into a .php document… right now
I am porting my legacy .php scripts to ruby, it takes
quite long :stuck_out_tongue: )

I’d rather just embed Ruby in markup for templating. Luckily, we can do
that now (with eruby).

Personally, I am a bit unhappy that PHP is compared to Rails so
often … PHP should be compared to Ruby, and then if we can,
Ruby should improve on the area where PHP has a slight edge.

What bothers me isn’t so much that PHP is compared with Rails, but that
they’re compared as if they’re the same class of thing. PHP is a
templating language. Rails is a framework that uses Ruby as its
templating language. If you’re going to compare the two, compare the
fact that with Rails you have a framework in addition to a templating
language (for good or ill) in one case and just a templating language in
the other.

Then, perhaps, talk about either PHP frameworks or ways to use Ruby as a
templating language without a framework, once you determine whether you
should be using a framework at all.

Wayne E. Seguin wrote:

On 10/1/07, Marcin R. [email protected] wrote:

I’m planning to use ORM, and use pure sql for most frequent calls (like
checking for new messages, or new stories) that are made by ajax

Marcin,
In this case I recommend also evaluating the Sequel ORM.

~Wayne

this thread is geting complicated, i ended up replaying to few people on
lots of issues, anyway in other thread i mentioned that i tested and
benchmarked popular ORM’s like AR, Og, Kansas and Sequel, i really liked
sequel and pure postgres driver.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs