Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Ruby Programming Language

Trying to decide on a language to learn


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?

In message <f3ffbi$1h@registered.motzarella.org>, "Crep Cat" writes:

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

Should be fine in virtually any language.

>Anyway, would Ruby be a good language for that task?

Sure.

>Would any other language be more suitable?

I don't know.  You could probably do it in just about anything.

>Could I get newbie help on file handling here?

Sure!

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

I don't think so.  Too specialized.

Budget a while to get used to programming; it's a new skill, and will
take some time.  Once you're used to it, IO should be easy.

-s

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

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.

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.

On Tue, May 29, 2007 at 06:31:18AM +0900, z@cesmail.net 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.

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);

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.

Quoting Chad Perrin <per@apotheon.com>:

> 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.
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc