[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Nervous Nuby Starting Out!

The MacRubyist

6/17/2007 10:01:00 AM


Anybody out there who's patient and willing to give a newby help if
required?
I'm just starting out considering trying to learn Ruby as a first
language (considering Applescript as language 0.5). This is largely because I
have a nebulous sense that Applescript is a collection of bad habits
waiting to pounce, especially if I'm learning it on my own. I've 'proved'
with Applescript that I like scripting for personal hobbyist things
(usually involving tweaking something to taste, text munging and simple small
things rather than trying to write a big huge app, so far). Suddenly
I'm bumping into limitations of Applescript for things I want to do, and
they're not necessarily to do with hooking apps up (which I know how to
ask for help for from the mailing list) as much as fairly simple 'unixy'
things to do with strings, simple XML and regexes, plus the stuff about
basic program design, flow control &c. Mainly attracted to Ruby by the
big huge user community and the idea that I could make a very cautious
attempt to learn from the ground up -- mainly put off from it so far by
the impression that it is full of people much cleverer than I am!
I don't want to hook Mac-specific stuff up to it until I've found my
feet a bit, and can always keep the little Applescripts I have that work (I
know the Mac-specific stuff is there if required, because people keep
making jokes on the internet about how many of the developers *working*
on Ruby are doing it on Macs), but could do with sorting out an easy XML
parser (Hpricot has been suggested) and working with strings and XML
elements.(and regexes and hashes if I can cautiously start to get my head
round them).
Also, it's my current writing-a-blog-about project in the sense that,
looking for something to blog about that I'm thinking about and there
aren't 99,999 blogs about already, I have started to write my impressions so
far (including where I find mental road-blocks in Why's excellent
friendly book) at:
macrubyist.livejournal.com

Please, if you think this is Far Too Ambitious, please pass over it in
discreet silence and I'll get the hint eventually (probably after I've
been knocking my head against it for weeks or months and can't do 'puts
'Hello world'). Don't discourage me yet. If you don't think it's a
completely cuckoo thing to do as a self-taught project, I'd love to hear from
you. Especially if somebody would tell me it's really easy to compile
from source under Darwin, because the last time I tried to compile from
source it was in an abortive attempt to learn Linux several years ago, with
several unfriendly problems, and I'm scared.
--
The (...and where are all those cartoon foxes, anyway? Could do with
seeing a friendly face...) MacRubyist
12 Answers

Axel Etzold

6/17/2007 10:42:00 AM

0

Dear Macrubyist,

welcome to the Ruby language!

> Anybody out there who's patient and willing to give a newby help if
> required?

Many patient people are around on this here ... just post your problem :)


> I'm just starting out considering trying to learn Ruby as a first
> language

There is a very nice tutorial on the web that presupposes almost
no knowledge about computing :

http://pine.fm/LearnToProgram/?...

It will guide you from the very first beginnings to coding a program
that involves a dinosaur baby's behavior, as it might be observed
in computer games, so you'll really get a feel of the more complex
things in a very short time.


> Suddenly
> I'm bumping into limitations of Applescript for things I want to do, and
> they're not necessarily to do with hooking apps up (which I know how to
> ask for help for from the mailing list) as much as fairly simple 'unixy'
> things to do with strings, simple XML and regexes, plus the stuff about
> basic program design, flow control &c.

Well I don't really know too much about Applescript and whether you could
use it to do things you want, but Ruby certainly is able to do all these
things.
For xml parsing, there's Hpricot and there are very nice tutorials about it, also, there
is rio

http://rio.ruby... ,

for i/o processing, which I use very often.
As you go, you'll find that many other packages are distributed
in a nice way as "gems", which you can easily install and work with right away.


> (and regexes and hashes if I can cautiously start to get my head
> round them).

A hash is just a dictionary, that associates a set of keys to some
other set, the set of values. These can be of all kinds:

english_german={'head'=>['Kopf','Haupt','Hydrozephalus'],
'body'=>'Koerper','foot'=>'Fuss',number_of_feet_in_humans=>2}

For Regexps, there is a nice tutorial here:

http://www.regular-expressions.info...

Ruby has extensive online documentation,

http://www.rubycentral...

Personally, I've also liked Hal Fulton's book
"The Ruby Way" with its many examples a great deal.

> Especially if somebody would tell me it's really easy to compile
> from source under Darwin, because the last time I tried to compile from
> source it was in an abortive attempt to learn Linux several years ago,
> with
> several unfriendly problems, and I'm scared.

Ruby should be there right away, if you have OS 10.2 or later.
But it is certainly a good idea to be able to compile something from source, if you want to work with packages .. you can move this to
next week, though.



> --
> The (...and where are all those cartoon foxes, anyway? Could do with
> seeing a friendly face...) MacRubyist

You can also learn Ruby from comics - here: http://poignantguid...

Best regards,

AQxel
--
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/...

John Joyce

6/17/2007 3:34:00 PM

0


On Jun 17, 2007, at 5:42 AM, Axel Etzold wrote:

> Dear Macrubyist,
>
> welcome to the Ruby language!
>
>> Anybody out there who's patient and willing to give a newby help if
>> required?
>
> Many patient people are around on this here ... just post your
> problem :)
>
>
>> I'm just starting out considering trying to learn Ruby as a first
>> language
>
> There is a very nice tutorial on the web that presupposes almost
> no knowledge about computing :
>
> http://pine.fm/LearnToProgram/?...
>
> It will guide you from the very first beginnings to coding a program
> that involves a dinosaur baby's behavior, as it might be observed
> in computer games, so you'll really get a feel of the more complex
> things in a very short time.
>
>
>> Suddenly
>> I'm bumping into limitations of Applescript for things I want to
>> do, and
>> they're not necessarily to do with hooking apps up (which I know
>> how to
>> ask for help for from the mailing list) as much as fairly simple
>> 'unixy'
>> things to do with strings, simple XML and regexes, plus the stuff
>> about
>> basic program design, flow control &c.
>
> Well I don't really know too much about Applescript and whether you
> could
> use it to do things you want, but Ruby certainly is able to do all
> these
> things.
> For xml parsing, there's Hpricot and there are very nice tutorials
> about it, also, there
> is rio
>
> http://rio.ruby... ,
>
> for i/o processing, which I use very often.
> As you go, you'll find that many other packages are distributed
> in a nice way as "gems", which you can easily install and work with
> right away.
>
>
>> (and regexes and hashes if I can cautiously start to get my head
>> round them).
>
> A hash is just a dictionary, that associates a set of keys to some
> other set, the set of values. These can be of all kinds:
>
> english_german={'head'=>['Kopf','Haupt','Hydrozephalus'],
> 'body'=>'Koerper','foot'=>'Fuss',number_of_feet_in_humans=>2}
>
> For Regexps, there is a nice tutorial here:
>
> http://www.regular-expressions.info...
>
> Ruby has extensive online documentation,
>
> http://www.rubycentral...
>
> Personally, I've also liked Hal Fulton's book
> "The Ruby Way" with its many examples a great deal.
>
>> Especially if somebody would tell me it's really easy to compile
>> from source under Darwin, because the last time I tried to compile
>> from
>> source it was in an abortive attempt to learn Linux several years
>> ago,
>> with
>> several unfriendly problems, and I'm scared.
>
> Ruby should be there right away, if you have OS 10.2 or later.
> But it is certainly a good idea to be able to compile something
> from source, if you want to work with packages .. you can move this to
> next week, though.
>
>
>
>> --
>> The (...and where are all those cartoon foxes, anyway? Could do with
>> seeing a friendly face...) MacRubyist
>
> You can also learn Ruby from comics - here: http://
> poignantguide.net/ruby
>
> Best regards,
>
> AQxel
> --
> Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
> Browser-Versionen downloaden: http://www.gmx.net/de/...
>
Welcome !
There is also an AppleScript gem. Once you get comfy with Ruby and
RubyGems, you can use the AppleScript Gem to write Ruby in place of
AppleScript for scripting applications on your mac!

Tim Hunter

6/17/2007 4:14:00 PM

0

The MacRubyist wrote:
> Anybody out there who's patient and willing to give a newby help if
> required?
>

Welcome to Ruby!

Check out http://rubymentor.rubyforge.org/wi.... This is targeted
directly at folks like you.

Good luck. Remember you can always ask questions here.

