Why is it so difficult to learn Ruby for me ?

P

Paganoni

No, it's not a troll.

I love Ruby. I mean, this is the only language that I read and write
with a lot pleasure but I must be honest, I have also great difficulties
to learn it.

I'm 40+ years old, I used to be a geek but I'm no more. My knowledge is
deeply formated by old static languages. I learned Basic, then
Assembler, then Pascal. I discovered object programming with Pascal, and
over the years had some experiments with C++ and Java. I disliked C++, I
liked Java but I disliked the J2E environment. Even if J2E was bloated I
found Java programming principles very logical for me, very familiar.
In the meantime I did a lot of PHP (3 & 4) programming to earn money.

Then I discovered Ruby on Rails and loved it immediately. I never coded
in PHP since, and will never again. I'm not pro or cons any language, I
was just ultra fed up with the tools I used every day and RoR saved my
job. That was 3 years ago. Since, I've coded several web sites and
applications, each time using better practices and I'm pretty proud of
the cleanliness of my current works.

But my Ruby learning curve is still flat.

I'm still thinking in Ruby as I did in C++ or Java (as I did in Pascal
in fact). I tried countless times to learn Ruby concepts, but each time
they faded away from my mind few hours later. I've read books, plenty of
articles found on the web but I'm still at loss.

I even tried some Ruby Quiz but they imply a double effort : solve the
problem AND think in Ruby. Too much for me.

So, I'm more or less to the Pickaxe level. But a great part of the code
written by best Rubyist or Railers is very very far away from that and I
can read it easily (or even at all).


What can I do to improve my ruby skills ?
 
R

Robert Klemme

No, it's not a troll.

I love Ruby. I mean, this is the only language that I read and write
with a lot pleasure but I must be honest, I have also great difficulties
to learn it.

I'm 40+ years old, I used to be a geek but I'm no more. My knowledge is
deeply formated by old static languages. I learned Basic, then
Assembler, then Pascal. I discovered object programming with Pascal, and
over the years had some experiments with C++ and Java. I disliked C++, I
liked Java but I disliked the J2E environment. Even if J2E was bloated I
found Java programming principles very logical for me, very familiar.
In the meantime I did a lot of PHP (3 & 4) programming to earn money.

Then I discovered Ruby on Rails and loved it immediately. I never coded
in PHP since, and will never again. I'm not pro or cons any language, I
was just ultra fed up with the tools I used every day and RoR saved my
job. That was 3 years ago. Since, I've coded several web sites and
applications, each time using better practices and I'm pretty proud of
the cleanliness of my current works.

But my Ruby learning curve is still flat.

I'm still thinking in Ruby as I did in C++ or Java (as I did in Pascal
in fact). I tried countless times to learn Ruby concepts, but each time
they faded away from my mind few hours later. I've read books, plenty of
articles found on the web but I'm still at loss.

I even tried some Ruby Quiz but they imply a double effort : solve the
problem AND think in Ruby. Too much for me.

So, I'm more or less to the Pickaxe level. But a great part of the code
written by best Rubyist or Railers is very very far away from that and I
can read it easily (or even at all).


What can I do to improve my ruby skills ?

That's a tough one as you seem to have exhausted pretty much every other
learning tool. Maybe you are underestimating your skills - at least you
managed to put several web applications into life.

Two ideas come to mind: try to get hands on a tutor that you can sit
together and maybe solve a few of those Ruby quizzes talking about the
code as you write it.

Another option would be to try to investigate which concepts you feel
you are failing to understand and ask specific questions over here.
Maybe you'll even find answers already by diving into the archives.

Hope that helps.

Kind regards

robert
 
P

Paganoni

le 21/03/2009 16:43, Paganoni nous a dit:
So, I'm more or less to the Pickaxe level. But a great part of the code
written by best Rubyist or Railers is very very far away from that and I
can read it easily (or even at all).

Typo : I can'T read it easily (or even at all).
 
P

Pascal J. Bourguignon

Paganoni said:
I'm still thinking in Ruby as I did in C++ or Java (as I did in Pascal
in fact). I tried countless times to learn Ruby concepts, but each
time they faded away from my mind few hours later. I've read books,
plenty of articles found on the web but I'm still at loss.
[...]
What can I do to improve my ruby skills ?

