Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Ruby vs. PHP

Reply
Thread Tools

Ruby vs. PHP

 
 
Marcin Raczkowski
Guest
Posts: n/a
 
      10-01-2007
> 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
>
> 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)

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.


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

 
Reply With Quote
 
 
 
 
Marcin Raczkowski
Guest
Posts: n/a
 
      10-01-2007
Wayne E. Seguin wrote:
> On 10/1/07, Marcin Raczkowski <(E-Mail Removed)> 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.

>
> <snip>
>
> 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

 
Reply With Quote
 
 
 
 
Richard Conroy
Guest
Posts: n/a
 
      10-01-2007
On 10/1/07, Marcin Raczkowski <(E-Mail Removed)> wrote:
> Richard Conroy 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.

> >
> > 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,


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.

 
Reply With Quote
 
Marcin Raczkowski
Guest
Posts: n/a
 
      10-01-2007
> 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

 
Reply With Quote
 
7stud --
Guest
Posts: n/a
 
      10-01-2007
Marcin Raczkowski 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.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Marcin Raczkowski
Guest
Posts: n/a
 
      10-01-2007
Wayne E. Seguin wrote:
> On 10/1/07, Marcin Raczkowski <(E-Mail Removed)> 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.

 
Reply With Quote
 
Chad Perrin
Guest
Posts: n/a
 
      10-01-2007
On Tue, Oct 02, 2007 at 01:29:57AM +0900, Marc Heiler 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 )


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.

--
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
awj @reddit: "The terms never and always are never always true."

 
Reply With Quote
 
Gaurang Khetan
Guest
Posts: n/a
 
      10-01-2007
Hello experts,

I thought this topic was quite related so posted in this same thread..

We are going to start a new website (serving videos but several database
intensive features as well), and we think it will hopefully reach a
stage where scalability is going to become important.

Hence I wanted some idea abt speed..

I checked several benchmarks online between PHP, Python and Ruby, and
found that Python is a strong winner here, with PHP and Ruby about
distant second. However with Ruby 2.0, I read that it will use a
bytecode compiler YARV, which will make it significantly faster than its
current implementation Ruby 1.8... ?

My question:
1. When can I reasonably expect a stable Ruby 2.0 release..
2. Are there any benchmarks as to how will it compare to PHP and Python
in run speed?

-Gaurang.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
John Joyce
Guest
Posts: n/a
 
      10-01-2007
> . PHP is a
> templating language.

PHP actually is a full-fledged programming language.

I think one of the reasons it took off so well is that its syntax is
very C-like so many computer science grads feel right at home with it
after being taught C/C++/Java for so long. It takes less of a leap
for them to start using it than would Perl or Ruby.

The worst thing to me about PHP is its object implementation and
overuse of sigils.

Regarding the sigils and syntax, Ruby shows that if you have an
identifier that is not already used in some other capacity, then it
is enough to say it is a variable or object or a function that takes
no arguments. A function is generally obviously a function, if it
takes no arguments then it doesn't need parentheses ! If it is
method it will be appended to an object's identifier. This is the
core of Ruby's gracefulness. Why should we have to type more than we
need to?

That said, there is something to be said for explicitness in
programming. If it's necessary and appropriate it is good.
PHP as a language is pretty explicit most of the time, but to the
point of being arguably less legible. But many programmers are overly
accustomed to bending over backwards for code that is less legible (C/
C++ in many cases) or abusively explicit (Java) to the point of
redundancy.

But in the end, none of this matters, it is up to you to try a
language and see if you like it, see if it works for what you need.
You're not likely going to write an OS in Ruby, but you could write a
DSL that might make that easier to do. You're also not likely going
to do server side scripting in COBOL, but you probably could do it
somehow if you really wanted to, and you'd be able to connect to some
legacy systems older than you.

 
Reply With Quote
 
Marcin Raczkowski
Guest
Posts: n/a
 
      10-01-2007
Gaurang Khetan wrote:
> Hello experts,
>
> I thought this topic was quite related so posted in this same thread..
>
> We are going to start a new website (serving videos but several database
> intensive features as well), and we think it will hopefully reach a
> stage where scalability is going to become important.
>
> Hence I wanted some idea abt speed..
>
> I checked several benchmarks online between PHP, Python and Ruby, and
> found that Python is a strong winner here, with PHP and Ruby about
> distant second. However with Ruby 2.0, I read that it will use a
> bytecode compiler YARV, which will make it significantly faster than its
> current implementation Ruby 1.8... ?
>
> My question:
> 1. When can I reasonably expect a stable Ruby 2.0 release..

december
> 2. Are there any benchmarks as to how will it compare to PHP and Python
> in run speed?

there are few benchmarks, but it's really hard to compare two langues as
i found out ^^



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Training Institute In Delhi, Live Projects on PHP. Short TermPHP Courses, PHP Scripts, PHP Training with Live Projects. Rajive Narain Java 0 09-18-2009 10:47 AM
Learn how to edit php pages with free php editor torque63 HTML 0 01-01-2009 03:45 AM
Ruby equivalence for php include("file.php"); Miquel Oliete Ruby 4 03-07-2008 06:33 PM
RE: php and python: how to unpickle using PHP? Ted Zeng Python 0 10-13-2006 12:11 AM
php and python: how to unpickle using PHP? Ted Zeng Python 4 10-03-2006 03:07 PM



Advertisments