--
RMagick OS X Installer [http://rubyforge.org/project...]
RMagick Hints & Tips [http://rubyforge.org/forum/forum.php?for...]
RMagick Installation FAQ [http://rmagick.rubyforge.org/instal...]


The MacRubyist

6/17/2007 5:45:00 PM

0


"Axel Etzold" <AEtzold@gmx.de> wrote:

[very useful hints and bits snipped, will definitely look at this stuff]

Unfortunately, the very first real-world Ordinary Stupid Problem i
actually want to solve is that the flow of control in one of my Applescripts
that creates text data and saves it in a small bunch of XML files (which
i use because my boyfriend pointed out that XML works well as a Better
Text File) is slightly wonky and won't iterate through the last file, so
i'd actually quite like to implement the
iterate-through-small-bunch-of-files thing in Ruby. I know the basics of using the DOM in as simple
and easy way as I can get away with.
Having just run irb so far because am slightly scared of getting into
compilation and package management without using binaries, (and I tried
telling Tiger to 'require gems' and it didn't like that, which presumably
means i have to download & compile) would you advise me to:
a) debug my Applescript properly by staring at it until I grow
cross-eyed, because debugging is good experience and then i won't be tempted to
jump ahead too far just to get something to work.
b) try to compile and install Gems so I can have a go at using the
packages that will give me an XML parser
or

c) Take a Deep Breath and start from the beginning with the Pickaxe and
Why's cartoon book, desperately reining in my desire to work with any
real-world data at all until I've got the hang of the basics, at which
point I can 'plumb in' actual data, because the reason I want to have a go
at Ruby In The First Place is to take a step back and learn from the
ground up to avoid the heaving mass of spaghetti code I can see in my
future if I keep learning Applescript as self-taught with nobody to talk to.
The (...still nervous...) MacRubyist

SonOfLilit

6/17/2007 6:31:00 PM

0

Don't install gems.

Instead, install a more recent version of Ruby than what comes with oyur mac.

First, download the graphic installer for ports or fink, then

port install ruby

or

fink install ruby


and you're set.


Have you joined my RubyMentor project? Are they treating you nicely? :)


Aur

On 6/17/07, The MacRubyist <macrubyist@ntlworld.com> wrote:
>
> "Axel Etzold" <AEtzold@gmx.de> wrote:
>
> [very useful hints and bits snipped, will definitely look at this stuff]
>
> Unfortunately, the very first real-world Ordinary Stupid Problem i
> actually want to solve is that the flow of control in one of my Applescripts
> that creates text data and saves it in a small bunch of XML files (which
> i use because my boyfriend pointed out that XML works well as a Better
> Text File) is slightly wonky and won't iterate through the last file, so
> i'd actually quite like to implement the
> iterate-through-small-bunch-of-files thing in Ruby. I know the basics of using the DOM in as simple
> and easy way as I can get away with.
> Having just run irb so far because am slightly scared of getting into
> compilation and package management without using binaries, (and I tried
> telling Tiger to 'require gems' and it didn't like that, which presumably
> means i have to download & compile) would you advise me to:
> a) debug my Applescript properly by staring at it until I grow
> cross-eyed, because debugging is good experience and then i won't be tempted to
> jump ahead too far just to get something to work.
> b) try to compile and install Gems so I can have a go at using the
> packages that will give me an XML parser
> or
>
> c) Take a Deep Breath and start from the beginning with the Pickaxe and
> Why's cartoon book, desperately reining in my desire to work with any
> real-world data at all until I've got the hang of the basics, at which
> point I can 'plumb in' actual data, because the reason I want to have a go
> at Ruby In The First Place is to take a step back and learn from the
> ground up to avoid the heaving mass of spaghetti code I can see in my
> future if I keep learning Applescript as self-taught with nobody to talk to.
> The (...still nervous...) MacRubyist
>
>
>

Samantha

6/17/2007 6:31:00 PM

0

On Sun, 17 Jun 2007 19:05:05 +0900
The MacRubyist <macrubyist@ntlworld.com> wrote:

>
> Anybody out there who's patient and willing to give a newby help if
> required?
>

I can tell you that this list is full of patient people. I have been
frequenting (and lurking on and off) this list for almost 6 months now
(maybe a little more) and I've gotten some great input and great help.

Someone pointed out the RubyMentor project which is an awesome resource.

Thanks,
Samantha
--
http://www.bab...

"Beware when the great God lets loose a thinker on this planet. Then all
things are at risk."
--Ralph Waldo Emerson

Bill Guindon

6/17/2007 6:37:00 PM

