Printing why's (poignant) guide to ruby

/me notes that he's writing a ruby parser using python's pyggy library
its a nice and easy language, just that ruby's blocks ain't complex, new
programs follow easy rules ("stick {} around the block"), and list comprehensions required an explanation for me. and i'm not exactly a newbie programmer. ruby's blocks just clicked, no tutorial needed, i grabbed the stdlib read the syntax files typed in a few examples from programming ruby and haven't stopped reading ri since.

Alex

···

On Feb 14, 2005, at 7:10 PM, James G. Britt wrote:

On Tue, 15 Feb 2005 02:39:08 +0900, Marcus Sharp > <brothermarcus@gmail.com> wrote:

*putting on flame retardant pants*

As a noob to Ruby who was convinced to try it after reading why's
wonderful work, i will say that i find Ruby "harder" than Python. To
call Python a "joke of a language" is pretty harsh by the way.

It is not merely harsh; it is incorrect. Most people here prefer Ruby
to Python, but don't simply dismiss Python either.

Navindra Umanee ha scritto:

I honestly think things like blocks are not a trivial matter.

Why:

5.times { print "hello " }

instead of:

5 times print hello

just my two cents:
maybe the point is starting withouth using blocks.
I found them hard too, when I initially started learning ruby , but I could write cute programs (the usual web scraping, irc bots and such) without using them. As of current ruby you can write net applications, XMLRPC clients, access SOAP funny things withouth ever seing a block.
Then, you have an "ah-ha!" moment and you become happyer :slight_smile:

Is not like explaining why in python:
  fun=lambda a: print(a)
does not work, or what
  foo.bar=fun.__get__(foo)
is supposed to do is /that/ obvious :slight_smile:

there is always a learning curve, sadly.

Michael Walter wrote:

The Ruby user would think "Who puts?" :slight_smile:

Michael

> Ruby:
>
> (hello.rb)
> puts "Hello World"

"Hello, world!".display

···

Anders Engström <aengstrom@gnejs.net> wrote:

google is your friend :slight_smile:

http://www.google.nl/search?hl=en&lr=&q=learning+to+program+ruby&btnG=Search

Alex

···

On Feb 14, 2005, at 12:19 AM, Navindra Umanee wrote:

Alexander Kellett <ruby-lists@lypanov.net> wrote:

i'm really puzzled by this.
why python? or even worse. vb??!!

How is a total beginner going to learn Ruby? By reading Pickaxe? I'm
not talking about a CS student here. My dad lives half-way around the
world from me.

Navindra Umanee, 13/2/2005 20:19:

i'm really puzzled by this.
why python? or even worse. vb??!!

How is a total beginner going to learn Ruby? By reading Pickaxe? I'm
not talking about a CS student here. My dad lives half-way around the
world from me.

Besides, Python is a more restricted and syntactically uniform
language. Ruby is more flexible and expressive, but IMHO to really
understand the code you have to know more CS concepts and have a
deeper understanding of the syntax than some people like to admit.

Even though in Ruby you can abuse the syntax or treat it glibly --
which makes it look like a nice thing for experienced programmers -- I
think it is better to understand what you are doing first. Python
forces you to understand these issues.

I prefer Ruby but I think Python will be easier for a beginner to
grasp at the beginning, and it has less hurdles as well
documentation/book-wise -- I even saw one of the beginner books
describe how to implement a neat graphical game in a few steps.

And yeah, VB has wizards and stuff on top of plenty of documentation.
Like I said, quicker gratification can be a good thing. Someone used
to fancy windows and GUI stuff probably isn't going to be happy stuck
at the command-line level. Joao makes a good point, of course.

Someone posted this code here:
def fib:
  a, b = 1, 1
  while true:
    yield a
    a, b = b, a+b

It fails. Ask why! Because are missing '()' after 'fib'.
Ruby is more prolixe. It's bad to refactoring tools, but is easier for the ones who can't remember the names of everything.
Isn't a good thing you got errors because is missing a space, or because you couldn't choose a number so great
(try
j = 0
for i in range(1000000000):
     j = j + 1

).

···

Alexander Kellett <ruby-lists@lypanov.net> wrote:

