Can you please help to make decision?

Discussion in 'Ruby' started by Byung-Hee HWANG, Sep 30, 2007.

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

    Can you please help to make decision?
    Byung-Hee HWANG, Sep 30, 2007
    1. Advertisements

  2. Ruby, no question about it.
    SpringFlowers AutumnMoon, Sep 30, 2007
    1. Advertisements

  3. Byung-Hee HWANG

    Robert Dober Guest

    Of course 100% Ruby unless you ask the question on the Python Mailing List ;).
    I however feel that if one might argue if Ruby or Python is the better
    language for ages if it comes to decide which one of the both to
    learn first Ruby really wins, here is my personal list why:

    - a clean (probably one of the cleanest) object oriented design, example
    12.to_s (Ry) vs. str(12) (Py)
    - a simpler (not simple by any means, but simpler) Inheritance Model
    - a little bit less esotheric (syntax and metraprogramming) thus what
    you learn about Ruby will be more usable for other languages e.g.
    - simpler, Python got very, very powerful but at the cost of advanced
    techniques, the Ruby learning curve will be much flatter.
    - and this is my favorite: "Code Blocks", learning to use code blocks
    is probably the single greatest benefit from learning Ruby, Python
    just will not give this to you.

    This is a single opinion of a single minded guy of course ;).
    Robert Dober, Sep 30, 2007
  4. Byung-Hee HWANG

    7stud -- Guest

    I would choose python.


    Convert the number 12 to a string:

    ruby: my_str = 12.to_s

    python: my_str = str(12)

    I have a hard time understanding how either method has an advantage over
    the other. It's totally irrelevant in my opinion. Personally, I think
    using a number to call a method looks ugly. But I can adapt pretty

    - a simpler (not simple by any means, but simpler) Inheritance Model

    I have never studied a simple inheritance model. I don't have enough
    experience with Ruby's inheritance model yet to know which is simpler.
    Once again, I think trying to decide which is simpler is totally
    irrelevant--especially for a beginner who has never programmed in any
    language before.

    - a little bit less esotheric (syntax and metraprogramming) thus what
    you learn about Ruby will be more usable for other languages e.g.

    I think ruby's syntax looks like chicken scratchings, and I have a C++
    background. C++ has the most difficult syntax I have seen--except maybe
    perl's. In my opinion, python's syntax is much more human readable than
    ruby's. I guess if you are coming from perl, then ruby's syntax would
    seem incredibly clear. Of course, if you know a language well, it's
    easy to read. I think the test is whether someone who doesn't know a
    language well can make heads or tails out of what is going on in some
    basic code. I don't think ruby is ever going to be readable in that way.

    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.

    - simpler, Python got very, very powerful but at the cost of advanced
    techniques, the Ruby learning curve will be much flatter.

    I doubt that Ruby's learning curve is flatter. I think python and ruby
    are close neighbors as far as languages go. In fact, there are some
    similarities that it will make you wonder who copied who with regard to
    certain features. However, I would guess that python's learning curve
    is easier for beginners because the subject of classes doesn't come up
    until about the middle of a python book. python is a language that can
    be used effectively without classes if the concept of classes is too
    difficult for a beginner to grasp.

    Overall, I think python's online documentation is pretty poor, but I
    think ruby's is worse. In my opinion, only php got it right. They
    opened up the online documentation to user comments, and now every
    single issue that has ever been encountered with any function is
    discussed in the comments to the documentation. That is incredibly
    valuable information. If ruby wanted to take a significant step forward
    in its online documentation relative to python, I think they should copy
    the php model. One solution to the poor online docs for both ruby and
    python is to buy a good book.

    There is also more information about python available on the web since
    the python community is much larger.

    - and this is my favorite: "Code Blocks", learning to use code blocks
    is probably the single greatest benefit from learning Ruby, Python
    just will not give this to you.

    I don't know what "code blocks" are and the subject isn't in the
    appendix of ruby's bible: pickaxe2, so I can't comment on that.

    6) I find tracking down errors is more difficult in ruby than python.
    python has better error messages. For instance, in ruby if you forget
    one 'end' in your code somewhere('end' is used to terminate a section of
    code), the error message will say that there is an error on the last
    line of your program. As a result, you have to go hunting through your
    whole program to figure out where you forgot an 'end'. That's

    7) There are some really nice little touches that python implements,
    which make programming less aggravating. I'll highlight one.

    Both ruby and python have string formatting, which requires more typing
    as well as typing harder to reach characters on the keyboard in order to
    output some information to the screen. But let's say you just want to
    quickly display something to the screen with minimal typing. In ruby,
    you can use the method: puts. For instance,

    val1 = 10
    val2 = 20

    puts val1, val2

    puts adds a newline after each value, so the output is:


    But, what if you want to print two things on the same line. Ruby also
    has a print method:

    print val1, val2

    but the output will be: 1020. To get some separation, you have to do

    print val1, " ", val2

    and then the output will be: 10 20. Having to include the quoted space
    in there is almost not worth the effort--you might be swayed to use the
    more laborious string formatting instead. In addition, print does not
    add a newline at the end, so to keep any subsequent output from
    displaying on the same line, you need to write:

    print val1, " ", val2, "\n"

    That's just too much of a hassle. Using puts with string formatting is
    probably no harder to type:

    puts "#{val1} #{val2}"

    So much for being able to type something quickly that displays a few
    values to the screen.

    In python, the print command is like the puts method in ruby. However,
    it works a little bit differently. The statement:

    print val1, val2

    works differently in two ways:

    1) print adds a newline after all the output--not after each variable
    2) print automatically adds a space between each variable

    So this code:

    val1 = 10
    val2 = 20

    print val1, val2

    produces the output: 10 20, and since print automatically adds a newline
    after all the output, the next print statement won't display output on
    the same line. As a result, python's print statement is incredibly
    handy and easy to use. I think it shows how much thought is put into
    the details of the language.

    8) Then there are the well documented major shortcomings of Ruby---it is
    slow. Rubyists will say, "Who cares?! I'm in no rush to get the
    results of my programs." That's well and good, but it's nice to have
    more speed if you need it. Rubyists will counter, "If I need the speed,
    I'll program in C." That's great if you know C, but what if you only
    know ruby? python executes much faster than ruby, and just like ruby,
    you can program the slow parts in C if you need even more speed.

    Good luck with your choice.
    7stud --, Sep 30, 2007
  5. snip...]
    I will refer to your comments. Thank you for serious advice.

    Byung-Hee HWANG, Sep 30, 2007
  6. Thank you for kindness..

    Byung-Hee HWANG, Sep 30, 2007
  7. Look under 'block' not 'code block'.

    Regards, Morton
    Morton Goldberg, Sep 30, 2007
  8. Byung-Hee HWANG

    Robert Dober Guest

    First of all is great that somebody speaks out honestly like this, and
    it will give a great discussion, looking forward to it
    That is not really the issue, remember I was talking to a beginner.
    12.to_s means it is Integer's responsibility to convert itself to a String
    str(12) means it is Kernel's responsibility to convert Integer's to Strings
    the second just does not feel OO to me.
    Well you mean the shall start running before walking? Why not if they
    are well guided, I could easily tell a beginner start with Python but
    be aware of all dangers of MI. Is there good materiel like that on
    Python? I guess a link would be appreciated.
    In the end it might be simpler to learn walking first, but it is not a
    strict rule.
    Ok maybe I should have said that this is a personal POV, however
    with all due respect that is nonsense, regexs are what they are, in
    Perl, Python or Ruby.
    Yes but should they, I guess a pure question of taste, but I give
    partially in on it.
    Might really depend on the student's style.
    Ok no discussion here, I give you that point
    But the Ruby community seems more helpful than Python's, do you agree?
    What? Are you sure I mean {} and do end
    I give it to you for Syntax errors, but when it come to Stack Traces
    OMG Ruby beats Python by magnitudes.
    No please not that, that is not important, whoever does not implement
    that kind of basic method his way anyway, and for a beginner,
    I think it is fast, it is even lightening fast for a beginner for
    whome typing speed is much more important than execution speed.
    Now I am making a brisk statement: Somebody learning Ruby today will
    have as fast Rubies available as Pythons, when she is master.
    And again I agree 100% with you ;)

    Robert Dober, Sep 30, 2007
  9. Byung-Hee HWANG

    Phlip Guest


    (2 years of pure Python, folks, and not going back...)
    Phlip, Sep 30, 2007
  10. Those are probably the same people who can't figure out
    what a code block is. Even little old Awk relies heavily on
    regular expressions, which should be learned by anyone who
    wants to rise above COBOL and BASIC and C.


    And yet the soul, shut up in her dark room,
    Viewing so clear abroad, at home sees nothing;
    But, like a mole in earth, busy and blind,
    Works all her folly up, and casts it outward
    To the world's open view.

    Apparently, Ruby gives the programmer more power here.
    Just as Awk has OFS (output-field-separator) and ORS
    (output-record-separator), Ruby has $, and $\.

    E:\Ruby>irb --prompt xmp
    print 88,99
    8899 ==>nil
    $, = ' '
    ==>" "
    print 88,99
    88 99 ==>nil
    $\ = "\n"
    print 88,99
    88 99
    $, = '--'
    print 88,99
    $\ = "<<\n"
    print 88,99
    William James, Sep 30, 2007
  11. Byung-Hee HWANG

    7stud -- Guest

    Look under 'block' not 'code block'.

    Ahh. "Blocks" as in "Proc's and blocks".
    Do you really think a beginner cares about that or even has any idea
    what you are talking about?
    What about when you write:

    puts result
    input = gets
    p = lambda {"hello world"}
    printf("%.2f \n", 4.56789)
    require "somefile"

    Do you avoid those 'global' method calls because they look too much like
    str(12)? Or, to maintain your OO purity do you write things like:

    Kernel.puts "hello world"
    def func1

    def func2
    puts y


    r8test.rb:5:in `func2': undefined local variable or method `y' for
    main:Object (NameError)
    from r8test.rb:2:in `func1'
    from r8test.rb:7

    Traceback (most recent call last):
    File "", line 8, in ?
    File "", line 2, in func1
    File "", line 5, in func2
    print y
    NameError: global name 'y' is not defined

    I don't see any substantive difference, but to my eye the python output
    looks more orderly and is easier to read.

    That's more credit than I'd give it!
    7stud --, Sep 30, 2007
  12. Byung-Hee HWANG

    7stud -- Guest

    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?


    colors = ["red", "blue", "green"]

    colors.each {|color| puts color}

    7stud --, Sep 30, 2007

  13. I think one thing is the "fun" factor, that i have programmed in BASIC,
    Assembly, Fortran, Pascal, C, C++, Perl, Python, Ruby, and PHP.

    I'd say Pascal was delightful as it was well structured. C is powerful.
    Perl and Python is quick for writing code. But recently I just have had
    a lot of fun writing in Ruby. I haven't had that feeling in years.
    SpringFlowers AutumnMoon, Sep 30, 2007
  14. if viewed as "hey number 12, i give you a message, and the message is
    'tell me what you are in a string format', and the number 12 tells you",
    that's be kind of cool.
    SpringFlowers AutumnMoon, Sep 30, 2007
  15. Byung-Hee HWANG

    7stud -- Guest

    Whoops. Maybe these will be easier to understand:

    numbers = [10, 20, 30]

    numbers.each {|number| puts number}

    7stud --, Sep 30, 2007

  16. numbers = [10, 20, 30]
    ==>[10, 20, 30]

    for number in numbers do
    p number
    William James, Sep 30, 2007

  17. E:\Ruby>irb --prompt xmp
    colors = ["red", "blue", "green"]
    ==>["red", "blue", "green"]
    puts colors
    William James, Sep 30, 2007
  18. 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.

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

    James Edward Gray II
    James Edward Gray II, Oct 1, 2007
  19. +1

    BTW ... I *still* hate them, but I use them. ;)
    M. Edward (Ed) Borasky, Oct 1, 2007
  20. Byung-Hee HWANG

    John Joyce Guest

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

    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.
    John Joyce, Oct 1, 2007
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.