0

On 6/17/07, The MacRubyist <macrubyist@ntlworld.com> wrote:
>
> "Axel Etzold" <AEtzold@gmx.de> wrote:
>
> [very useful hints and bits snipped, will definitely look at this stuff]
>
> Unfortunately, the very first real-world Ordinary Stupid Problem i
> actually want to solve is that the flow of control in one of my Applescripts
> that creates text data and saves it in a small bunch of XML files (which
> i use because my boyfriend pointed out that XML works well as a Better
> Text File) is slightly wonky and won't iterate through the last file, so
> i'd actually quite like to implement the
> iterate-through-small-bunch-of-files thing in Ruby. I know the basics of using the DOM in as simple
> and easy way as I can get away with.

That's pretty much the first thing I did with Ruby, it's fairly
simple, and a good way to learn.

> Having just run irb so far because am slightly scared of getting into
> compilation and package management without using binaries, (and I tried
> telling Tiger to 'require gems' and it didn't like that, which presumably
> means i have to download & compile) would you advise me to:
> a) debug my Applescript properly by staring at it until I grow
> cross-eyed, because debugging is good experience and then i won't be tempted to
> jump ahead too far just to get something to work.
> b) try to compile and install Gems so I can have a go at using the
> packages that will give me an XML parser
> or

I suggest 'b'. No compile needed. Just download from rubyforge,
unzip it, and then run:
ruby setup.rb

> c) Take a Deep Breath and start from the beginning with the Pickaxe and
> Why's cartoon book, desperately reining in my desire to work with any
> real-world data at all until I've got the hang of the basics, at which
> point I can 'plumb in' actual data, because the reason I want to have a go
> at Ruby In The First Place is to take a step back and learn from the
> ground up to avoid the heaving mass of spaghetti code I can see in my
> future if I keep learning Applescript as self-taught with nobody to talk to.
> The (...still nervous...) MacRubyist

Nothing to fear here. Give it a shot, you'll be pleasantly surprised.

--
Bill Guindon (aka aGorilla)
The best answer to most questions is "it depends".

Axel Etzold

6/17/2007 7:56:00 PM

0

Dear MacRubyist,

> Unfortunately, the very first real-world Ordinary Stupid Problem i
> actually want to solve is ...

it's always good to work on or towards the solution of real world
problems - that keeps you focused ... there are piles of dust
tossing themselves up on books I wanted to work through from A-Z
to get to know about some topic in a theoretic way -- it never came true.

> Having just run irb so far because am slightly scared of getting into
> compilation and package management without using binaries, (and I tried
> telling Tiger to 'require gems' and it didn't like that, which presumably
> would you advise me to:

I would advise that you put off the idea that you must iterate
through files for, say, one day and try and work through
Chris Pine's book, which is on the web (see my last post).
It introduces you to some of the very basic
features of the language, and doesn't take long to go through.
Just try some of his exercises and this will raise your mood,
because everything will work, and it will work much sooner
than for other computing languages.
You don't need to install anything or compile anything for that.

After having completed Chris Pine's book, you will feel strong enough
to kill one the dinosaurs he makes you look at in the last chapter,
then you should follow the advice about how to get hpricot and/or
rio to work on a Mac ( just ask again if it doesn't work),
and try some of the examples on the website tutorials of these
packages.

From the many responses you already got you can see that there are some people around who can and will help you.

So, welcome again, and good luck,

Best regards,

Axel




--
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/g...

The MacRubyist

6/18/2007 8:41:00 AM

0


Thanks for all the help, everyone.

Am now almost brave enough to try compiling ruby. :-) Hope the World Has
Moved On since I tried to learn Linux several years ago, and tended to
have little success with compiling from source.
The (...hoping to become less of a Nervous Nuby...) MacRubyist

James Gray

6/18/2007 1:50:00 PM

0

On Jun 17, 2007, at 5:05 AM, The MacRubyist wrote:

> Especially if somebody would tell me it's really easy to compile
> from source under Darwin, because the last time I tried to compile
> from
> source it was in an abortive attempt to learn Linux several years
> ago, with
> several unfriendly problems, and I'm scared.

This is a good set of compiling instructions for Ruby on Mac OS X:

http://hivelogic.com/narrative/articles/ruby-rails-mongrel...

Just skip the instructions for the applications you don't need.

James Edward Gray II