reading this again. still shocked...

How is a total beginner going to learn Ruby? By reading Pickaxe? I'm
not talking about a CS student here. My dad lives half-way around the
world from me.

already answered this one.

Besides, Python is a more restricted and syntactically uniform
language. Ruby is more flexible and expressive, but IMHO to really
understand the code you have to know more CS concepts and have a
deeper understanding of the syntax than some people like to admit.

python is confusing as hell. you try to explain why they have to
get the indent levels right on every line. people can't even deal
with the correctness of html (as is obvious given the shit on the web)
never mind python.

Even though in Ruby you can abuse the syntax or treat it glibly --
which makes it look like a nice thing for experienced programmers -- I
think it is better to understand what you are doing first. Python
forces you to understand these issues.

ummm... without some backup i'd have to say you're trolling.

I prefer Ruby but I think Python will be easier for a beginner to
grasp at the beginning, and it has less hurdles as well
documentation/book-wise -- I even saw one of the beginner books
describe how to implement a neat graphical game in a few steps.

chris pines tutorial answers this problem already.
anyways. this is about materials. i doubt that you're
really expecting to shove the python stdlib documentation
in front of your father and get a regexp engine out of
him in the coming days...

And yeah, VB has wizards and stuff on top of plenty of documentation.
Like I said, quicker gratification can be a good thing. Someone used
to fancy windows and GUI stuff probably isn't going to be happy stuck
at the command-line level. Joao makes a good point, of course.

okay. i don't even want to start on this point because it
means one inevitable thing.

<rant>

sorry but this is just getting stupid. "fancy windows and gui stuff"
are you talking about vb? the confusing as crap to advanced and beginner
users piece of cruft that m$ managed to build over the last 10 years
with seemingly no real advancements whatsoever? non resizable interfaces,
awful damn confusing language syntax, slow as hell on old machines.

gimme my a nicely syntax highlighted irb with gui builder integration
anyday over this crap!

</rant>

···

On Feb 14, 2005, at 12:19 AM, Navindra Umanee wrote:

No. Ruby is only complex when you work on complex problems. (I mean
that in the sense that the complexity allows for elegant solutions.
Rails for example). When Ruby is used as a tool to teach programming,
there is no reason to use any of the complex constructs.

Python's procedural mix only works against itself for when used to
learn programming.

For someone who is new to programming
"string".display
wouldn't feel less natural than
print "string"

Really, think about that.

And why should we try to teach them the procedural paradigm and then
say 'Hey! forget all that stuff you learnt. It's not really a good way
to program. Now i'll teach you the object-oriented way" ?

Of course, all of this I say assuming that the goal is to create an
object-oriented programmer, not a procedural one.

···

On Mon, 14 Feb 2005 08:19:20 +0900, Navindra Umanee <navindra@cs.mcgill.ca> wrote:

Alexander Kellett <ruby-lists@lypanov.net> wrote:

Besides, Python is a more restricted and syntactically uniform
language. Ruby is more flexible and expressive, but IMHO to really
understand the code you have to know more CS concepts and have a
deeper understanding of the syntax than some people like to admit.

--
Gavri
---------------------------------------------------
I blog here: http://gavri.blogspot.com

Hi,

Seriously, Python, Ruby, C, Java, Smalltalk, etc are all *great*
languages. The *best* learn-to-program language/environment is probably
Squeak, it is pretty much designed just for that, and oh yeah, is a
pretty good Smalltalk implementation too :wink:

Have you seen this interview by Alan Kay?
http://acmqueue.org/modules.php?name=Content&pa=showpage&pid=273

He says that Smalltalk has become more of a pro-tool and less of a
teaching environment since its beginnings.

Cheers,
Joao

thanks. glad someone said it.

Alex

···

On Feb 14, 2005, at 7:40 PM, Brian McCallister wrote:

If you have trouble explaining blocks, though, wait until you go for list comprehensions!

i did note that it was a rant...

the problem is the defensive attitude and
bringing up of python in obviously non
related threads. its getting me a tad </sarcasm>
irritable.

Alex

···

On Feb 14, 2005, at 10:45 PM, James G. Britt wrote:

Thanks Marcus, I have to admit some of the comments are making me lose
my cool here. The profanity, and accusations of trolling (with
simultaneous attacks on Python) as well as my unfortunate lack of
sleep are all adding up.

Please take into account that most folks here do not look down on
Python on Python developers. We just don't care for it, finding Ruby
to be a better personal choice. Though some would express their
tastes using stronger terms ...

Brian McCallister ha scritto:

If you have trouble explaining blocks, though, wait until you go for list comprehensions!

   ^^^^^^^^^^^^^^^^^^^
more fun with generator expressions :smiley:

Ok, that's probably more intuitive :slight_smile: But not if you want to achieve the
same effect as 'puts'. Then you'd have to change it to:

    "Hello World!\n".display

That '\n' is pretty confusing for a newbie.

//Anders

···

On Mon, Feb 14, 2005 at 08:19:57AM +0900, William James wrote:

Michael Walter wrote:
> The Ruby user would think "Who puts?" :slight_smile:
>
> Michael
>
> Anders Engström <aengstrom@gnejs.net> wrote:
> > Ruby:
> >
> > (hello.rb)
> > puts "Hello World"

"Hello, world!".display

--
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. Anders Engström aengstrom@gnejs.net
. http://www.gnejs.net PGP-Key: ED010E7F
. [Your mind is like an umbrella. It doesn't work unless you open it.]

Um yeah the whole program is syntactically wrong. Fortunately Python
tells you there's an error on practically every single line.

Learning and understanding syntax is one of the first steps of a
newbie, even with something like Scheme which doesn't really have much
of a syntax. I believe it is an important first step.

If you don't have a clue about the basics like this, you'll soon fail
miserably whether you're using Ruby or not. And come-on, who's going
to explain yield and blocks to a newbie?

Why do you think Java became so popular? The creators have often said
it is because the language started out with a relatively small number
features and wasn't overwhelming to intermediate programmers.

I'm trying to context-switch to the point of view of a newbie. I
believe starting small is important when learning.

Cheers,
Navin.

···

Caio Tiago Oliveira <caiot1@ibest.com.br> wrote:

def fib:
  a, b = 1, 1
  while true:
    yield a
    a, b = b, a+b

It fails. Ask why! Because are missing '()' after 'fib'.

FWIW, from my experience "people" have very few problems understanding
indentation in Python.

Michael

···

On Tue, 15 Feb 2005 00:41:45 +0900, Alexander Kellett <ruby-lists@lypanov.net> wrote:

reading this again. still shocked...
On Feb 14, 2005, at 12:19 AM, Navindra Umanee wrote:
> Besides, Python is a more restricted and syntactically uniform
> language. Ruby is more flexible and expressive, but IMHO to really
> understand the code you have to know more CS concepts and have a
> deeper understanding of the syntax than some people like to admit.
python is confusing as hell. you try to explain why they have to
get the indent levels right on every line. people can't even deal
with the correctness of html (as is obvious given the shit on the web)
never mind python.

Joao Pedrosa wrote:

Have you seen this interview by Alan Kay?
http://acmqueue.org/modules.php?name=Content&pa=showpage&pid=273

He says that Smalltalk has become more of a pro-tool and less of a
teaching environment since its beginnings.

Yes, but at the same time, he devotes a lot of his time to support the Etoys environment within Squeak which is meant for teaching young kids how to author various Media (not just programming) on the computer. Take it from me, I have done this at my son's school ( 6th and 7th grade) and it was very successful. More about it here: http://www.squeakland.org

In my opinion Logo or Etoys is the best way to introduce programming to kids. I tried Ruby a couple of times, but it did not work out quite like the others. Of course, YMMV !

Cheers,
Joao

HTH,
-- shanko

Hi,

For someone who is new to programming
"string".display
wouldn't feel less natural than
print "string"

Really, think about that.

And why should we try to teach them the procedural paradigm and then
say 'Hey! forget all that stuff you learnt. It's not really a good way
to program. Now i'll teach you the object-oriented way" ?

No, you don't go paradigm-swapping on them. When it gets to a point
where it makes a difference, let them know that "puts" is the short
form of "STDOUT.puts". Tell them that STDOUT is an object that is
created for you, which can recieve messages that, among other things,
help you write to the screen. Have them write a little code using
STDOUT. Then tell them that the short form is easier, and more
commonly used.

Of course, all of this I say assuming that the goal is to create an
object-oriented programmer, not a procedural one.

I suspect the goal is to create a Ruby programmer :slight_smile: Which means that
there will be some amount of overlapping.

cheers,
Mark

···

On Tue, 15 Feb 2005 01:04:22 +0900, Gavri Fernandez <gavri.fernandez@gmail.com> wrote:

Anders Engström, 13/2/2005 21:03:

···

On Mon, Feb 14, 2005 at 08:19:57AM +0900, William James wrote:

Michael Walter wrote:
> The Ruby user would think "Who puts?" :slight_smile:
>
> Michael
>
> Anders Engström <aengstrom@gnejs.net> wrote:
> > Ruby:
> > > > (hello.rb)
> > puts "Hello World"

"Hello, world!".display

Ok, that's probably more intuitive :slight_smile: But not if you want to achieve the
same effect as 'puts'. Then you'd have to change it to:

    "Hello World!\n".display

That '\n' is pretty confusing for a newbie.

"Hello world!
I'm here.
".display

Without "\n"!

Anders Engström wrote:

That '\n' is pretty confusing for a newbie.

How do you know that?

I'd be interested in any good sources that detail the sort of things different types of newbies find troublesome or confusing.

Offhand, I don't quite see that "\n" would be such a problem given a reasonably succinct explanation. My own experience with teaching programming newbies suggests that most of them are comfortable with fairly straight-forward edicts (e.g., "That's just how you tell the computer to start writing to a new line").

It's the more abstract stuff (e.g., blocks, high-order functions, even the notion of a variable) that spooks them.

James

> def fib:
> a, b = 1, 1
> while true:
> yield a
> a, b = b, a+b
>
> It fails. Ask why! Because are missing '()' after 'fib'.

Um yeah the whole program is syntactically wrong. Fortunately Python
tells you there's an error on practically every single line.

Whoops. Okay the whole program is not syntactically wrong... I cut
and paste the code into the interpreter instead of trying it from a
file, so it rejected everything since it couldn't get past the first
line.

I also got confused seeing "yield" there. Hmm, I didn't know Python
supported that.

Later,
Navin.

Hi,

Um yeah the whole program is syntactically wrong. Fortunately Python
tells you there's an error on practically every single line.

This is the required behaviour of good languages. When there is a
detectable error, tell it to the user/programmer.

Learning and understanding syntax is one of the first steps of a
newbie, even with something like Scheme which doesn't really have much
of a syntax. I believe it is an important first step.

Every step is important, even making money after getting to know the
language better. :slight_smile:

If you don't have a clue about the basics like this, you'll soon fail
miserably whether you're using Ruby or not. And come-on, who's going
to explain yield and blocks to a newbie?

We just take what we can handle. No need to explain everything that a
language can do before someone can write his programs. I remember a
kid that would use lots of lines in his code until he learned how to
make a loop.

Why do you think Java became so popular? The creators have often said
it is because the language started out with a relatively small number
features and wasn't overwhelming to intermediate programmers.

Java was meant was an embedded systems language. It is obviously being
used in wrong places than its creators had envisioned.

Why don't you let him learn Java, then? The same language of the pros?
That's right. It certainly isn't the most newbie-friendly language out
there. It demands lots of reading/asking/figuring out until one can be
reasonably proficient with it. But I know that some kids love Java.
They are 12 or 13 years old and already do some Java. So it's
possible. :slight_smile:

That said, the reason that I don't use Java is probably because
Microsoft didn't support it in a good way and never will. So while
Java and DotNet are fighting, I prefer to try to eat their lunch. :slight_smile:

I'm trying to context-switch to the point of view of a newbie. I
believe starting small is important when learning.

We are the guys who make languages, tools, operating systems and
programs complex in the first place. I don't think that we can think a
lot like the users of our systems.

Cheers,
Joao