- learn Smalltalk, or
- learn Scheme or Common-Lisp.

Actually, it may be enough for you to understand the fundamental
difference between the object-oriented programming language you know,
and Ruby, Smalltalk, Scheme, Lisp (and also Python, Perl and PHP):

In C++, Java or Pascal, the variables are typed: you cannot put in a
variable a value of a different type than the one declared for the
variable. This allow the compilers of these languages to _blindly_
apply an operation on the value stored in a variable, as long as this
operation is compatible with the type of that variable. Theorically,
it should be safe enough. In practice, there may be loopholes allowing
to store random bit patterns in variables and thus breaking the
programs (true mostly of C++, but it's easily done in Pascal too, less
easily in Java).

In Ruby, Smalltalk, Scheme, Lisp, etc, it's the _values_ that are
typed, variable are entirely untyped: you can assign any type of value
to any variable. The operations can and do check the type of the
values they're applied on and either implement generic behavior (do
something different for each type of value) or signal an error (at
run-time). Since it is impossible (or very hard) to have invalid bit
patterns in values, it's almost impossible to make programs break
(basically, you can do it when you have access to a "FFI" a Foreign
Function Interface which let you fall back to C-level programming and
all it's unsafeness).


Well to allow for OO polymorphism, statically typed programming
languages may implement partially such run-time value-dependent
dispatching of polymorph operations, so as long as you declare your
variables as being of type some root class, you can store in them
values of any subclass type (notice that in C++ there's no single root
class, you can have as many class hierarchies as you want, so you
cannot store instances of subclasses of another hierarchy. And in any
case, in these programming languages, there are types that are not
classes, the Plain Old Data types such as integer (even if as you know
Java defines corresponding classes).


In dynamically typed programming languages such as Ruby, Smalltalk,
Scheme, Lisp, etc, all the values have a class, even simple integers,
and operations can be dispatched on their class.


So basically, in Ruby (and other dynamically typed programming
languages), all the values are objects, and only objects have a type
(a class). Everything is an object (even classes and methods). And
since variables are not typed, you can define generic operations that
work on more than one type of values, even classes that are not
defined at the time you write the operation. This is what let these
language be very extensible.
 
P

Paganoni

le 21/03/2009 17:24, Robert Klemme nous a dit:
That's a tough one as you seem to have exhausted pretty much every other
learning tool. Maybe you are underestimating your skills - at least you
managed to put several web applications into life.

Two ideas come to mind: try to get hands on a tutor that you can sit
together and maybe solve a few of those Ruby quizzes talking about the
code as you write it.

Another option would be to try to investigate which concepts you feel
you are failing to understand and ask specific questions over here.
Maybe you'll even find answers already by diving into the archives.

Yes, these applications are up & running. The next one will be quite big
(at least for me). But it seems that I'm always polishing Rail's concept
without enhancing Ruby's concepts.

The idea of a tutor is good, but unfortunately there are none around
here...

About investigating some concepts : In fact, it's more a practice
problem than an understanding problem. For example, I understand
closures, even if subtleties are out of reach, but I never use them
because I'm so "static language" formatted that no ideas come to me on
everyday use.

Same with methods definitions : I understand that a method can be
defined to a class, all the instances or a specific instance (become a
duck) but 100% of the time I'm defining methods like I would do in Java.
And my classes never "mutilate" themselves as some well known Ruby
software does.

May be I should find good books, like "Design Patterns in Ruby"... Do
you have some references of books going quite far with some care for old
programmers like me :) ?
 
P

Paganoni

le 21/03/2009 18:25, Pascal J. Bourguignon nous a dit:
Paganoni said:
I'm still thinking in Ruby as I did in C++ or Java (as I did in Pascal
in fact). I tried countless times to learn Ruby concepts, but each
time they faded away from my mind few hours later. I've read books,
plenty of articles found on the web but I'm still at loss.
[...]
What can I do to improve my ruby skills ?

- learn Smalltalk, or
- learn Scheme or Common-Lisp.

Actually, it may be enough for you to understand the fundamental
difference between the object-oriented programming language you know,
and Ruby, Smalltalk, Scheme, Lisp (and also Python, Perl and PHP):

