Is Ruby is better than PHP

In article CB655214-93B3-11D8-ADDB-000A95676A62@pragprog.com,

···

Dave Thomas dave@pragprog.com wrote:

On Apr 21, 2004, at 11:34, Savut wrote:

Ruby and PHP are two differents thing. Ruby is used for command line
program supporting user input and run just as batch file or linux
shell script do. PHP run embedded on a webpage and it main purpose is
for website development.

Damn! I guess I’ll have to delete my 40,000 line Ruby web application
then… :slight_smile:

And I’ll have to get rid of all that Ruby/FLTK code I’ve been writing to
develop a GUI app… Bummer.

Phil

Hello Kirk,

Wednesday, April 21, 2004, 10:13:11 PM, you wrote:

The devil is in the details, but I am pretty confident that I could
support 100 sites on a 2.0 Ghz Intel server with 1GB of ram, if they were
all using Iowa to drive their dynamic content.

Thanks, my experience with amrita was going into the other direction.
Anyone ever tried the ClearSilver template system
http://www.clearsilver.net/ ?

···

--
Best regards,
Lothar mailto:mailinglists@scriptolutions.com

What is Iowa?

rolo

···

-----Original Message-----
From: Kirk Haines [mailto:khaines@enigo.com]
Sent: Thursday, April 22, 2004 1:43 AM
To: ruby-talk ML
Cc: usenets_remote_this@earthlink.net
Subject: Re: Is Ruby is better than PHP …

On Thu, 22 Apr 2004, Lothar Scholz wrote:

If you must host 100 users on a 2,0 GHz Pentium with 1 GB RAM, you
don’t have real a choice: you must use PHP.

Not necessarily. I run a very large, busy site consisting of around 250
dynamically generated pages of content using Iowa with a process size of
around 14-16Mb in size.

My personal business site is smaller, but has about 50 dynamically
generated pages served out of a process that runs around 5Mb in size.

The devil is in the details, but I am pretty confident that I could
support 100 sites on a 2.0 Ghz Intel server with 1GB of ram, if they were
all using Iowa to drive their dynamic content.

Kirk Haines

Christian Hammers wrote:

···

“Savut” webki@hotmail.com wrote:

Ruby and PHP are two differents thing. Ruby is used for command line
program supporting user input and run just as batch file or linux
shell script do. PHP run embedded on a webpage and it main purpose is
for website development.

Well I use PHP nearly only on command line as a neat Perl replacement and just saw that ruby is of course also available as embedded Apache
scripting language (mod_ruby) so you guys should better focus to the language itself instead on their original purpose :slight_smile:
(but IMHO ruby looks ugly => use php g)

-christian-

PHP on the command line as a “neat” Perl replacement. Ack!

PHP Ruby


base64_decode require ‘base64’
Base64::decode64

base64_encode require ‘base64’
Base64::encode64

Why not

string.pack(“m”); string.unpack(“m”) ??

If find this much easier

That’s all Base64::encode/decode64 does, but when glancing over code,
Base64::encode64(str) tells me more than str.pack(“m”). I was never
very good with remembering pack notation, and I’d like to think other
people are in the same boat as me.

···


Zachary P. Landau kapheine@hypa.net
GPG: gpg --recv-key 0x24E5AD99 | http://kapheine.hypa.net/kapheine.asc

As helpful as that may be to people, one of PHPs major problems (as
someone mentioned) is namespaces. I would hate to bring that over to
Ruby. It would be better to teach people to do it properly.

···

On Thu, Apr 22, 2004 at 07:04:07AM +0900, Chris Dutton wrote:

Zachary P. Landau wrote:

I think one thing people like about PHP is it comes with a lot of
built-in functions for dealing with Web-related problems. It might be
an interesting project for someone to make a list of common PHP
functions used in web developments, with their Ruby equivalent
(including what library it comes from).

Or even going a step farther, create a module that’s nothing but
wrappers around those methods/classes.

require “php-transition”

plain = base64_decode(source)

actually is:

plain = Base64::decode64(source)

Though I have a feeling that having both PHP and Ruby targetting Parrot
would make this significantly easier, as long as the PHP functions are
implemented in a modular way.


