Should I Learn Ruby as a First Language?

Hello Group,

I realize this question has been previously asked in different boards,
however, I believe that it is worth asking here owing to the level of
expertise present.

I am a beginner in programming. I have read some fundamental theory
material and mucked around a bit, and now want to move into actually
learning programming and my first language.

Throughout my research into this question, I have seen that the more
credible sources recommend either Python or Ruby, and I am personally
leaning quite heavily toward Ruby, yet I would very much like to read
the thoughts of the group on this question.

Thanking everyone beforehand,

Maurice

In article
[email protected],
MRH [email protected] wrote:

however, I believe that it is worth asking here owing to the level of
expertise present.

That is one way to avoid being sent to Google :wink:

learning programming and my first language.

I learned by doing, in perl, and think it worked well

credible sources recommend either Python or Ruby, and I am personally
leaning quite heavily toward Ruby, yet I would very much like to read

You’ll have to learn more than one language anyway, so why not just
start with one and try the other in 2 weeks time? They’re not that hard.

Educationally Python might make more sense since it has less syntax (no
blocks)

But my real advice is to find a problem you really care about, than look
which language has the best library for it, and go with that. You won’t
learn anything from example code in books.

(I learned/wrestled PHP just to use an ID3 tag library. A while ago I
ported all my code to ruby and use pipes to communicate with a very
small PHP script wrapping getID3)

On Wednesday 28 May 2008 07:45:00 MRH wrote:

Throughout my research into this question, I have seen that the more
credible sources recommend either Python or Ruby, and I am personally
leaning quite heavily toward Ruby, yet I would very much like to read
the thoughts of the group on this question.

Depends what you want to do, and how far you want to go.

For a first language, either Python or Ruby are fine. Python has
stricter
syntax, but I suspect Ruby has stricter concepts (of OO, etc). I find
Ruby
easier to read, but that’s an opinion.

If you want to get a good concept of programming in general, you should
learn
(and develop at least some small apps in) a variety of languages – and
a
variety of very different languages.

So, at least one language low-level enough not to do garbage collection
(C,
ASM, etc), at least one high-level “scripting” language (Ruby, Python,
Perl,
JavaScript), at least one purely functional language (Haskell), and I’ll
throw in LISP and either Erlang or Smalltalk.

I’m not sure it matters what order you do this in – pick whichever has
the
best absolute beginner books. I would suggest a tight feedback loop for
learning, though – look for interactive interpreter shells (Python,
IRB),
and avoid compilers (C, C++, Java).

And others will have other lists.

If you don’t have that kind of attention span, or if you’re looking to
learn
what it takes to get stuff done now, that depends very much on what you
want
to do. For example, if you’re planning to do game development, you’re
probably going to have to know C++, and definitely at least C. If you’re
just
looking to automate some high-level tasks on Unix, learn Bash. And so
on.

MRH wrote:

I am a beginner in programming. I have read some fundamental theory
material and mucked around a bit, and now want to move into actually
learning programming and my first language.

Once upon a time I used to teach C as a first programming language. In
some ways it’s good, as it’s close to the hardware (bits and bytes,
addresses and pointers etc) but in many other ways this can be a
disadvantage, as you can’t see the wood for the trees. However, it
certainly makes you appreciate higher-level languages when you come
across them later on!

Java now seems to be the first language of choice for many universities,
but I would have to disagree with that.

Ruby is much nicer than Java and it will teach you plenty of OO
concepts.

However, there’s no such thing as the “best” language, so you should
concentrate on mastering one, then go on to your next.

  • MRH, 2008-05-28, 21:45:

I am a beginner in programming. I have read some fundamental theory
material and mucked around a bit, and now want to move into actually
learning programming and my first language.

Which programming language to start with is a question that precisely
has one and only one answer: It depends.

If your primary aim is directly programming hardware it would make
sense to learn C as a first programming language. For other primary
aims Java may be a good choice.