Your answer is quite surprising to me. Why do you tell me to learn one
of those languages instead of learning Ruby ? I know that they
historically provided most of the concepts of modern languages but why
not to learn them with Ruby ?
 
P

Phlip

Paganoni said:
May be I should find good books, like "Design Patterns in Ruby"... Do
you have some references of books going quite far with some care for old
programmers like me :) ?

My favorite answer in these forums is: "How are your unit tests?"

You just can't underestimate their impact on your mindset...
 
P

Phlip

Paganoni said:
Your answer is quite surprising to me. Why do you tell me to learn one
of those languages instead of learning Ruby ? I know that they
historically provided most of the concepts of modern languages but why
not to learn them with Ruby ?

Because the first, deepest schism in the OO languages are between the Incorrect
ones and the Correct ones. (Aka Static Typing and Dynamic Typing, respectively.)

Dynamic Typing ("Duck Typing") is about emergent behavior, whereas Static Typing
is about negative reinforcement - investing your fear of emergent behavior into
all kinds of restrictions in your code.

So learn other Duck Typing languages, too...
 
R

Robert Klemme

Yes, these applications are up & running. The next one will be quite big
(at least for me). But it seems that I'm always polishing Rail's concept
without enhancing Ruby's concepts.

Maybe that's not needed for the types of applications you do. Who knows?
The idea of a tutor is good, but unfortunately there are none around here...

Maybe you just post a piece of code here that you feel is not well
crafted and listen to the responses you get.
About investigating some concepts : In fact, it's more a practice
problem than an understanding problem. For example, I understand
closures, even if subtleties are out of reach, but I never use them
because I'm so "static language" formatted that no ideas come to me on
everyday use.

Maybe your problems do not lend themselves to being treated with
closures. Use the right tool for the job. I mean, you do not have to
have all design patterns in one application, do you? Use what works and
fits the situation. If you discover that it doesn't work or does not
work too well, look for another tool.
Same with methods definitions : I understand that a method can be
defined to a class, all the instances or a specific instance (become a
duck) but 100% of the time I'm defining methods like I would do in Java.

The difference is not that big: in Java you can define methods for
classes (static) and instances (non static). The role that class level
and instance level methods play in all OO languages is roughly the same.
And my classes never "mutilate" themselves as some well known Ruby
software does.

May be I should find good books, like "Design Patterns in Ruby"... Do
you have some references of books going quite far with some care for old
programmers like me :) ?

IIRC there was a recommendation recently here (less than two months
ago). I'm sure you can dig that up by looking for "patterns".

Kind regards

robert
 
R

Robert Klemme

Because the first, deepest schism in the OO languages are between the
Incorrect ones and the Correct ones. (Aka Static Typing and Dynamic
Typing, respectively.)

Dynamic Typing ("Duck Typing") is about emergent behavior, whereas
Static Typing is about negative reinforcement - investing your fear of
emergent behavior into all kinds of restrictions in your code.

That's a bit too much psychological terminology for my taste. Both
approaches have pros and cons, deeming one of them "incorrect" is not
fair and not helpful as well. Defensiveness can be a virtue in some
cases, in other it hinders productivity. For example, I tend to believe
that you can write very robust and bug free software with design by
contract. This is not necessarily fast but there are areas of software
engineering where robustness is paramount while time to market isn't.

Having said that I do support the point that learning more languages is
helpful because it fills your "toolbox". Whether it is helpful for OP I
am not sure.

Cheers

robert
 
P

Paganoni

le 22/03/2009 13:00, Phlip nous a dit:
My favorite answer in these forums is: "How are your unit tests?"

You just can't underestimate their impact on your mindset...

I unit test the most I can under RoR (it means more and more with wy the
improvement of my RoR skills) but I never unit test nothing when I'm
just trying to play with Ruby to understand some of its features...

Should I ?
 
P

Pascal J. Bourguignon

Paganoni said:
le 21/03/2009 18:25, Pascal J. Bourguignon nous a dit:
Paganoni said:
I'm still thinking in Ruby as I did in C++ or Java (as I did in Pascal
in fact). I tried countless times to learn Ruby concepts, but each
time they faded away from my mind few hours later. I've read books,
plenty of articles found on the web but I'm still at loss.
[...]
What can I do to improve my ruby skills ?
- learn Smalltalk, or
- learn Scheme or Common-Lisp.
Actually, it may be enough for you to understand the fundamental
difference between the object-oriented programming language you know,
and Ruby, Smalltalk, Scheme, Lisp (and also Python, Perl and PHP):