Zachary P. Landau kapheine@hypa.net
GPG: gpg --recv-key 0x24E5AD99 | http://kapheine.hypa.net/kapheine.asc

There was a posting in this group that told the story of a PHP
application
rewritten in Ruby with significantly less lines of code plus it was
considerably faster. Dunno the ref though.

I’d like to sign up for that claim. Rails[1] was a PHP framework before
I moved to Ruby. And what a difference. Ruby has so much better support
for introspection and run-time modification that making a framework
becomes a whole other ball game.

Equally so for the applications I’ve developed on Rails, most notably
Basecamp[2]. They’re much more readable, requires far less code, and
often times is faster.

Note that “faster” is compared to the PHP version of Rails that tried
its best to make use of the clunky OOP support that language offers.
I’m sure you can handcode something in PHP without objects that’s just
as fast.

[1] http://www.rubyonrails.org/ (still just a teaser site, more coming
soon)
[2] http://www.basecamphq.com/

···


David Heinemeier Hansson,
http://instiki.nextangle.com/ – A No-Step-Three Wiki in Ruby
http://www.basecamphq.com/ – Web-based Project Management
http://www.loudthinking.com/ – Broadcasting Brain

Ruby and PHP are two differents thing. Ruby is used for command line
program supporting user input and run just as batch file or linux
shell script do. PHP run embedded on a webpage and it main purpose is
for website development.

Well I use PHP nearly only on command line as a neat Perl replacement

Holy crap - you must love > and < characters…

(but IMHO ruby looks ugly => use php g)

There’s nowt queer as folk…

···

“Savut” webki@hotmail.com wrote:


This fortune intentionally not included.
Rasputin :: Jack of All Trades - Master of Nuns

messju mohr messju@lammfellpuschen.de writes:

···

On Thu, Apr 22, 2004 at 09:39:08PM +0900, Dave Brown wrote:

In article 1441333312.20040421215228@scriptolutions.com,
Lothar Scholz mailinglists@scriptolutions.com wrote:
: UN> So, what’s the drawback of leaving PHP and embrace Ruby as web programming
: UN> tools?
:
: If you must host 100 users on a 2,0 GHz Pentium with 1 GB RAM, you
: don’t have real a choice: you must use PHP.

Assuming that all 100 users agree on what PHP syntax to use.

Have you looked at /etc/php.ini? It’s a single, global configuration
file, and it controls all kinds of aspects of the language.

Have you looked at the docs? One can set set php.ini-values per
server, per virtualhost, per directory and per script. No user has to
agree with any other user.

Please don’t let this become such a useless php-vs-ruby-bashing-
thread.

Awww … what a spoilsport. I was just getting ready to start these
threads:

Is Ruby better than RPG 1?
Is Ruby better than Intercal (The INTERCAL Resources Page)?
Is Ruby better than the high-priced spread?
Is Ruby better than my cat?


Lloyd Zusman
ljz@asfast.com

Phil Roberts philrob@HOLYflatnetSHIT.net wrote in message news:Xns94D2B9FA3592Ephilroberts@216.196.97.132

With total disregard for any kind of safety measures “Savut”
webki@hotmail.com leapt forth and uttered:

Ruby and PHP are two differents thing. Ruby is used for command
line program supporting user input and run just as batch file or
linux shell script do. PHP run embedded on a webpage and it
main purpose is for website development.

Hardly.

Ruby can be used for shell scripting, GUI application programming
(there are 3 GUI toolkits available that I know of) and Web CGI
scripting. It’s a very flexible language with a very nice syntax.

Arachno Ruby IDE and Distribution at http://www.ruby-ide.com comes
bundeled with out of the box working FOX,TK,FLTK,WXRuby and the
standart Win32 GUI Toolkit.

Its also the easiest way to develop CGI Scripts with Ruby because it
automatically starts an apache that is correctly configured and let
you debug your CGI’s.

If I am understanding you correctly, you missed the point of most of the
replies to your first post. Ruby isn’t specifically designed as a web
programming language. However, it works very well for that purpose.
There are a lot of people who use it daily for that purpose, and there are
a number of people, including myself, who have software that we have
developed specifically for web development. The list of these packages is
really quite long.

Kirk Haines

···

