Should I Learn Ruby as a First Language?

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

···

On May 28, 2:36 pm, Kyle Schmitt <kyleaschm...@gmail.com> wrote:

Since nobody's posted it...xkcd: Electric Skateboard (Double Comic)

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.

====

LearnRuby.com offers Rails & Ruby HANDS-ON public & ON-SITE
workshops.
   Ruby Fundamentals Wkshp June 16-18 Ann Arbor, Mich.
   Ready for Rails Ruby 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.

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 Wednesday 28 May 2008 13:36:30 Kyle Schmitt 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).

Kyle Schmitt 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:

···

--
Posted via http://www.ruby-forum.com/\.

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.

Hi forgottenwizard,

Thank you for that info, that is good to know, as I have concluded
that I will need to study C eventually, and something like this sounds
as though it will be very useful.

Happy Hacking,

Maurice

My two cents worth:

Ruby is a good first language to learn if you are really really young
and you are just learning something, because ruby is designed in a way
that lets us apply regular thinking methods. If you are a child,
5.times do something makes more sense than for (i=0; ....). However,
if you are a little older and are able to grasp concepts, then you
might be better off learning C.

One reason C is advantageous is it forces you to learn algorithms and
the inner working of "methods" in ruby for instance. It is entirely
possible for a person who has only learned ruby to never bother about
how a sort is implemented. This may or may not matter to you in the
end, but learning C, as someone else said earlier, really makes you
appreciate Ruby, Java etc. Also, going from Ruby to C might be hard
because it might seem like you are always writing code for tasks that
are so trivial in Ruby. So I suggest you learn C first.

Hope that helps.

Jayanth

Hello Kyle,

Since nobody's posted it...xkcd: Electric Skateboard (Double Comic)

I see what is meant there.

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.

That resonates with what I had considered in relation to C. I have
also concluded that I should read "Write Great Code" I & II, as those
address becoming acquainted with the bare metal from a programmer's
perspective.

Cheers,

Maurice

Hi David,

Thank you for your post.

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

I want to program for myself, for clients, and contribute to FOSS
projects, and take it all as far as I can.

Still depends -- for example, if you just want to be able to contribute to the
most FOSS possible, learn C. The vast majority of FOSS projects are in C,
among them some of the better known. It might be nice to know some value of P
in a "LAMP stack" -- Perl/PHP/Python/Ruby -- but pretty much the entire rest
of the stack will be written in C. Maybe a bit of shell scripts, but the
shell itself is written in C.

If, on the other hand, you want to write brand new apps, from the ground up --
or you want to interface with all these existing apps, but not actually patch
them -- then Ruby is as good a choice as any.

But these don't matter as much, since you've indicated a more academic
curiosity -- you'll probably learn both anyway, and more.

I hear you, I am mostly interested in web applications, yet also want
to explore desktop applications for Mac OS X . . . and the more I read
about Lisp, the more interesting it becomes . . .

I suspect that Ruby has more LISPisms than Python. Either would be good for
GUI OS X apps and web apps.

···

On Thursday 29 May 2008 06:54:54 MRH wrote:

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: "Mark Wilden" <mark@mwilden.com>

  From: "Yukihiro Matsumoto" <matz@ruby-lang.org>
  To: <ruby-core@ruby-lang.org>
  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

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.

···

On Wed, May 28, 2008 at 3:54 PM, Mark Wilden <mark@mwilden.com> wrote:

On May 28, 2008, at 11:36 AM, Kyle Schmitt 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.

--
Rick DeNatale

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

But, many don't seem to realize that the other languages are
protecting them and carry unnecessary techniques from C to the higher
level language.

···

On Thu, May 29, 2008 at 7:45 AM, Dave Bass <davebass@musician.org> wrote:

Kyle Schmitt wrote:

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

--
Rick DeNatale

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

I agree, although I will devote some time to becoming acquainted with
the lower level, just enough to broaden my perspective I think.

···

On May 28, 2:54 pm, Mark Wilden <m...@mwilden.com> wrote:

On May 28, 2008, at 11:36 AM, Kyle Schmitt 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

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

Hi Eric,

