Is Ruby is better than PHP ...

M

Matt O'Toole

Useko said:
So, what's the drawback of leaving PHP and embrace Ruby as web
programming tools?

All the code already written in PHP...

If you want to write everything from scratch, use whatever turns you on.

Matt O.
 
R

Robert Klemme

Paul Vudmaska said:
What you get with PHP is maturity and speed and a dirty namespace.

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.

Regards

robert
 
D

David Heinemeier Hansson

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/
 
D

Dave Brown

: 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. For
example, the syntax:

; Use Sybase-style magic quotes (escape ' with '' instead of \').
magic_quotes_sybase = Off

Or the CGI-parsing behaviour:

; This directive describes the order in which PHP registers GET, POST, Cookie,
; Environment and Built-in variables (G, P, C, E & S respectively, often
; referred to as EGPCS or GPC). Registration is done from left to right, newer
; values override older values.
variables_order = "EGPCS"

Change that and some of the scripts stop working and some of the scripts
start working. And someone who tests their scripts on their home system
with a php.ini that slightly differs from yours will have all kinds of
problems. Try to install an app which requires a change to your php.ini
and you could break everyone else's code.

And don't get me started on why there isn't an equivalent of DBI, or how
optimization patches aren't accepted into the open-source PHP codebase
(because that would compete with Zend) or why you have a choice of more
than 20 different functions just to do search-and-replace, or any number
of other things.

I'm in the process of banishing PHP from my web site. I tried. It
didn't work out. It's just too painful to work with any more. The
actual amount of code that I have to write has practically collapsed;
I've gone from multi-hundred-line PHP source files to tens-of-lines Ruby
source files. Most of my source files I can now fit onto a single
(50-line) xterm. Life is so much easier now, and I can spend my time
doing what I want to instead of fighting with the language.

--Dave
 
M

messju mohr

: 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.
 
L

Lloyd Zusman

messju mohr said:
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 (http://www.catb.org/~esr/intercal)?
Is Ruby better than the high-priced spread?
Is Ruby better than my cat?
 
A

Aredridel

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?

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("<a href='$a'>$b</a>");

with a ruby this:

puts "<a href='#{do_something}'>#{do_something_else}</a>"

Uniform access is a wonder.

Ari
 
L

Lothar Scholz

Hello Aredridel,


Your example is very bad: try this:

puts "<a href='#{do_something}'>#{do_something_else}</a>"
echo "<a href=".do_something().'>'.do_something_else()."</a>"

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.
 
L

Lothar Scholz

Phil Roberts said:
With total disregard for any kind of safety measures "Savut"


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.
 
A

Andreas Schwarz

Aredridel said:
amrita -- a nice templating system that I adore

I tried to use amrita for my web forum, but eventually gave up because
there are annoying bugs, development seems to be dead, amrita is
unnecessary complex and slow, the amrita interpreter requires huge
amounts of memory, and the amcc compiler generates incredibly bloated
code.
kwartz -- another templating system

kwartz's concept is not as "clean" as amrita, but it is much more
pragmatic. Instead of a CPU & memory intensive parser/VM at runtime it
can generate simple ruby code.
 
L

Lothar Scholz

Hello Andreas,

Saturday, April 24, 2004, 2:04:07 PM, you wrote:


AS> I tried to use amrita for my web forum, but eventually gave up because
AS> there are annoying bugs, development seems to be dead, amrita is
AS> unnecessary complex and slow, the amrita interpreter requires huge
AS> amounts of memory, and the amcc compiler generates incredibly bloated
AS> code.

AS> kwartz's concept is not as "clean" as amrita, but it is much more
AS> pragmatic. Instead of a CPU & memory intensive parser/VM at runtime it
AS> can generate simple ruby code.

Ever tried ClearSilver ?
 
A

Andreas Schwarz

Lothar said:
Saturday, April 24, 2004, 2:04:07 PM, you wrote:



AS> I tried to use amrita for my web forum, but eventually gave up because
AS> there are annoying bugs, development seems to be dead, amrita is
AS> unnecessary complex and slow, the amrita interpreter requires huge
AS> amounts of memory, and the amcc compiler generates incredibly bloated
AS> code.


AS> kwartz's concept is not as "clean" as amrita, but it is much more
AS> pragmatic. Instead of a CPU & memory intensive parser/VM at runtime it
AS> can generate simple ruby code.

Ever tried ClearSilver ?

Not yet, but it looks very interesting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,825
Members
47,371
Latest member
Brkaa

Latest Threads

Top