On Thu, 22 Apr 2004, Useko Netsumi wrote:

It is very unfortunate that this nice young language does not consider the
web development in mind. I even think that if and only if Ruby creator ever
think this thru by including web design in mind, Ruby can easily gain its
popularity against PHP and Java because of its ease of use features, its
consistency, its OO paradigm, and many.

Is there any work being done to cater specifically for web development?

In article c66asi$81tsi$1@ID-205437.news.uni-berlin.de,

It is very unfortunate that this nice young language does not consider the
web development in mind.

Well, you know how it is with these young languages. They’re just too
carefree to consider the serious stuff. They just want to have fun :wink:

Seriously, there is a lot of web development work being done in ruby and
some very nice frameworks have been and are being developed.

I even think that if and only if Ruby creator ever
think this thru by including web design in mind, Ruby can easily gain its
popularity against PHP and Java because of its ease of use features, its
consistency, its OO paradigm, and many.

Is there any work being done to cater specifically for web development?

I’m not an expert in Web development by any stretch, but here are a few
pointers:

cgikit http://www.spice-of-life.net/cgikit/index_en.html
CGIKit is a web application framework like Apple Computer’s WebObjects.
This framework services Model-View-Controller architecture programming by
component based on a HTML file, a definition file and a Ruby source.

arrow http://rubycrafters.com/projects/Arrow/
Arrow is a framework for building web applications using Apache and
mod_ruby.

borges http://borges.rubyforge.org
Borges is a modal web application framework that keeps track of
state, so you can go back and undo or redo operations.

rails Ruby on Rails — A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.
Rails is a soon-to-be-released web-application framework for Ruby. It’s
built upon well-understood patterns which should make the seasoned web
developer feel right at home and the new comer welcome.
Full-stack framework: Model, View, and Control
Rails is a composition of three sub-projects that make up the Model, View,
and Control tiers. This means that most web applications shouldn’t need
to assemble anything else to get off the ground.

…there are more like Amrita, but this should be enough to get you
started.

Phil

···

Useko Netsumi usenets_remote_this@earthlink.net wrote:

Iowa is a framework that was originally written a couple of years ago by
Avi Bryant. He worked on it for a while before abandoning it to work on
his next generation framework, Seaside, on SmallTalk.

I’ve been using and developing on it for about two years. I use the heck
out of it and have made a lot of changes from where Avi left it.

Basically, it’s a system that seperates content from code, handles
sessions and variable transfer and all of that server side, represents
content as objects which are components that can be placed inside of other
components to build web pages, letting one create reusable widgets. My
site, http://enigo.com, is done using Iowa. The navigation on the left is
a single component, as an example.

I have in the CVS at RubyForge code that is very close to what I am
running in production, but haven’t done a release yet because I really
hate the thought of releasing while my documentation still sucks. I’m
trying very hard to finish the docs up ASAP, though, at least enough so
that someone checking it out has some help.

Oh, it runs just fine on Ruby 1.6.7 and up. It might run on 1.6.4, too,
but I have never tested that.

I have to run; need to take my daughter to something. If you have any
more questions, I can follow up later.

Kirk Haines

···

On Thu, 22 Apr 2004, rolo wrote:

What is Iowa?

Hello Zachary,

Thursday, April 22, 2004, 12:24:46 AM, you wrote:

Zachary P. Landau wrote:
>I think one thing people like about PHP is it comes with a lot of
>built-in functions for dealing with Web-related problems. It might be
>an interesting project for someone to make a list of common PHP
>functions used in web developments, with their Ruby equivalent
>(including what library it comes from).

Or even going a step farther, create a module that's nothing but
wrappers around those methods/classes.

require "php-transition"

plain = base64_decode(source)
# actually is:
# plain = Base64::decode64(source)

Though I have a feeling that having both PHP and Ruby targetting Parrot
would make this significantly easier, as long as the PHP functions are
implemented in a modular way.

As helpful as that may be to people, one of PHPs major problems (as
someone mentioned) is namespaces. I would hate to bring that over to
Ruby. It would be better to teach people to do it properly.

This is not the major problem of PHP. The major problem is that you
always start with an empty universe and must reread all data on each
page.

