Trying to decide on a language to learn

C

Crep Cat

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

Alex Young

Crep said:
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,
 
Z

znmeb

Quoting Crep Cat said:
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.
 
C

Chad Perrin

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.

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

Ari Brown

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

znmeb

Quoting Chad Perrin said:
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.
 

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,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top