Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Can you please help to make decision?

Reply
Thread Tools

Can you please help to make decision?

 
 
Phlip
Guest
Posts: n/a
 
      10-01-2007
> Please, sit down and really try learning regular expression before
> adding to the fear factor surrounding them.


Then test them, clean them up, use /m on their ends so you can group
their contents with blanks, and hide them behind self-documenting
interfaces.

> > Ruby also relies heavily on regex's, and regex's are never going to be
> > easy to read for anyone. regex's are not beginner friendly, and that
> > might be a big barrier for a beginner trying to learn ruby. There are
> > lots of people who just can't learn regex's.


Next, I thought any language which supports Regexp would have this
problem. No language "relies on" Regexps for its core behaviors, so do
commit the Regexp abuse that some _programmers_ indulge in, and we'll
get along fine!

--
Phlip
http://www.oreilly.com/catalog/9780596510657/
^ assert_xpath

 
Reply With Quote
 
 
 
 
William James
Guest
Posts: n/a
 
      10-01-2007
On Oct 1, 9:50 am, Phlip <(E-Mail Removed)> wrote:
> > Please, sit down and really try learning regular expression before
> > adding to the fear factor surrounding them.

>
> Then test them, clean them up, use /m on their ends so you can group
> their contents with blanks,


Incorrect. /m makes . match a newline. /x lets you put extra
whitespace
and comments in the regular expression.

 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      10-01-2007
William James wrote:

> > Then test them, clean them up, use /m on their ends so you can group
> > their contents with blanks,

>
> Incorrect. /m makes . match a newline. /x lets you put extra
> whitespace
> and comments in the regular expression.


I upgraded one of my assertions to write that post. I added blanks,
and it failed. Then I added /m, and it failed, so I added /x, and it
passed.

Then I came here and wrote /m.

Test-first posting works!

--
Phlip
http://www.oreilly.com/catalog/9780596510657/
^ assert_xpath

 
Reply With Quote
 
Chad Perrin
Guest
Posts: n/a
 
      10-01-2007
On Mon, Oct 01, 2007 at 03:25:37AM +0900, 7stud -- wrote:
> Here's a simple test for the op. Which of the following do you think is
> easier to understand? Can you guess what each program does?
>
> language1:
> --------
>
> colors = ["red", "blue", "green"]
>
> colors.each {|color| puts color}
>
>
> language2:
> ---------
> colors = ["red", "green", "blue"]
>
> for color in colors:
> print color


In the case of someone who has never programmed before, I rather think
"colors.each {|color| puts color}" might be less confusing than "for
color in colors:\n print color". I have never in my life seen anything
in plain English that even began to look like "for color in colors", and
the meaning of that clause is non-obvious. Meanwhile, "colors.each" at
least looks like it's saying something about each of something, with the
"each" attached obviously to the "colors", suggesting that it's saying
"for each element of the colors array".

The only way the Python one looks anything like "more intuitive" to
someone who has never encountered Ruby or Python before, as far as I can
tell, is if that person is familiar with C.

--
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
They always say that when life gives you lemons you should make lemonade.
I always wonder -- isn't the lemonade going to suck if life doesn't give
you any sugar?

 
Reply With Quote
 
Logan Capaldo
Guest
Posts: n/a
 
      10-01-2007
On 10/1/07, Chad Perrin <(E-Mail Removed)> wrote:
> On Mon, Oct 01, 2007 at 03:25:37AM +0900, 7stud -- wrote:
> > Here's a simple test for the op. Which of the following do you think is
> > easier to understand? Can you guess what each program does?
> >
> > language1:
> > --------
> >
> > colors = ["red", "blue", "green"]
> >
> > colors.each {|color| puts color}
> >
> >
> > language2:
> > ---------
> > colors = ["red", "green", "blue"]
> >
> > for color in colors:
> > print color

>
> In the case of someone who has never programmed before, I rather think
> "colors.each {|color| puts color}" might be less confusing than "for
> color in colors:\n print color". I have never in my life seen anything
> in plain English that even began to look like "for color in colors", and
> the meaning of that clause is non-obvious. Meanwhile, "colors.each" at
> least looks like it's saying something about each of something, with the
> "each" attached obviously to the "colors", suggesting that it's saying
> "for each element of the colors array".
>
> The only way the Python one looks anything like "more intuitive" to
> someone who has never encountered Ruby or Python before, as far as I can
> tell, is if that person is familiar with C.
>

