Trying to decide on a language to learn

Discussion in 'Ruby' started by Crep Cat, May 28, 2007.

  1. Crep Cat

    Crep Cat Guest

    I am trying to decide on a language to learn - and would be grateful for
    help.
    My reasons for wanting to learn programming are firstly to have fun
    and secondly to learn more about how computers work.

    I have thought of one thing I would like to write - and wonder if Ruby
    (or perhaps Python?) would be suitable.

    I would like to export a spreadsheet column to a file;
    read that file into Ruby as an array;
    mess about with that array;
    write the new array out as a file;
    import that file into a spreadsheet.

    I can't understand the documentation about file handling.
    Ruby documentation starts off very user friendly,
    but, by the time it gets to file handling, has become extremely
    esoteric!

    Anyway, would Ruby be a good language for that task?
    Would any other language be more suitable?
    Could I get newbie help on file handling here?
    Is there a really good introductory book which deals simply with file
    handling?
    Crep Cat, May 28, 2007
    #1
    1. Advertising

  2. Crep Cat

    Alex Young Guest

    Crep Cat wrote:
    > I am trying to decide on a language to learn - and would be grateful for
    > help.
    > My reasons for wanting to learn programming are firstly to have fun
    > and secondly to learn more about how computers work.
    >
    > I have thought of one thing I would like to write - and wonder if Ruby
    > (or perhaps Python?) would be suitable.
    >
    > I would like to export a spreadsheet column to a file;
    > read that file into Ruby as an array;
    > mess about with that array;
    > write the new array out as a file;
    > import that file into a spreadsheet.
    >
    > I can't understand the documentation about file handling.
    > Ruby documentation starts off very user friendly,
    > but, by the time it gets to file handling, has become extremely esoteric!
    >
    > Anyway, would Ruby be a good language for that task?

    Yes. There is a library included with Ruby specifically for this sort
    of task - it's the CSV library. Mind you, if you're dealing with files
    that only contain a single column, there's going to be a simpler way to
    do it.

    > Would any other language be more suitable?

    For tasks of this sort of complexity, Ruby, Python and Perl are probably
    equivalent - there's not a lot in it.

    > Could I get newbie help on file handling here?

    Certainly - but it's always best to have as specific a problem as
    possible, and to show us what you've already tried and what you're
    expecting the code to do.

    > Is there a really good introductory book which deals simply with file
    > handling?

    The Pickaxe is the definitive guide - there's a free edition online
    here: http://www.ruby-doc.org/docs/ProgrammingRuby/. The section you
    want is "Basic Input and Output". You'll also want to read the
    "Containers, Blocks, and Iterators" section to get a handle on blocks -
    lots of Ruby is based around blocks, so it's good to know how they work.

    Hope this helps,
    --
    Alex
    Alex Young, May 28, 2007
    #2
    1. Advertising

  3. Crep Cat

    Guest

    Quoting Crep Cat <nospam@[127.0.0.1]>:

    > I am trying to decide on a language to learn - and would be grateful for
    > help.
    > My reasons for wanting to learn programming are firstly to have fun
    > and secondly to learn more about how computers work.


    In that case, I'd recommend either "Everyday Scripting With Ruby" or "Learn To
    Program". Both are available as either paper, PDF or combo packs from the
    Pragmatic Programmers. Judging by your example below, I'd recommend "Everyday
    Scripting With Ruby" first.
    >
    > I have thought of one thing I would like to write - and wonder if Ruby
    > (or perhaps Python?) would be suitable.


    Ruby is suitable. I'm guessing Python and Perl are as well, although I haven't
    used them for this sort of thing.
    >
    > I would like to export a spreadsheet column to a file;
    > read that file into Ruby as an array;
    > mess about with that array;
    > write the new array out as a file;
    > import that file into a spreadsheet.
    >
    > I can't understand the documentation about file handling.
    > Ruby documentation starts off very user friendly,
    > but, by the time it gets to file handling, has become extremely
    > esoteric!
    >
    > Anyway, would Ruby be a good language for that task?
    > Would any other language be more suitable?
    > Could I get newbie help on file handling here?
    > Is there a really good introductory book which deals simply with file
    > handling?


    Here's what I recommend:

    1. I'm assuming that "spreadsheet" means Excel, and that you're on Windows. If
    that's not correct, please post otherwise.

    2. Download the One-Click Ruby Installer for Windows and install it on your
    machine. If you're in a corporate setting behind a firewall, you may need to
    have your IT people help you with "gem" updates when you get to that point, but
    since you're a beginner, you probably won't be doing that just yet.

    3. There is a library in the Windows versions of Ruby that talks *directly* to
    spreadsheets using the Windows OLE API. There's no reason to mess with
    intermediate files when you can just talk directly to the spreadsheet in Ruby.

    4. I think the One-Click Installer comes with a copy of the free version of the
    Pickaxe Book ("Programming Ruby"). And I also think that the Windows OLE API is
    documented in that version. So that's where I would start.
    >
    >
    >
    , May 28, 2007
    #3
  4. Crep Cat

    Chad Perrin Guest

    On Tue, May 29, 2007 at 06:31:18AM +0900, wrote:
    > Quoting Crep Cat <nospam@[127.0.0.1]>:
    >
    > > I am trying to decide on a language to learn - and would be grateful for
    > > help.
    > > My reasons for wanting to learn programming are firstly to have fun
    > > and secondly to learn more about how computers work.

    >
    > In that case, I'd recommend either "Everyday Scripting With Ruby" or "Learn To
    > Program". Both are available as either paper, PDF or combo packs from the
    > Pragmatic Programmers. Judging by your example below, I'd recommend "Everyday
    > Scripting With Ruby" first.


    I, too, would recommend "Everyday Scripting with Ruby". I'm reading it
    now, and it's excellent -- and well suited to this sort of introduction
    to the language.


    > >
    > > I have thought of one thing I would like to write - and wonder if Ruby
    > > (or perhaps Python?) would be suitable.

    >
    > Ruby is suitable. I'm guessing Python and Perl are as well, although I haven't
    > used them for this sort of thing.


    Ruby, Python, and Perl are among the best languages for hacking together
    something like that. Not only are they fairly high-level languages with
    great list-handling (only LISP dialects really provide better basic list
    handling, from what I've seen so far), but they also provide excellent
    libraries ("modules", whatever) specifically for dealing with data
    formats like CSV and XLS files. You could conceivably do the same with
    C, OCaml, Logo, VB.NET, or Prolog, but my first instinct would be to
    recommend Perl, Python, or Ruby.


    >
    > Here's what I recommend:
    >
    > 1. I'm assuming that "spreadsheet" means Excel, and that you're on Windows. If
    > that's not correct, please post otherwise.
    >
    > 2. Download the One-Click Ruby Installer for Windows and install it on your
    > machine. If you're in a corporate setting behind a firewall, you may need to
    > have your IT people help you with "gem" updates when you get to that point, but
    > since you're a beginner, you probably won't be doing that just yet.
    >
    > 3. There is a library in the Windows versions of Ruby that talks *directly* to
    > spreadsheets using the Windows OLE API. There's no reason to mess with
    > intermediate files when you can just talk directly to the spreadsheet in Ruby.
    >
    > 4. I think the One-Click Installer comes with a copy of the free version of the
    > Pickaxe Book ("Programming Ruby"). And I also think that the Windows OLE API is
    > documented in that version. So that's where I would start.


    Good advice. Add to that the recommendation of "Everyday Scripting with
    Ruby", and you've got a winner.

    . . or talk to people in the Perl and/or Python communit[y|ies] about
    how best to approach the problem in either of those languages. I
    personally prefer either Perl or Ruby, rather than Python, for anything
    I do -- for a number of reasons. Most of those reasons are specific to
    my individual tastes and preferences, but one in particular for data
    munging is that Python's regex engine is a trifle more clunky than that
    of Ruby or Perl (though my understanding is that, once you get past the
    clunkiness, Python's is slightly more "powerful" than Ruby's, putting it
    not far behind Perl's).

    One more note on the decision: If you're planning on doing any OOP, I'd
    recommend either Python or Ruby over Perl. I personally would rather
    use Perl for OOP than Python, but that's because I dislike Python, not
    because Perl's better at object oriented programming. Objectively
    speaking, Python's OOP characteristics are much better than Perl's. Of
    course, so are Ruby's (and I even think they're better than Python's,
    though my bias might be showing on that one), so if I have my choice of
    language for an OOP project I'll choose Ruby over either Perl or Python
    any day of the week.

    Your mileage may vary.

    --
    CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
    print substr("Just another Perl hacker", 0, -2);
    Chad Perrin, May 29, 2007
    #4
  5. Crep Cat

    Ari Brown Guest

    On May 28, 2007, at 4:55 PM, Crep Cat wrote:

    > I am trying to decide on a language to learn - and would be
    > grateful for help.
    > My reasons for wanting to learn programming are firstly to have fun
    > and secondly to learn more about how computers work.


    If you'd like to learn a language that helps you understand how
    computers work....

    x86 Assembly ftw!

    avoid it like the plague.

    Ruby is definitely a great choice. It teaches you object oriented
    programming, while allowing you funcitonal programming. It's easy to
    learn, and can write could as easy as cheese and crackers.

    Ruby ftw
    ~ Ari
    English is like a pseudo-random number generator - there are a
    bajillion rules to it, but nobody cares.
    Ari Brown, May 29, 2007
    #5
  6. Crep Cat

    Guest

    Quoting Chad Perrin <>:

    > Ruby, Python, and Perl are among the best languages for hacking together
    > something like that. Not only are they fairly high-level languages with
    > great list-handling (only LISP dialects really provide better basic list
    > handling, from what I've seen so far), but they also provide excellent
    > libraries ("modules", whatever) specifically for dealing with data
    > formats like CSV and XLS files.


    I'm not at all sure Lisp/Scheme are really better at "basic list handling" than
    Ruby at this point in time. At the core interpreter level, Lisp/Scheme are
    fundamentally list-oriented and recursive, while Ruby is object-oriented and
    iterative. But at the high level we programmers normally prefer in our daily
    work, I'd take Ruby over Lisp/Scheme any day for dealing with lists, arrays and
    hashes. And while I know Common Lisp and Scheme have libraries for all the heavy
    lifting, so does Ruby.
    , May 29, 2007
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Porky Pig Jr
    Replies:
    3
    Views:
    1,033
    Fuzzyman
    May 12, 2004
  2. CoreyWhite
    Replies:
    1
    Views:
    650
    JohnQ
    Mar 31, 2007
  3. Google Poster

    Trying to decide between PHP and Python

    Google Poster, Jan 4, 2011, in forum: Python
    Replies:
    37
    Views:
    818
    Benjamin J. Racine
    Feb 10, 2011
  4. Cambridge Ray
    Replies:
    3
    Views:
    918
    Joe Kesselman
    Jul 28, 2011
  5. Amit
    Replies:
    2
    Views:
    159
Loading...

Share This Page