I agree. Thank you for your post.

Cheers,

Maurice

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.

David,

Thank you for this post. I also agree.

Is it just me or is the web interface for posting here actually
PAINFUL to use?

Best,

Maurice

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:

Hi Dave,

Thank you for your post. As I have mentioned, I believe I will study C
and those texts so as to become acquainted with the lower level
concepts.

Best,

Maurice

Woot, i love those questions :slight_smile:

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

C definitely is valuable. I dont like C, but there is,
in the long run, not really a way around C.

But Ruby is about 1000x nicer than C and I hope one
day we can use nice languages rather than ugly ones. :wink:

What you should also keep in mind is that if you already
know Ruby well, learning C can be boring, because 95% of
what C does, Ruby does too - shorter and nicer for the
human being.

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 think both will be a good choice and fill almost the same
niche. I think people that use python or ruby are much
more in the same boat than other languages (i.e. than
in java). The amount of static languages, and the code,
is monumental. I am afraid of the day an autonomous
space ship with robots that colonialize other planets is
empowered by java....

So my personal recommendation is, if you have no time pressure
etc... is that you should learn C first, even if ruby is
a lot more fun (because you will learn ruby a lot easier
anyway and it doesnt matter much when you start learning it IMO.) :slight_smile:

···

--
Posted via http://www.ruby-forum.com/\.

Hello Jayanth,

An interesting and helpful post, thank you. I did find a free online
book on Data Structures and Algorithms in Ruby . . . posted it to
Reddit Ruby, and some folks stated that it did not use idiomatic
Ruby . . . I am going to tackle that one anyway however.

Regards,

Maurice

···

On May 29, 7:21 am, Srijayanth Sridhar <srijaya...@gmail.com> wrote:

My two cents worth:

Ruby is a good first language to learn if you are really really young
and you are just learning something, because ruby is designed in a way
that lets us apply regular thinking methods. If you are a child,
5.times do something makes more sense than for (i=0; ....). However,
if you are a little older and are able to grasp concepts, then you
might be better off learning C.

One reason C is advantageous is it forces you to learn algorithms and
the inner working of "methods" in ruby for instance. It is entirely
possible for a person who has only learned ruby to never bother about
how a sort is implemented. This may or may not matter to you in the
end, but learning C, as someone else said earlier, really makes you
appreciate Ruby, Java etc. Also, going from Ruby to C might be hard
because it might seem like you are always writing code for tasks that
are so trivial in Ruby. So I suggest you learn C first.

Hope that helps.

Jayanth

Still depends -- for example, if you just want to be able to contribute to the
most FOSS possible, learn C. The vast majority of FOSS projects are in C,
among them some of the better known. It might be nice to know some value of P
in a "LAMP stack" -- Perl/PHP/Python/Ruby -- but pretty much the entire rest
of the stack will be written in C. Maybe a bit of shell scripts, but the
shell itself is written in C.

I see.

If, on the other hand, you want to write brand new apps, from the ground up --
or you want to interface with all these existing apps, but not actually patch
them -- then Ruby is as good a choice as any.

Good to know.

But these don't matter as much, since you've indicated a more academic
curiosity -- you'll probably learn both anyway, and more.

Thank you, that is encouraging.

I suspect that Ruby has more LISPisms than Python.

So have I read, so have I read . . . that is actually one of main
reasons (out of many) why I am interested in Ruby: a rather well known
Lisp hacker has on several instances expressed his opinion that Ruby
is quite similar to Lisp.

Either would be good for
GUI OS X apps and web apps.

Also good to know.

From: "Yukihiro Matsumoto" <matz@ruby-lang.org>
To: <ruby-core@ruby-lang.org>
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

···

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

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

···

--
RMagick: http://rmagick.rubyforge.org/
RMagick 2: http://rmagick.rubyforge.org/rmagick2.html

Rick Denatale wrote:

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.

It's a question of whether you learn top-down, or bottom-up. Different
people have different learning preferences.

Traditionally technical subjects have been taught bottom-up in academia
("building on a firm foundation"), but there are very good arguments for
the top-down approach too.

···

--
Posted via http://www.ruby-forum.com/\.