How's ruby compare to it older brother python

H

Hunn E. Balsiche

in term of its OO features, syntax consistencies, ease of use, and their
development progress. I have not use python but heard about it quite often;
and ruby, is it mature enough to be use for developing serious application,
e.g web application as it has not many features in it yet.

I've given up on Perl for its ugly syntax and it is not the easiest language
to learn. How about PHP?

Thanks
 
M

Michael

in term of its OO features, syntax consistencies, ease of use, and their
development progress. I have not use python but heard about it quite often;
and ruby, is it mature enough to be use for developing serious application,
e.g web application as it has not many features in it yet.

I've given up on Perl for its ugly syntax and it is not the easiest language
to learn. How about PHP?
IMO Ruby is closer to Perl than Python as far as clearness of it's
syntax. I really like Python better. PHP isn't as garbled as Perl but it
isn't as flexible either and it's still not nearly as clean as Python.
Of the four languages (Perl, Python, PHP, and Ruby) I find Python the
easiest to work in. I use Python for command-line programming, web
programming (mod_python), and GUI programming (wxPython and Pygame) and
find it a good general purpose language.
 
P

Peter Maas

Hunn said:
I've given up on Perl for its ugly syntax and it is not the easiest language
to learn. How about PHP?

I forgot http://dada.perl.it/shootout, which is great for performance
comparisons. Source code of the tests can be viewed easily to get a
feeling for the strengths and weaknesses of the syntax as well.

Mit freundlichen Gruessen,

Peter Maas
 
L

Leif B. Kristensen

Hunn said:
in term of its OO features, syntax consistencies, ease of use, and
their development progress. I have not use python but heard about it
quite often; and ruby, is it mature enough to be use for developing
serious application, e.g web application as it has not many features
in it yet.

I've given up on Perl for its ugly syntax and it is not the easiest
language to learn. How about PHP?

It really depends on what you'll want to do. PHP is a great language for
getting dynamic HTML pages up and running quickly. Perl is great for
its string-handling abilities. (On my Web pages, I actually call a Perl
script from PHP precisely for this reason.)

However, both PHP and Perl can be very unwieldy for large projects. I'm
a newcomer to Python, but it seems to scale much better than the other
P-languages.

For a first tour of Python, I'll suggest that you read the excellent
tutorial by the language's author, Guido van Rossum:

http://www.python.org/doc/current/tut/

regards,
 
J

John Roth

Hunn E. Balsiche said:
in term of its OO features, syntax consistencies, ease of use, and their
development progress. I have not use python but heard about it quite often;
and ruby, is it mature enough to be use for developing serious application,
e.g web application as it has not many features in it yet.

As another poster has mentioned, Ruby is more closely related
to Perl than to Python. While I don't use it, people I respect who
have moved to Ruby say it has a couple of real killer features;
in particular the way blocks and the pervasive use of the visitor
pattern come together change the way one writes programs for
the better.

As far as syntax is concerned, there doesn't seem to be a
huge amount of difference. Syntax is syntax, and every language
has it's little pecularities.

I haven't seen enough of it to make me want to learn it, but it's
on my list of languages to play with sometime.

John Roth
 
B

Bruno Desthuilliers

Hunn said:
in term of its OO features, syntax consistencies, ease of use, and their
development progress. I have not use python but heard about it quite often;
and ruby, is it mature enough to be use for developing serious application,
e.g web application as it has not many features in it yet.

Syntax : both Ruby and Python are pretty clean, Ruby being IMHO more
consistent and Python easier to grasp

OO : Ruby is OO all the way, and pretty close to Smalltalk. Python is
more a mix of procedural and OO with some functional stuff too.

Web : Python may have a bit more existing solutions, and a real killer
app (Zope). Now, AFAIK, Ruby has also some interesting stuff for web
developpement.

IMHO, both are really great languages. I really like the elegance of
Ruby and the ease of use of Python. So try both and pick the one that
fits you're brain !-)
I've given up on Perl for its ugly syntax and it is not the easiest language
to learn.