Your answer is quite surprising to me. Why do you tell me to learn one
of those languages instead of learning Ruby ? I know that they
historically provided most of the concepts of modern languages but why
not to learn them with Ruby ?

That's because learning these programming languages you don't learn
idiosyncratic features, but you learn fundamental concepts, and that's
these concepts that you need to understand, because they are what
really differenciate the languages.

I'm afraid that Ruby tutorials concentrate more on the syntax and
gratuituous shortcuts provided by Ruby than on the fundamental
concepts.

For example, in the world of scheme, there's the seminal work SICP:

SICP = Structure and Interpretation of Computer Programs
http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html
http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/
http://www.codepoetics.com/wiki/index.php?title=Topics:SICP_in_other_languages
http://eli.thegreenplace.net/category/programming/lisp/sicp/

You may have the impression that this is about scheme, but actually
not the least. This book only uses scheme as an algorithmic notation
for its examples, but what it teaches are concepts that are appliable
to all programming languages. (Well in some programming languages it
may be harder to express them; for example, when you reach the chapter
4, you may have some difficulties in Ruby because it's not a
homoiconic programming language, but you may make do with arrays of
symbols instead of s-exps).
 
M

matt neuburg

Pascal J. Bourguignon said:
I'm afraid that Ruby tutorials concentrate more on the syntax and
gratuituous shortcuts provided by Ruby than on the fundamental
concepts.

That is the answer I was going to give to the OP's original question.

When I started to learn Ruby, it seemed to be all about syntax: this is
a string, this is what you can do with it; this is an array; this is a
hash; this is how we use "each" instead of looping. Classes were just a
convenience, and modules were just namespaces, off the stratosphere
somewhere, a kind of icing on the cake.

I call that way of talking about Ruby "bottom-up". Bottom-up Ruby is
attractive, but it doesn't get at what Ruby really *is*, and by the time
the student gets to what Ruby really is, exhaustion has settled in.

Well, that was the wrong way to show me Ruby. My experience is that it
is much better to expose newbies to Ruby "top-down": everything is an
object, the most important kind of object is Module and "def", then
Class, then instance... You can learn about playing with strings and
arrays and hashes any time, but if you don't understand Module from the
get-go, if you don't understand the relationship between instance and
Class and Module, you'll never grok what's going on in any serious Ruby
program.

So my answer to the OP's question is that he's having trouble because
he's been approaching Ruby backwards (or upside-down). m.
 
E

Eric Jacoboni

My experience is that it
is much better to expose newbies to Ruby "top-down": everything is an
object, the most important kind of object is Module and "def", then
Class, then instance...

In my University, a few years ago i've suggested to use Ruby as the "first one" language
to learn programming instead of Pascal...
Over the last years, i've noticed that the main difficulty is not with
the "absolute beginners" students, but with my colleagues who are
helping me to teach it.

When it comes to loops, for instance, the "each" paradygm seem
"unnatural" to them as they use to consider a loop as an external
process, not as a behavior of the data itself. So, they tend to use
"for", "while", "until" loops as there are the ones they learn
themselves when they're was students...

Same things with arrays: it seems natural for them to consider that an
array has always indexes, and they even think they could loop over an
array without using indexes.

Beginners don't have this problem...
 
P

Phlip

Paganoni said:
I unit test the most I can under RoR (it means more and more with wy the
improvement of my RoR skills) but I never unit test nothing when I'm
just trying to play with Ruby to understand some of its features...

You have presented with the complaint that you are productive in RoR, but don't
feel dangerous in Ruby yet.

The next questions are:

- do you rigorously test_first_, so tests fail before you pass them?
- do you refactor _mercilessly_, to try to DRY up all your code?

As a fellow tetragenarian, I too formerly did the static language thing -
without unit tests. I got so "good" at debugging that, the larger the project,
the more cumulative debugging it would require. That's why I have switched,
quite permanently, to dynamic languages and TDD. And that is the urgency which
propels all my current research...

Should I ?

When you noodle around to learn a language, not to write production code, just
do anything you like...
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top