If you are rather a generalist and interested in using a wide range of
programming paradigms and fields of applications Ruby or Python are
good choices.

Consider visiting http://python.about.com/ and http://ruby.about.com/
before deciding which of the two languages to learn. I personally
prefer Ruby for its syntax but other people prefer Python for precisely
the same reason.

Josef ‘Jupp’ Schugt

On May 28, 2008, at 6:01 AM, Tobias W. wrote:

But my real advice is to find a problem you really care about, than
look
which language has the best library for it, and go with that. You
won’t
learn anything from example code in books.

That is such good advice. Programming and cooking are two areas in
which you can both learn and benefit from the result.

///ark

On 22:04 Wed 28 May , David M. wrote:

I’m not sure it matters what order you do this in – pick whichever has the
best absolute beginner books. I would suggest a tight feedback loop for
learning, though – look for interactive interpreter shells (Python, IRB),
and avoid compilers (C, C++, Java).

Actually, TinyCC has a C interpreter that you can use to test code, so
there isn’t much need to compile when you are using it.

I believe there is a Windows and a *nix version, so there shouldn’t be a
problem with platforms.

On May 28, 7:43 am, MRH [email protected] wrote:

Throughout my research into this question, I have seen that the more
credible sources recommend either Python or Ruby, and I am personally
leaning quite heavily toward Ruby, yet I would very much like to read
the thoughts of the group on this question.

Thanking everyone beforehand,

Maurice

Hi Maurice,

I’m new to this as well. Here’s a link to a resource that can maybe
help you find/learn ruby info - (there are a lot of others up there if
you just search) Flashcards, notes and learning tools online: YoYoBrain.com.

I hope it helps! Let me know what you think about it too.

Best,

Elizabeth

On Wed, May 28, 2008 at 09:45:00PM +0900, MRH wrote:

Throughout my research into this question, I have seen that the more
credible sources recommend either Python or Ruby, and I am personally
leaning quite heavily toward Ruby, yet I would very much like to read the
thoughts of the group on this question.

I usually lump beginner programmers into one of two categories, (i)
those
who want to become expert programmers for purposes of education,
profession, or hobby, and (ii) those who are interested in learning how
to
program sufficiently enough to make work in their primary careers
easier,
but don’t necessarilly have a specific interest in programming itself.

If you’re of the former category, I would say it doesn’t really matter
what
lanaguage you learn first since you will inevitably learn multiple
languages anyways. Remember that a master programmer is not someone who
expertly understands the minutiae of any single language, but rather is
someone who is proficient in many languages. This is largely due to the
fact that all programming languages seek to achieve that same high-level
goal–enable programmers to use a machine to perform computation–and
yet
each language achieves this goal in a different and nuanced way. It’s
the understanding of these nuances, and why they exist, that paints the
overall picture.

That said, there are a lot of languages out there that are complicated
or
even cumbersome because they attempt to be sufficiently general as to
allow
any “style” of programming without enforcing too strict of rules as to
what
code should look like. Perhaps the best example of this phenomenon is
C++,
and to a lesser extent Perl. I express caution in learning these
languages
as first languages, since, as a novice programmer you don’t really have
an
intuition for what code should look like, and the language doesn’t
really
help guide you in learning either.

Ruby is guilty of a similar phenomenon which, in this context, goes by
the
name of “expressiveness”. While Ruby is certainly my favorite language,
I
know that part of my appreciation for this expressiveness comes from
over a
decade of experience in other languages and being able to place Ruby in
the context of this experience.

In other words, I’m not really sure if Ruby is the best, or even a good
language for beginners because I’m not sure how difficult it is to learn
without the benefit of experience. On the other hand, plenty of people
have learned Ruby as their first language and have gone on to recommend
it
to others, so it’s certainly possible, and probably not a bad choice
either.