No comment...
How about PHP?
<troll>
One of the dumbest 'scripting' language I've ever worked with, but still
a good solution for web developpement when you have no better (read :
Python or Ruby) choice.
</troll>

Bruno
 
C

Cameron Laird

.
.
.
getting dynamic HTML pages up and running quickly. Perl is great for
its string-handling abilities. (On my Web pages, I actually call a Perl
script from PHP precisely for this reason.)
.
.
.
I hear this more often than I understand it. Perl certainly
does support many string-oriented operations. What's a speci-
fic example, though, of an action you feel more comfortable
coding in external Perl? I suspect there's something I need
to learn about PHP's deficiencies, or Perl's power.
 
L

Leif B. Kristensen

Cameron Laird rose and spake:
.
I hear this more often than I understand it. Perl certainly
does support many string-oriented operations. What's a speci-
fic example, though, of an action you feel more comfortable
coding in external Perl? I suspect there's something I need
to learn about PHP's deficiencies, or Perl's power.

I'm glad that you asked :)

The routine is for a phonetic search in Norwegian 18th century names,
which can be spelled in an amazing number of different ways. As I found
that the Soundex algorithm was useless for Norwegian spellings, I
invented my own. It's not really an algorithm, but a series of
substitutions that reduces names to a kind of primitives. Thus, eg.
Berthe, Birthe, Bergitte, Bergit, Birgit, Børte, Berit, and Brit, which
actually are interchangeable spellings of the same name, are reduced to
BRT.

Here's a small sample:

$str =~ s/HN/N/g; # John --> JON
$str =~ s/TH/T/g; # Thor --> TOR
$str =~ s/CHI/KJ/g; # Torchild --> TORKJL
$str =~ s/CHE/KJ/g; # Michel --> MKJL
$str =~ s/KKE/KJ/g; # Mikkel --> MKJL
$str =~ s/KIEL/KJL/g; # Kield -> Kjeld ( --> KJL)
$str =~ s/CH/K/g; # Christen -> Kristen ( --> KRSTN)
$str =~ s/CA/KA/g; # Carl -> Karl ( --> KAL)
$str =~ s/RL/L/g; # Thorleif <=> Tollef <=> Tolf ( --> TOLF)

I use a Perl script to transform my genealogy data from a FoxPro
database to MySQL command scripts. Thanks to the excellent module
DBD::XBase by Jan Pazdziora, this is a quite simple task.

In theory, the web routine for phonetic searches might have been
implemented in PHP. The trouble with that is that I would have to
maintain both a PHP and a Perl version of the same routine. I find it
much easier to just copy and paste the whole mess (at present about 120
lines) between the encoding and the decoding routines in Perl, and run
an exec("perl norphon.pl $name") from PHP.

regards,
 
P

Phil Tomson

As another poster has mentioned, Ruby is more closely related
to Perl than to Python. While I don't use it, people I respect who
have moved to Ruby say it has a couple of real killer features;
in particular the way blocks and the pervasive use of the visitor
pattern come together change the way one writes programs for
the better.

As far as syntax is concerned, there doesn't seem to be a
huge amount of difference. Syntax is syntax, and every language
has it's little pecularities.

Well, there is one big difference syntactically: Python uses indentation
as syntax and Ruby doesn't. Personally I don't prefer Python's
'indentation-as-syntax' since it means that syntactically significant
pieces of my code are invisible and if the tab settings in my editor are
not the same as yours it can make it difficult to share code (or even
worse, it might look like everything is OK when we share code, but the
code which looks exactly the same to each of us, might not be depending
on how tabs are or are not expanded). It would also seem to be a pain for
cutting & pasting code as well.
However, some people really like Python's indentation-as-syntax, so YMMV.

Your best bet is to actually use each language for a small project
so that you spend about a day with each language. You'll find that while
on the surface both languages seem quite similar, at a deeper level they
each have a very different effect on how you think about and approach the
problem. Some people find that Ruby best fits with their brain and others find
Python a better fit. You won't know until you try.

Phil
 
C

Cameron Laird

.
.
.
which can be spelled in an amazing number of different ways. As I found
that the Soundex algorithm was useless for Norwegian spellings, I
invented my own. It's not really an algorithm, but a series of
substitutions that reduces names to a kind of primitives. Thus, eg.
.
.
.
"Canonicalization" is one name in academic English for this transformation.
 
C

Cameron Laird

.
.
.
The routine is for a phonetic search in Norwegian 18th century names,
which can be spelled in an amazing number of different ways. As I found
that the Soundex algorithm was useless for Norwegian spellings, I
invented my own. It's not really an algorithm, but a series of
substitutions that reduces names to a kind of primitives. Thus, eg.
Berthe, Birthe, Bergitte, Bergit, Birgit, Børte, Berit, and Brit, which
actually are interchangeable spellings of the same name, are reduced to
BRT.

Here's a small sample:

$str =~ s/HN/N/g; # John --> JON
$str =~ s/TH/T/g; # Thor --> TOR
$str =~ s/CHI/KJ/g; # Torchild --> TORKJL
$str =~ s/CHE/KJ/g; # Michel --> MKJL
$str =~ s/KKE/KJ/g; # Mikkel --> MKJL
$str =~ s/KIEL/KJL/g; # Kield -> Kjeld ( --> KJL)
$str =~ s/CH/K/g; # Christen -> Kristen ( --> KRSTN)
$str =~ s/CA/KA/g; # Carl -> Karl ( --> KAL)
$str =~ s/RL/L/g; # Thorleif <=> Tollef <=> Tolf ( --> TOLF)

I use a Perl script to transform my genealogy data from a FoxPro
database to MySQL command scripts. Thanks to the excellent module
DBD::XBase by Jan Pazdziora, this is a quite simple task.

In theory, the web routine for phonetic searches might have been
implemented in PHP. The trouble with that is that I would have to
maintain both a PHP and a Perl version of the same routine. I find it
much easier to just copy and paste the whole mess (at present about 120
lines) between the encoding and the decoding routines in Perl, and run
an exec("perl norphon.pl $name") from PHP.
.
.
.
Long ago, I was myself involved in a tiny way with
parish records for Finnmark and Troms. I wish I'd
been able to do more ...

I'm glad things are working for you. I'm all for
not-duplicating effort. Do you realize you can use
PHP from the command line? As I understand your
explanation, it doesn't reflect AT ALL on a defici-
ency in PHP string-handling; to my eye, PHP can do
the operation just about as well as Perl.

Incidentally, Tcl has a one-liner for this, along
the lines of
set str [string map {HN N TH T CHI KJ CHE KJ ...} $str]
I believe Perl does, too, but haven't enough interest
to track it down now. I'm also confident we can find
a language which makes the particular operation even
more transparent.

I continue to conclude that all these languages are
roughtly equally competent at managing strings.
 
C

Cameron Laird

.
.
.
Your best bet is to actually use each language for a small project
so that you spend about a day with each language. You'll find that while
on the surface both languages seem quite similar, at a deeper level they
each have a very different effect on how you think about and approach the
problem. Some people find that Ruby best fits with their brain and others find
Python a better fit. You won't know until you try.
.
.
.
It's not just that "You won't know until you try" ("is it better
to have children, or join the monastery?"); it's that you won't
know until you try, *and it's inexpensive to try*! It's eminently
feasible to gain experience in either language with a few hours (!)
of work, as opposed to the weeks that must precede enlightenment
about, say, J2EE servers.
 
J

John Roth

Phil Tomson said:
Well, there is one big difference syntactically: Python uses indentation
as syntax and Ruby doesn't. Personally I don't prefer Python's
'indentation-as-syntax' since it means that syntactically significant
pieces of my code are invisible and if the tab settings in my editor are
not the same as yours it can make it difficult to share code (or even
worse, it might look like everything is OK when we share code, but the
code which looks exactly the same to each of us, might not be depending
on how tabs are or are not expanded). It would also seem to be a pain for
cutting & pasting code as well.

As I said in another post, indentation is the reason I learned
Python in the first place, but it's not the reason I stay with
the language. In fact, I've come to the very heretical view
that the indentation sensitivity is a language design mistake.
It should be the editor's job to handle that level of detail in
a manner that the developer finds workable.