In Ruby you have also a really huge namespace problem comming from the
fact that library developer A adds some feature here and there, for
example some nice string tokenizer called "fast_tokenizer" etc. and
developer B does the same with his version.

So PHP has one namespace problem which is so obvious that people try
to avoid this by using prefixes. It is hard to explain the same
problem to ruby developers.

···

On Thu, Apr 22, 2004 at 07:04:07AM +0900, Chris Dutton wrote:

--
Best regards,
Lothar mailto:mailinglists@scriptolutions.com

Well, so do I.

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/86925

And I wasn’t even trying to use OOP. It’s basically just one big
function fiddling around with some strings and arrays.

···

On Thu, Apr 22, 2004 at 07:10:06PM +0900, David Heinemeier Hansson wrote:

There was a posting in this group that told the story of a PHP
application
rewritten in Ruby with significantly less lines of code plus it was
considerably faster. Dunno the ref though.

I’d like to sign up for that claim.


Thomas
beast@system-tnt.dk

eRuby – embedded ruby in HTML
mod_ruby – embed Ruby in Apache
ruby-fcgi – Run Ruby as a FastCGI process
webrick – Ruby’s native web and network server classes
fcgi-webrick – the bridge I wrote to use the Webrick API under FastCGI
amrita – a nice templating system that I adore
kwartz – another templating system
borges – a continuation-based web development platform, so programming
is more linear than CGI usually permits

I’ve given up PHP – Code that’s monstrous in PHP can be simple in Ruby.
Add in that if I design properly, with a separate set of classes or
methods for business logic, I can then convert into a native GUI app at
some point (As I intend to do with my latest app).

The high points for me about Ruby for web development: The encouragement
to use clean solutions like templating, and the string interpolation.
I’m fond of replacing PHP-ish this:

$a = do_something();
$b = do_something_else();
print(“$b”);

with a ruby this:

puts “#{do_something_else}

Uniform access is a wonder.

Ari

···

On Thu, Apr 22, 2004 at 02:29:06AM +0900, Useko Netsumi wrote:

It is very unfortunate that this nice young language does not consider the
web development in mind. I even think that if and only if Ruby creator ever
think this thru by including web design in mind, Ruby can easily gain its
popularity against PHP and Java because of its ease of use features, its
consistency, its OO paradigm, and many.

Is there any work being done to cater specifically for web development?

There are projects supporting MVC pattern:
http://www.starware.one.pl/software/sws/index.html
http://outerbody.com/ruby/roach/

as well as some other cgi/mod-ruby templating systems
(including eruby which uses the well known <% %> markers):

comparison is given at:
http://www.kuwata-lab.com/ruby/kwarts/benchmark.html

Marcin

“Thomas Fini Hansen” beast@system-tnt.dk schrieb im Newsbeitrag
news:20040422130547.GQ856@saber.xen.dk…

···

On Thu, Apr 22, 2004 at 07:10:06PM +0900, David Heinemeier Hansson wrote:

There was a posting in this group that told the story of a PHP
application
rewritten in Ruby with significantly less lines of code plus it was
considerably faster. Dunno the ref though.

I’d like to sign up for that claim.

Well, so do I.

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/86925

That’s exactly the posting I was referring to. Thanks for digging that
up!

Kind regards

robert

Release it! Users will help you build much better documentation
than you could easily write yourself, since they’ll ask questions about
what they want to know. This way you write the useful documents first.

At least, its worked that way for Borges. (And they’ve spotted lots of
bugs, and helped fix them.)

···

Kirk Haines (khaines@enigo.com) wrote:

I have in the CVS at RubyForge code that is very close to what I am
running in production, but haven’t done a release yet because I really
hate the thought of releasing while my documentation still sucks. I’m
trying very hard to finish the docs up ASAP, though, at least enough so
that someone checking it out has some help.


Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

Hello Aredridel,

Your example is very bad: try this:

puts “#{do_something_else}
echo “<a href=”.do_something().’>’.do_something_else().””

So you need only 4 characters more in PHP.

The only real advantage in using ruby/python (or java) comes from
using program structure features and persistent non session data
storage, but you can’t demonstrate them in a simple few
lines example.

···


Best regards,
Lothar mailto:mailinglists@scriptolutions.com