That said, keep in mind that Ruby is a bit unique compared to other
popular
languages. For example, the idiom of using internal iterators and
blocks
as looping constructions (e.g., Enumerable#each) is unlike the usual
approach of using a for loop and/or external iterator as you would use
in
C, C++, Java, or Python. While I think Ruby’s approach is better, it is
not the norm in other languages. Another example is Ruby’s idiom of
automatic allocation and deallocation of resources by passing them to
code
blocks (e.g., File#open). In other languages, one typically has to
explicitly deallocate the resource (close the file) and the code for
writing this safely is not intuitive.

This brings up another advantage/disadvantage of learning Ruby first:
code
safetyness. One example of this is the resource allocation/deallocation
idiom I mentioned above that ensures that resources are always properly
cleaned up when the program is finished with their use. Another is
that
most methods raise an exception upon encountering an error, forcing a
program to abort is an unexpected error happens.

Exceptions are good, and they’re prominent in other languages (Java and
Python) and behave, more or less in the same way. Unfortunately some
popular languages implement exceptions (C++ and Perl) but don’t use them
universally in library functions, and other languages © don’t
implement
them at all. In these languages, you must (or at least should) check
return values of any function you call to make sure that the desired
action
performed successfully. Often times people forget to do this, and the
result is code that continues on ignoring error conditions, usually
blowing
up somewhere else where it’s difficult to debug.

So, while I regard these features as advantages of Ruby, they are, in
some
sense a disadvantage when you attempt to learn a different language that
doesn’t take care of these issues for you, as you must be diligent in
taking care of them yourself and it’s not something you’re used to.

Anyways, the crux of my advice is this: Any language that you’re
enthralled by, and can’t get enough of, is a good (first) language to
learn. On the other hand, any language that you find bewildering,
confusing, or just plain unfun to learn is probably not a good first
language candidate. If you find youself becoming disinterested after
spending a week or two learning whatever language you choose, skip it
and
move on to something else. It may take a while to find the language
that
fits, but trial and error is better than giving up on programming
entirely–especially when the language that clicks with you is right
around
the corner.

Briefly getting back to the other category of beginner programmers,
those
that are not particularly interested in programming itself but recognize
that some proficiency is beneficial for getting their work done–if
you’re
only going to learn one language and you’re not sure which, both Python
and
Ruby are reasonable choices. The argument is that since you’re only
going
to learn one language, you might as well learn one that’s useful enough
to
enable you to accomplish a wide variety of tasks, and one that’s popular
enough that there are many libraries, tutorials, and resources available
for helping you get the job done. Python might be a bit superior with
regard to popularity, at least in the English speaking community. At
one
time Perl was much more so, but I wouldn’t consider any beneift in
greater
popularity of Perl to be worth the pain of having to deal with it’s
obtuseness.

Mike K. wrote:

On Wed, May 28, 2008 at 09:45:00PM +0900, MRH wrote:

I usually lump beginner programmers into one of two categories, (i)
those
who want to become expert programmers for purposes of education,
profession, or hobby, and (ii) those who are interested in learning how
to
program sufficiently enough to make work in their primary careers
easier,
but don’t necessarilly have a specific interest in programming itself.

If you’re of the former category, I would say it doesn’t really matter
what
lanaguage you learn first since you will inevitably learn multiple
languages anyways. Remember that a master programmer is not someone who
expertly understands the minutiae of any single language, but rather is
someone who is proficient in many languages. This is largely due to the
fact that all programming languages seek to achieve that same high-level
goal–enable programmers to use a machine to perform computation–and
yet
time Perl was much more so, but I wouldn’t consider any beneift in
greater
popularity of Perl to be worth the pain of having to deal with it’s
obtuseness.

Excellent answer !
Aplausos !!

Since nobody’s posted it…

Ruby is an awesome language, highly abstracted from the hardware,
incredibly flexible and fluid, and probably not a good first language
just for those reasons alone.

Learn C first.

To really get programming, to understand what’s going on, you need to
go deep. All the way down to C (though some say assembler).

C is the lingua franca of computers. It doesn’t make things easy for
you, it doesn’t make things pretty, or necessarily intuitive, but it
does bring you right down to the metal in the end.

It isn’t flexible, when you have to tell it to do something, you have
to tell it exactly what to do, And C will do it, even if it’s not a
good idea, even if it crashes.
You grab your own memory, and are responsible for putting it back.
You make and move pointers to access the memory: if you point to the
wrong place, you’ll get the wrong data, corrupt your own program, and
probably crash it.
You’ve got to link your own binaries, and link them to the right
libraries.

And doing all that makes you a better programmer, makes you understand
what really is going on behind the scenes. Not to mention makes you
appreciate languages like ruby, perl, python and java so much more
when you get to them :slight_smile:

I don’t think you necessarily should program your first projects in C,
but you should learn C as a first language, even if you don’t use it
for your first projects. Even if you never use it outside of studying
it.

–Kyle

On May 28, 2008, at 11:36 AM, Kyle S. wrote:

Learn C first.

As someone who learned UCSD Pascal first, and then went on to
assembler, then C, I disagree. :slight_smile:

You don’t have to be able to overhaul an engine to ride on a train.
You should always take the easiest way that fulfills your goals.

I was a Classical Studies major at university. People would always
say, “Oh, I wish I’d learned Latin!” Idiots. :slight_smile: Yeah, learning Latin
will help you learn French, etc. But if you want to learn French, you
should just learn French.

We only have a limited amount of time in our lives. Any time spent
learning a bad language like C is time we can’t spent learning
something else - like how to write maintainable, well-tested code.

Taken to its logical extreme, you should really know how to design
digital circuits before you jump into C. Would it make you a better
Ruby programmer? Absolutely! What would make you an even better Ruby
programmer, however, is learning Smalltalk or Scheme or TDD or Rails.
Limited time means you can’t learn everything. Make sure what you
learn is actually useful.

Learning C means not learning something else.

///ark

On Wednesday 28 May 2008 13:36:30 Kyle S. wrote:

Learn C first.

To really get programming, to understand what’s going on, you need to
go deep. All the way down to C (though some say assembler).

And that’s the point, really. Some say assembler. You say C. I say
neither, or
it depends.

I would say, start with something like Ruby or Python. There’s a minimum
of
busywork between you and what you actually want to make. It’ll get you
in,
and get you hooked.

It also means you’ll have a solid grasp of a few core concepts before
moving
on to C. You won’t spend the whole time learning what a variable is, or
what
a function is, because you’ll already know how to program. Instead,
you’ll
spend your time learning all that depth knowledge you’re talking about
– how
to allocate memory, what a pointer is, etc.

But it’s not really a closed debate, by any means. I started (barely)
with
QBASIC (multiple choice quizzes with if/then/else) – didn’t really
learn to
program until I got a good book on C++. So I pretty much did the
opposite of
what I’m advocating here.

And I stand by, whichever has the best book. Once you know one language
well,
learning another is much easier – it’s those first baby steps that are
difficult.

On May 28, 2:36 pm, Kyle S. [email protected] wrote:

probably crash it.
it.
I strongly disagree with this opinion. If the goal is to start
closer to the hardware, then why isn’t assembly language even better?
It’s like saying to learn sociology you first need to learn
psychology, but before that neurology, preceded by neurochemistry, but
only after biochemistry, which of course follows chemistry, but which
can only come after physics…

Just as there are useful concepts and abstractions within sociology, a
high level programming language provides you with abstractions (loops,
objects, exceptions, iterators, closures, etc.) that are useful in
their own right. You do not have to learn what’s happening behind the
scenes first to understand or leverage these concepts.

You can’t learn everything at once. You have to learn things
incrementally, and given human psychology, it tends to work best if
along the way you are able to do useful and interesting things.

Now does learning C or assembly language at some point make you a
better programmer? Absolutely! But it doesn’t have to be first, or
even second or third. Why make learning unnecessarily painful when it
can be coincidentally fun?

Eric

====

LearnRuby.com offers Rails & Ruby HANDS-ON public & ON-SITE
workshops.
Ruby Fundamentals Wkshp June 16-18 Ann Arbor, Mich.
Ready for Rails R. Wkshp June 23-24 Ann Arbor, Mich.
Ruby on Rails Wkshp June 25-27 Ann Arbor, Mich.
Ruby Plus Rails Combo Wkshp June 23-27 Ann Arbor, Mich
Please visit http://LearnRuby.com for all the details.

From: “Mark W.” [email protected]

We only have a limited amount of time in our lives. Any time spent
learning a bad language like C is time we can’t spent learning
something else - like how to write maintainable, well-tested code.

Uhhhhhhhh… From matz, two days ago on ruby-core: [16910]

From: “Yukihiro M.” [email protected]
To: [email protected]
Sent: Monday, May 26, 2008 8:18 AM
Subject: Re: [PATCH] lambda with normal block syntax

[…] I program in C more than Ruby

So… matz has implemented ruby in a “bad language” ?

Personally I find it extremely useful to be fluent in the
language that Ruby is written in. Ruby would be a lot less
useful to me if I weren’t able to write my own ruby
extension modules. . . . Which requires a knowledge of C,
if one is using Matz’ ruby. (Obviously if I were using
JRuby, knowledge of C wouldn’t be anywhere near as relevant.)

I’m not convinced someone should learn C before ruby,
however I find C to be an extremely vaulable language to
know.

Regards,

Bill

On May 28, 2008, at 3:13 PM, Bill K. wrote:

From: “Yukihiro M.” [email protected]
To: [email protected]
Sent: Monday, May 26, 2008 8:18 AM
Subject: Re: [PATCH] lambda with normal block syntax

[…] I program in C more than Ruby

If you’re writing Ruby, as opposed to doing applications programming,
that makes sense!

So… matz has implemented ruby in a “bad language” ?

It’s funny. I used to work at Sierra On-Line (a long time ago) where
we used a home-grown OOP language to write adventure games. The guy
who wrote the language was without doubt the smartest person I’ve ever
worked with. But he actually had very little OOP experience, and I was
able to teach him a thing or two about using his own language!

All that’s to say that “Matz uses C more than Ruby” doesn’t really
bear on which is the better language. However, I should have said that
C is a “bad” language for applications, in the sense that Ruby is much
better!

Personally I find it extremely useful to be fluent in the
language that Ruby is written in. Ruby would be a lot less
useful to me if I weren’t able to write my own ruby extension
modules. . . . Which requires a knowledge of C,
if one is using Matz’ ruby. (Obviously if I were using
JRuby, knowledge of C wouldn’t be anywhere near as relevant.)

That’s great, but it doesn’t apply to most people.

I’m not convinced someone should learn C before ruby,
however I find C to be an extremely vaulable language to know.

As someone who’s quoted in the GNU C FAQ, I probably have as great an
appreciation of C as anyone. I just think its sell-by date has passed
for most applications. On the other hand, I wouldn’t write a device
driver in Ruby.

///ark

Bill K. wrote:

Personally I find it extremely useful to be fluent in the
language that Ruby is written in. Ruby would be a lot less
useful to me if I weren’t able to write my own ruby extension modules. .
. . Which requires a knowledge of C,
if one is using Matz’ ruby. (Obviously if I were using
JRuby, knowledge of C wouldn’t be anywhere near as relevant.)

I’m not convinced someone should learn C before ruby,
however I find C to be an extremely vaulable language to know.

+1. I read this quote from somebody smart: “C is the atmosphere in which
we live.”

Although I learned (and earned my living with) assembly language many
years ago, I don’t think it’s particularly necessary to learn it now
unless you’re working in a very specialized area, like compilers,
graphics drivers, etc. But C is still hugely popular and widely used and
having it in your toolchest will be useful for many years to come.

However, even though C is a small language (compared to Java or C++) I
think it’s harder to learn than Ruby, and learning it will be more
frustrating since it takes so much more code to get results and it’s so
easy to make mistakes that are really, really hard to fix. I’ve been
doing it for 25 years now and I still spend more of my time finding and
fixing bugs than I do writing code.

Kyle S. wrote:

Learn C first.

To really get programming, to understand what’s going on, you need to
go deep. All the way down to C (though some say assembler).

C is the lingua franca of computers. It doesn’t make things easy for
you, it doesn’t make things pretty, or necessarily intuitive, but it
does bring you right down to the metal in the end.

This is exactly why we chose C as the first language for electronic
engineering and information systems engineering students. Previously the
course had been given in Algol 68 (!), then Pascal, but it was decided
that C would be a much better foundation, and useful in the real world
too.

C is very hard to learn. Almost everybody comes unstuck on pointers and
memory allocation. But this trains your mind, and once you’ve learnt C,
you realise what other languages are protecting you from, and how they
work internally (since most are written in C, like Ruby).

Recently some ex-students of mine contacted me via a social networking
site to thank me, saying that C had been very valuable to them in their
careers.

If the OP wants a good foundation in programming, C will provide it. But
Ruby would be gentler. :slight_smile:

On Wed, May 28, 2008 at 3:54 PM, Mark W. [email protected] wrote:

I was a Classical Studies major at university. People would always say, “Oh,
I wish I’d learned Latin!” Idiots. :slight_smile: Yeah, learning Latin will help you
learn French, etc. But if you want to learn French, you should just learn
French.

And while learning Latin, might help some learn French up to a point,
I’d argue that knowledge of one language can also interfere REALLY
learning another, related or not, if one can’t accept that the second
language really doesn’t operate exactly like the other.
While Latin had a large influence on the evolution of French, it’s
only one influence. This is true, I suspect to an even larger degree
to English, which was influenced by a long succession of native
tongues and the tongues of various conquerors and invaders.

There’s a long history of English grammarians clinging to the myth
that English grammar must follow Latin grammar, leading to bogus rules
like the injunction against splitting an infinitive, which is common
in English usage, but impossible in Latin since the infinitive is a
single word. Yes, if Star Trek were translated to latin, something
would have to be done with “To boldly go,…” but in English it’s
perfectly good and understandable usage IMHO.

The concerns when programming in a low-level language like C are quite
different than those when programming in a higher-level language like
Ruby. In C one must worry about issues like storage management,
ensuring that one doesn’t copy the wrong kind of data from one
variable to another, possibly causing buffer overflow or underflow,
confusing a pointer with data, etc. All on top of (or perhaps
beneath) application level concerns.

It seems to me that people who start with a language like C are much
more likely to be overly concerned about the problems they’ve
encountered coming out of these low-level technical concerns, which
for the most part are handled by the language and its runtime rather
than the programmer in a language like Ruby leading to stilted,
chicken-typed code.

This is not to say that it’s a bad think to learn C, or Latin. But I
firmly believe that for most people this should come later as a way to
expand understanding of how higher-level languages are implemented and
extended, not as a first step to inform how one should think about
higher-level languages.

Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

Tobias:

Thank you for your reply.

I learned by doing, in perl, and think it worked well

I agree, and plan on using that approach.

You’ll have to learn more than one language anyway

Quite true, and I plan on a few . . . I am just debating which one to
try first . . .

Educationally Python might make more sense since it has less syntax (no
blocks)

I will keep that in mind.

But my real advice is to find a problem you really care about, than look
which language has the best library for it, and go with that. You won’t
learn anything from example code in books.

Had also planned on this.

Cheers,

Maurice