You bring up an excellent point. Where the hell did "for" come from
anyway? Only thing I can think of is "for all x in X" kinds of
statements from math, but thinking about it now, "for" seems like
such a weird word. I just looked it up, man is this word overloaded:
http://dictionary.reference.com/browse/for
If I ever create a language, the word "for" shall not appear as an
interation construct in it.
> --
> CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
> They always say that when life gives you lemons you should make lemonade.
> I always wonder -- isn't the lemonade going to suck if life doesn't give
> you any sugar?
>
>


 
Reply With Quote
 
John Joyce
Guest
Posts: n/a
 
      10-01-2007

On Oct 1, 2007, at 2:58 PM, Chad Perrin wrote:

> On Mon, Oct 01, 2007 at 03:25:37AM +0900, 7stud -- wrote:
>> Here's a simple test for the op. Which of the following do you
>> think is
>> easier to understand? Can you guess what each program does?
>>
>> language1:
>> --------
>>
>> colors = ["red", "blue", "green"]
>>
>> colors.each {|color| puts color}
>>
>>
>> language2:
>> ---------
>> colors = ["red", "green", "blue"]
>>
>> for color in colors:
>> print color

>
> In the case of someone who has never programmed before, I rather think
> "colors.each {|color| puts color}" might be less confusing than "for
> color in colors:\n print color". I have never in my life seen
> anything
> in plain English that even began to look like "for color in
> colors", and
> the meaning of that clause is non-obvious. Meanwhile,
> "colors.each" at
> least looks like it's saying something about each of something,
> with the
> "each" attached obviously to the "colors", suggesting that it's saying
> "for each element of the colors array".
>
> The only way the Python one looks anything like "more intuitive" to
> someone who has never encountered Ruby or Python before, as far as
> I can
> tell, is if that person is familiar with C.
>
> --
> CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
> They always say that when life gives you lemons you should make
> lemonade.
> I always wonder -- isn't the lemonade going to suck if life doesn't
> give
> you any sugar?
>

But you forget, Ruby can also do
colors = Array.new # Or Hash.new, etc...

for color in colors
puts color
end

This format makes more sense to some people in some cases. Seems
pretty clear. For some it is more clear than the .each version with
its do-end or {}
Of course, if they don't get used to do-end and {} they'll have a
hard time with Ruby...

 
Reply With Quote
 
Chad Perrin
Guest
Posts: n/a
 
      10-01-2007
On Mon, Oct 01, 2007 at 11:29:28PM +0900, John Joyce wrote:
>
> On Oct 1, 2007, at 12:20 AM, David Orriss Jr wrote:
>
> >In article <(E-Mail Removed)>,
> > Byung-Hee HWANG <(E-Mail Removed)> wrote:
> >
> >>Fist of all, sorry for poor English, I am not professional English
> >>speaker. I have some plan to do study computer language for my
> >>work. But
> >>still I do not make decision what to do study between Ruby and
> >>Python. I
> >>never have experience to use any computer language. I think Ruby's
> >>design is clean, whereas it does not have many libraries to use
> >>somebody.
> >>
> >>Can you please help to make decision?

> >
> >I don't think Python has ever gained the traction that Ruby has,
> >especially with the advent of RoR.
> >
> >My opinion, go with Ruby.
> >

> Huh? Python's got lots of traction! Just not the buzz.
> Python is widely used and shipped with systems.


True. Perl, Python, and Ruby are all quite widely used. For instance,
Perl was used to create Debian's APT, Python was used to create Gentoo's
portage, and Ruby was used for FreeBSD's portupgrade. It's difficult to
get more of an indication of traction than that.


>
> Try both.
> Go with the one that suits you best!
> You have many things to consider. Browse the books and sites for all
> languages you're considering.
> A bad book can be a big turn-off to a good language.
>
> You can't go wrong with either one.


Agreed, pretty much. Personal preferences play heavily into the choice
between Ruby and Python (and Perl, for that matter). It's not like any
of the three are QBASIC or COBOL, avoided for the sake of sanity.
They're all excellent, flexible, powerful, high-level languages. If
there's a major influence on which is the "best" choice for a first
language aside from personal preference, it's which has the best absolute
beginner tutorial materials -- and from what I've seen, that's a toss-up
between Ruby and Perl, depending in large part on whether you're looking
for online tutorials (Ruby wins there, I think) or hardcopy, published
books (while there's some excellent material for Ruby, like Chris Pine's
Learn to Program, Perl's camelid books provide a smoother and more
complete path from rank newbie to competent programmer, in my opinion).

Of course, community is quite important, too. Between ruby-talk and
Perlmonks, it's kind of a toss-up between the two. I like the
Pythonistas in my area, but I'm not a fan of the Python community at
large, in general.

--
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
Kent Beck: "I always knew that one day Smalltalk would replace Java. I
just didn't know it would be called Ruby."

 
Reply With Quote
 