One reason I think it's a language design mistake is that
it's not recursive. That is, it's not possible to shift from
expression level indentation back to statement level
indentation without major disruptions. This is needed for
embedded blocks.

I think Ruby has a reasonable middle ground here: its use of
'end' is fairly unobtrusive compared to, for example, C, C++,
C# or Java. Even so, I think that a reasonable programming
editor would get them out of my face while I was programming.

The tab issue is one of those relatively inconsequential things
that people seem to love to argue about: I'd rather be able to
tell the editor how I want the program formatted, and have done
with it.
 
L

Leif B. Kristensen

Cameron Laird rose and spake:
Long ago, I was myself involved in a tiny way with
parish records for Finnmark and Troms. I wish I'd
been able to do more ...

That's very interesting from my point of view. Starting this autumn, by
the way, the Norwegian National Archive will begin to publish scanned
images of parish records on the Web. They plan to finish this job in a
couple of years, and then go on to other popular sources for
genealogists, such as probates, court records, and land transactions.
I'm glad things are working for you. I'm all for
not-duplicating effort. Do you realize you can use
PHP from the command line? As I understand your
explanation, it doesn't reflect AT ALL on a defici-
ency in PHP string-handling; to my eye, PHP can do
the operation just about as well as Perl.

It probably could, but at the time I wrote my FoxPro extraction script I
was very much into Perl. I was very happy to find the XBase module, and
besides, I have been unable to find something similar in any other
language that I have more than a nodding aquaintance with.
I continue to conclude that all these languages are
roughtly equally competent at managing strings.

Perhaps, but right now I think that I'm in love with Python. Consider
these two equivalent routines in PHP and Python:

PHP:
function get_place($x) {
$query = "select pl1, pl2, pl3, pl4, pl5
from places where place_id = $x";
$handle = mysql_query($query);
$row = mysql_fetch_row($handle);
$pl_string = '';
if ($p_num == 1) return '';
$i = 0;
for ($j = 0; $j<5; $j++) {
if ($row[$j] != '' && substr($row[$j], 0, 1) != '-') {
$pl[$i] = $row[$j];
$i++;
}
}
for ($j = 0; $j < ($i-1); $j++)
$pl_string .= $pl[$j].', ';
$pl_string .= $pl[$i-1];
return ltrim(rtrim($pl_string));
}

Python:
def get_place(x):
c=db.cursor()
c.execute("select pl1, pl2, pl3, pl4, pl5
from place where place_id = %d" % (x))
result=c.fetchone()
return ', '.join([p for p in result if p and p[0] != '-'])

Consider that my entire Web site is written in PHP. I stumbled across
Python just a few weeks ago, and got substantial help with the latter
version of the routine from Paul Rubin on this list.

My PHP coding may be suboptimal, but in terms both of codability and
readability as well as in sheer elegance, I find the Python version
superior in any way.

regards,
 
C

Cameron Laird

Cameron Laird rose and spake: .
.
.

Perhaps, but right now I think that I'm in love with Python. Consider
these two equivalent routines in PHP and Python:
.
[marvelous, if
slightly unfair,
example]
.
.
My PHP coding may be suboptimal, but in terms both of codability and
readability as well as in sheer elegance, I find the Python version
superior in any way.
.
.
.
I consider infatuation with Python entirely healthy. In
fact, I often *do* argue just the same position as you
take here: that Python is strongly and demonstrably superior
to PHP. I just want to be as precise as I can about what the
differences are.
 
B

Brandon J. Van Every

Cameron said:
.
It's not just that "You won't know until you try" ("is it better
to have children, or join the monastery?"); it's that you won't
know until you try, *and it's inexpensive to try*! It's eminently
feasible to gain experience in either language with a few hours (!)
of work, as opposed to the weeks that must precede enlightenment
about, say, J2EE servers.

Of course, those of us who are more into the Complete Waste Of Time [TM]
theory of selecting software components will simply give you the bottom
line:

- If you like Perl, you'll like Ruby. If you think Perl is a bletcherous
hack, you'll like Python.
- The Python community dwarfs the Ruby community.
- Both languages are slow.
- Python has lotsa libraries but not everything. Ask here regarding your
specific needs. Even if Python were the most elegant language in the world,
that's not useful if you must write everything from scratch and don't have
time to do it.

This is the kind of information you get by simply asking people and reading
lotsa archives. Some people say "Try it yourself!" is the only way to
learn. They are wrong, and they often don't value people's time. You
really can rely on other people's reported experiences of the nuclear
mushroom cloud exploding over the horizon. It is not strictly necessary to
walk into Ground Zero yourself.

Now, if you're going to argue "it's just a little Ruby code..." why don't
you try multiplying that by all the languages in the comp.lang.* hierarchy
that you could potentially be selecting from? Take a spin by the Language
Shootouts if you want to spin your head some more.
http://www.bagley.org/~doug/shootout/
http://dada.perl.it/shootout/
You need a filter of some kind for cutting down the options. I suggest
asking people, and seeing what languages actually got used for jobs relevant
to your software problem / industry.

I'm waiting for someone to say that my participation in this thread
constitutes trolling. I find it amusing that the boundary between
"intelligent language discussion" and "trolling" is mainly a matter of who
likes who, not the content. And, this is all I have to say on the subject,
so have fun.

--
Cheers, www.indiegamedesign.com
Brandon Van Every Seattle, WA

"Troll" - (n.) Anything you don't like.
Usage: "He's just a troll."
 
F

Florian Gross

Hunn said:
[Ruby, Python]
I've given up on Perl for its ugly syntax and it is not the easiest language
to learn. How about PHP?

All these suck. You guys should grow up and start programming in *real*
programming languages like Befunge.

Oh, and you forgot to cross post to all the other 54 comp.lang groups.

And now: Can we please never have threads like this one ever again?
We're getting them on a twice-per-month base right now which makes these
topics get old and very uninteresting quickly.

PS: Don't take this too personal, but all this wouldn't have happened if
you had searched in other resources before posting here.

Regards,
Florian Gross
 
P

Phil Tomson

Cameron said:
.
It's not just that "You won't know until you try" ("is it better
to have children, or join the monastery?"); it's that you won't
know until you try, *and it's inexpensive to try*! It's eminently
feasible to gain experience in either language with a few hours (!)
of work, as opposed to the weeks that must precede enlightenment
about, say, J2EE servers.

Of course, those of us who are more into the Complete Waste Of Time [TM]
theory of selecting software components will simply give you the bottom
line:

- If you like Perl, you'll like Ruby. If you think Perl is a bletcherous
hack, you'll like Python.
- The Python community dwarfs the Ruby community.
- Both languages are slow.
- Python has lotsa libraries but not everything. Ask here regarding your
specific needs. Even if Python were the most elegant language in the world,
that's not useful if you must write everything from scratch and don't have
time to do it.

This is the kind of information you get by simply asking people and reading
lotsa archives. Some people say "Try it yourself!" is the only way to
learn. They are wrong, and they often don't value people's time. You
really can rely on other people's reported experiences of the nuclear
mushroom cloud exploding over the horizon. It is not strictly necessary to
walk into Ground Zero yourself.

Now, if you're going to argue "it's just a little Ruby code..." why don't
you try multiplying that by all the languages in the comp.lang.* hierarchy
that you could potentially be selecting from? Take a spin by the Language
Shootouts if you want to spin your head some more.
http://www.bagley.org/~doug/shootout/
http://dada.perl.it/shootout/
You need a filter of some kind for cutting down the options. I suggest
asking people, and seeing what languages actually got used for jobs relevant
to your software problem / industry.

It seems as though he has already done this. He was interested in Ruby
and Python (N=2). From there a couple of people (including myself)
suggested that he make the determination about which to study indepth by
actually doing a bit of coding in both languages. Spending a day or two
on this exercise doesn't seem excessive if you're serious about selecting
your 'next language' to learn in depth.

Phil
 

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
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top