Chad Perrin
Guest
Posts: n/a
 
      10-02-2007
On Mon, Oct 01, 2007 at 02:10:04AM +0900, William James wrote:
>
> Apparently, Ruby gives the programmer more power here.
> Just as Awk has OFS (output-field-separator) and ORS
> (output-record-separator), Ruby has $, and $\.


I should have read this before I responded and brought up the idea of
global variables.

--
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
Isaac Asimov: "Part of the inhumanity of the computer is that, once it is
completely programmed and working smoothly, it is completely honest."

 
Reply With Quote
 
Chad Perrin
Guest
Posts: n/a
 
      10-02-2007
On Mon, Oct 01, 2007 at 11:16:58PM +0900, James Edward Gray II wrote:
> On Sep 30, 2007, at 8:47 AM, 7stud -- wrote:
>
> >Ruby also relies heavily on regex's, and regex's are never going to be
> >easy to read for anyone. regex's are not beginner friendly, and that
> >might be a big barrier for a beginner trying to learn ruby. There are
> >lots of people who just can't learn regex's.

>
> I'm staying out of the Ruby vs. Python debate, but the above is just
> plain wrong and I wish people would stop saying things like this.
>
> For some reason, regular expressions are surrounded in this aura of
> mystery. Perhaps their syntax heavy nature makes them seem odd to
> people unfamiliar with them at first glance, but for some reason
> many, many people believe things like the comment posted about.
> That's a real shame.
>
> Regular expression is a simple pattern language anyone can learn
> quite easily. I once taught them to my wife in the space of evening,
> to help with a work project. She's an above average skill-level
> computer user, but definitely not a programmer. She had no trouble
> grasping the concepts and still uses regular expression to this day.


Agreed. If an emacs user can learn to use a regex, anyone can.

/me ducks and hides.


>
> Please, sit down and really try learning regular expression before
> adding to the fear factor surrounding them. I promise, it's time
> well spent.


--
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
Leon Festinger: "A man with a conviction is a hard man to change. Tell him
you disagree and he turns away. Show him facts and figures and he questions
your sources. Appeal to logic and he fails to see your point."

 
Reply With Quote
 
Chad Perrin
Guest
Posts: n/a
 
      10-02-2007
On Tue, Oct 02, 2007 at 04:58:10AM +0900, Chad Perrin wrote:
> On Mon, Oct 01, 2007 at 03:25:37AM +0900, 7stud -- wrote:
> > Here's a simple test for the op. Which of the following do you think is
> > easier to understand? Can you guess what each program does?
> >
> > language1:
> > --------
> >
> > colors = ["red", "blue", "green"]
> >
> > colors.each {|color| puts color}
> >
> >
> > language2:
> > ---------
> > colors = ["red", "green", "blue"]
> >
> > for color in colors:
> > print color

>
> In the case of someone who has never programmed before, I rather think
> "colors.each {|color| puts color}" might be less confusing than "for
> color in colors:\n print color". I have never in my life seen anything
> in plain English that even began to look like "for color in colors", and
> the meaning of that clause is non-obvious. Meanwhile, "colors.each" at
> least looks like it's saying something about each of something, with the
> "each" attached obviously to the "colors", suggesting that it's saying
> "for each element of the colors array".
>
> The only way the Python one looks anything like "more intuitive" to
> someone who has never encountered Ruby or Python before, as far as I can
> tell, is if that person is familiar with C.


. . and while I'm at it, I think this might be even more easily
understood (ignoring for a moment the variable sigils):

@colors = ("red", "blue", "green")

print foreach @colors;

On the other hand, I doubt you want to advocate Perl -- particularly if
you're a Pythonista. Also, as others have pointed out, the Ruby iterator
could just be replaced with `puts colors`.

--
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
Patrick J. LoPresti: "Emacs has been replaced by a shell script which 1)
Generates a syslog message at level LOG_EMERG; 2) reduces the user's disk
quota by 100K; and 3) RUNS ED!!!!!!"

 
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
make pls don't work , i help you make web ,help you do business onthe internet xiaobb03@gmail.com Digital Photography 0 03-13-2008 11:28 AM
Can you spare 10 minutes to do a survey? You can be a valuable help to university researchers! daniel DVD Video 0 03-02-2007 02:19 AM
Stupid question. Please, only stupid responders. If you're not sureif you're stupid, you probably aren't. =?ISO-8859-1?Q?R=F4g=EAr?= Computer Support 6 07-18-2005 05:11 AM
HELP! HELP! PLEASE, PLEASE, PLEASE tpg comcntr Computer Support 11 02-15-2004 06:22 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments