# Ruby and C

**URL:** <https://www.ruby-forum.com/t/ruby-and-c/92773>\
**Category:** Ruby\
**Created:** [April 24, 2007, 2:28am UTC](https://www.ruby-forum.com/t/ruby-and-c/92773 "2007-04-24T02:28:14Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![smc\_smc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@smc\_smc](https://www.ruby-forum.com/u/smc_smc)\
**Post date:** [April 24, 2007, 2:28am UTC](https://www.ruby-forum.com/t/ruby-and-c/92773/1 "2007-04-24T02:28:14Z")

</div>

Would it be easier to learn ruby if i knew C/C+/C++ or the other way  
around?

---

<div class="post-metadata">

**Author:** ![smc\_smc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@smc\_smc](https://www.ruby-forum.com/u/smc_smc)\
**Post date:** [April 24, 2007, 2:56am UTC](https://www.ruby-forum.com/t/ruby-and-c/92773/2 "2007-04-24T02:56:16Z")

</div>

I think it’s a better way that konw more about OO

---

<div class="post-metadata">

**Author:** ![smc\_smc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@smc\_smc](https://www.ruby-forum.com/u/smc_smc)\
**Post date:** [April 24, 2007, 3:31am UTC](https://www.ruby-forum.com/t/ruby-and-c/92773/3 "2007-04-24T03:31:18Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

smc smc wrote:

> Would it be easier to learn ruby if i knew C/C+/C++ or the other way  
> around?

It is easier to learn _programming_ in Ruby than in C/C++. However, the  
languages are different enough that if you _need_ to know C/C++, I’d  
focus on learning that, rather than learning Ruby first.

* * *

M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P)  
[http://borasky-research.net/](http://borasky-research.net/)

If God had meant for carrots to be eaten cooked, He would have given  
rabbits fire.  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v2.0.3 (GNU/Linux)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org](http://enigmail.mozdev.org)

iD8DBQFGLV1TIqRAswy4LDARAunrAJ9huLG8ggodLsvajD4DvKVwxia1HACgldxO  
lI0RbQtf+Kx0lrcfPowIPyc=  
=zlEL  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![smc\_smc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@smc\_smc](https://www.ruby-forum.com/u/smc_smc)\
**Post date:** [April 24, 2007, 3:49am UTC](https://www.ruby-forum.com/t/ruby-and-c/92773/4 "2007-04-24T03:49:20Z")

</div>

smc smc wrote:

> Would it be easier to learn ruby if i knew C/C+/C++ or the other way  
> around?

I’m biased since I learned C in 1985, but if you don’t know C (or  
better, assembler) then you really don’t know what your program is  
doing. The Ruby translator is written in C, the core libraries and many  
standard libraries are written in C, and many things in Ruby (printf,  
for example) are named after the well-known C equivalents.

There are those who can argue eloquently that you don’t need to know  
what your program is doing at the C level and they’re very persuasive.  
At this point I can’t decide if they’re right or wrong. All I know is  
that when I write Ruby code I frequently think about how such-and-such  
Ruby abstraction is _really_ implemented in C.

In any case you can’t go wrong learning C. Somebody said that C is so  
pervasive that it’s “the atmosphere in which we live.”

---

<div class="post-metadata">

**Author:** ![smc\_smc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@smc\_smc](https://www.ruby-forum.com/u/smc_smc)\
**Post date:** [April 24, 2007, 6:43am UTC](https://www.ruby-forum.com/t/ruby-and-c/92773/5 "2007-04-24T06:43:28Z")

</div>

get the book by Chris P., Learn to Program.  
It’s cheap and small and interesting. Mr. Pine uses it to teach  
beginning programming to kids. He chooses to teach them Ruby rather  
than other languages. Ruby gets out of the way most of the time. It  
lets you focus on the skill of creating a program. Designing it and  
testing and running it. In C this is a much more complicated task. If  
you starting out, C will throw a lot of things at you at once.  
If you need to learn some programming concepts, Ruby is a great place  
to start.

But learning C is a good goal too. It really is the Latin of computer  
languages. Many ideas and traditions come out of decades of C culture.

That said, either way you’ll be fine, but get yourself a good text  
editor which does colors and (if possible) auto completion. Learn to  
use the command line too. Buy a good reference book for Unix.

---

<div class="post-metadata">

**Author:** ![smc\_smc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@smc\_smc](https://www.ruby-forum.com/u/smc_smc)\
**Post date:** [April 24, 2007, 5:50am UTC](https://www.ruby-forum.com/t/ruby-and-c/92773/6 "2007-04-24T05:50:26Z")

</div>

On Apr 23, 5:27 pm, “smc smc” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Would it be easier to learn ruby if i knew C/C+/C++ or the other way around?

As others have mentioned, there are pluses and minuses to either  
approach. Here is my take on either scenario:

1. C first, Ruby next: You learn the intricacies and then get spoiled  
with the ease-of-use later and appreciate each language.
2. Ruby first, C next: Easy learning with forgivable syntax. When you  
learn C, you’ll find it “verbose” and strict.

---

<div class="post-metadata">

**Author:** ![smc\_smc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@smc\_smc](https://www.ruby-forum.com/u/smc_smc)\
**Post date:** [April 24, 2007, 7:02am UTC](https://www.ruby-forum.com/t/ruby-and-c/92773/7 "2007-04-24T07:02:29Z")

</div>

John J. wrote:

> get the book by Chris P., Learn to Program.

[http://pine.fm/LearnToProgram/](http://pine.fm/LearnToProgram/)

To sneak a peak, you can find a complete tutorial (I don’t have the book  
itself, and thus cannot comment on the completeness of the content in  
comparison to the book) to programming in general and Ruby especially.

Of course, \_why’s poignant guide shouldn’t be amiss in Ruby specific  
tutorials.

> It’s cheap and small and interesting. Mr. Pine uses it to teach  
> beginning programming to kids. He chooses to teach them Ruby rather than  
> other languages. Ruby gets out of the way most of the time. It lets you  
> focus on the skill of creating a program. Designing it and testing and  
> running it. In C this is a much more complicated task. If you starting  
> out, C will throw a lot of things at you at once.

I can recommend “C++ for Dummies” if you are new to C/C++. I haven’t yet  
had the patience to learn C/C++, though, but found the book a valuable  
resource when I was dabbling in C/C++.  
A tidbit of information: C has become a subset of C++, which, upon more,  
introduced OOP to the C world.

> That said, either way you’ll be fine, but get yourself a good text  
> editor which does colors and (if possible) auto completion. Learn to use  
> the command line too. Buy a good reference book for Unix.

Look long and hard for a good text editor / IDE (once you know what your  
IDE should be able to do). What works for me, doesn’t work for you (I  
don’t really like Eclipse, but I like NetBean’s Ruby support, for  
example).

Get used to reading loads of documentation, most of which is dry and  
boring, but packed with information.

Don’t just get a Unix book, but install yourself a Linux / Unix derivate  
(Ubuntu is a very good choice if you never, ever touched \*nix). Darwin  
(Mac OS X’s Unix core) is available as download, too.

–  
Phillip “CynicalRyan” Gawlowski  
[http://cynicalryan.110mb.com/](http://cynicalryan.110mb.com/)  
[http://clothred.rubyforge.org](http://clothred.rubyforge.org)

Eek! That was supposed to be My Special Law, _MY_ special law, I tell  
you!

T/

---

<div class="post-metadata">

**Author:** ![smc\_smc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@smc\_smc](https://www.ruby-forum.com/u/smc_smc)\
**Post date:** [April 24, 2007, 7:47am UTC](https://www.ruby-forum.com/t/ruby-and-c/92773/8 "2007-04-24T07:47:33Z")

</div>

On Apr 24, 2007, at 2:01 PM, Phillip G. wrote:

> [Learn to Program, by Chris Pine](http://pine.fm/LearnToProgram/)
> 
> To sneak a peak, you can find a complete tutorial (I don’t have the  
> book itself, and thus cannot comment on the completeness of the  
> content in comparison to the book) to programming in general and  
> Ruby especially.

It’s an intro. Doesn’t go into bigger topics. Focus on fundamental  
things.

> Of course, \_why’s poignant guide shouldn’t be amiss in Ruby  
> specific tutorials

Of Course!

> I can recommend “C++ for Dummies” if you are new to C/C++. I  
> haven’t yet had the patience to learn C/C++, though, but found the  
> book a valuable resource when I was dabbling in C/C++.  
> A tidbit of information: C has become a subset of C++, which, upon  
> more, introduced OOP to the C world.

Actually, C and C++ are still very closely related, but have  
officially and technically branched off. C++ is no longer a superset  
of C  
however, Objective-C is a superset of C. Meaning, all C is valid  
Objective-C. Not so with C and C++. (though we can say that most  
small C programs probably are valid C++ programs)

C is not bad to learn, just painful at times (debugging) it is still  
all around you, everywhere. That mobile phone in your pocket? C is in  
it. In most single-purpose devices. Systems engineers use it all the  
time. Ruby can be used to test and check C! Even to generate C.

---

<div class="post-metadata">

**Author:** ![smc\_smc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@smc\_smc](https://www.ruby-forum.com/u/smc_smc)\
**Post date:** [April 24, 2007, 9:12am UTC](https://www.ruby-forum.com/t/ruby-and-c/92773/9 "2007-04-24T09:12:40Z")

</div>

looks like im going to be trying to learn C…

---

<div class="post-metadata">

**Author:** ![smc\_smc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@smc\_smc](https://www.ruby-forum.com/u/smc_smc)\
**Post date:** [April 24, 2007, 4:17pm UTC](https://www.ruby-forum.com/t/ruby-and-c/92773/10 "2007-04-24T16:17:11Z")

</div>

Late in the conversation but…  
I learned the canonical basics (Apple &Q) of childhood, then Pascal.  
then C++, then C…  
It really wasn’t a good way to go.

You’re right to learn C first. It teaches you many of the good habits  
people used to proclaim were taught by Pascal, except unlike Pascal,  
it’s useful. Once you start coding in Ruby, you may not use your C  
much, but it’s one of those languages you should at least be able to  
read. Being able to read C, and having at least written some C, is to  
a programmer like being able to read a circuit diagrams and  
greek-letter laden papers is to an engineer. You don’t have to be an  
expert in writing it if you’re not programming in it, but you should  
be able to read it and understand it.

Learning C++ before C is painful, and then it will take great work to  
get your C skills up to snuff. Learning C++ for your OO stuff may be  
painful as well.

Since you’re planning on learning some C, maybe learn C, learn ruby,  
then if you want to branch out to OO in C, learn C++ 🙂  
(obj C is a cool choice too, but not widely used outside of OSX)

---

<div class="post-metadata">

**Author:** ![smc\_smc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@smc\_smc](https://www.ruby-forum.com/u/smc_smc)\
**Post date:** [April 24, 2007, 5:04pm UTC](https://www.ruby-forum.com/t/ruby-and-c/92773/11 "2007-04-24T17:04:17Z")

</div>

Don’t quit Ruby though. It’s different enough from C that one may  
make the other make sense in a way.  
It doesn’t hurt to learn C first, but it isn’t necessary to master it.  
You will indeed find that other languages do things the way you wish  
C did. C is really bare bones stuff. It’s hard to feel productive and  
useful with it compared to interpreted languages like Ruby, Perl,  
Python or PHP.  
Much terminology comes from C or before, and many fundamental  
concepts are well established in C books, but don’t feel like you  
have to learn one language at a time. (more than 2 at a time would be  
difficult though)  
Most of them have a lot in common, so many things will carry over.  
Many languages even look and work a lot like C does, but Ruby  
certainly does have a particular beauty about it.  
Learn both.  
Many people do indeed use multiple languages. Certain languages are  
good at certain things.  
Some concepts are better illustrated and easier to manage mentally  
with some languages.

---

<div class="post-metadata">

**Author:** ![smc\_smc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@smc\_smc](https://www.ruby-forum.com/u/smc_smc)\
**Post date:** [April 24, 2007, 4:28pm UTC](https://www.ruby-forum.com/t/ruby-and-c/92773/12 "2007-04-24T16:28:11Z")

</div>

On 4/24/07, smc smc [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Would it be easier to learn ruby if i knew C/C+/C++ or the other way around?

One of the first things you’ll learn is that C/C++ is an uneasy  
pairing - despite C++ being based on, and backward-compatible with C  
they’re pretty different languages.

martin

---

<div class="post-metadata">

**Author:** ![smc\_smc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@smc\_smc](https://www.ruby-forum.com/u/smc_smc)\
**Post date:** [April 24, 2007, 7:13pm UTC](https://www.ruby-forum.com/t/ruby-and-c/92773/13 "2007-04-24T19:13:35Z")

</div>

On 4/23/07, smc smc [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Would it be easier to learn ruby if i knew C/C+/C++ or the other way  
> around?

Are you looking to have fun, or to acquire marketable skills? If you’re  
tempted to say “both,” you should probably think a little harder because  
the  
answer differs.

If you want to have fun, learn C, then C++, then Ruby. Nothing is more  
fun  
than understanding what you’re doing at a deep level, and building on  
that  
foundation to learn higher-level things. I learned assembler before I  
learned C before I learned C++ (and have been a professional at all of  
them,  
where “professional” is defined as “getting paid consistently for doing  
it”). But before I ever approached computers, I learned how to design  
digital logic at the hardware level (gates, circuits, voltage  
regulators,  
all of it). Then when I first looked at assembly languages, they made  
complete and intuitive sense from the first minute. Needless to say, my  
reaction to C was “Wow, what a high-level language this is!” I never had  
conceptual trouble with pointers because I know exactly what they mean  
at  
the electronic level.

It’s a different question if you’re looking for marketable skills  
(although  
taste plays a big role because you need to ask yourself what you will  
actually enjoy working with every day).

It’s been long predicted, but we may finally be starting to see a split  
between hard-core systems programmers (for which the demand is really  
rather  
low), script-level coders, and “business” analysts who probably won’t  
ever  
write a line of code at all. As the economics of software development  
change, these layers may become more clearly delineated and less  
permeable  
in the marketplace. I think Ruby has helped drive this change because it  
really is becoming more possible to cut together significant and  
valuable  
applications from system-level pieces using scripting. (Java tries to do  
this at the library level, less successfully, although the terrific  
amount  
of effort that goes into the attempt shows you that the principle at  
work is  
a compelling one.)

So if you want to be in the middle layer (probably the mainstream going  
forward), there’s nothing wrong with learning Ruby first. You would do  
well  
to learn Java too (though I’m hesitant to recommend that, not because of  
inherent problems with Java but rather because most Java pedagogy is of  
the  
mindless, cookbook variety.)

Flame away. I can anticipate objections to this argument in two basic  
forms:

1. “What you’re talking about hasn’t happened yet, therefore it won’t  
happen  
in the future,” and 2) “Language XYZ is the best language in the world  
[for  
some local definition of “best”] and therefore everyone should learn it  
first!” I’ll be very interested in hearing any counterarguments that are  
not  
isomorphic to one of these.

---

<div class="post-metadata">

**Author:** ![smc\_smc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@smc\_smc](https://www.ruby-forum.com/u/smc_smc)\
**Post date:** [April 25, 2007, 2:56am UTC](https://www.ruby-forum.com/t/ruby-and-c/92773/14 "2007-04-25T02:56:23Z")

</div>

On Apr 24, 2007, at 12:42 AM, John J. wrote:

> get the book by Chris P., Learn to Program.  
> Chris P.'s book, I must say, is rather great. He teaches you one  
> things at a time, and explains everything thoroughly. You could learn  
> a lot of Ruby from that book in two days. I did.

> But learning C is a good goal too. It really is the Latin of  
> computer languages. Many ideas and traditions come out of decades  
> of C culture.  
> Anyone know much about D? It’s an alternative to C, with cleaned up  
> syntax and garbage collection. There are a lot of other features,  
> too, but I don’t know them. Check it out if you’re even slightly  
> interested.

> That said, either way you’ll be fine, but get yourself a good text  
> editor which does colors and (if possible) auto completion.  
> For macs, Aquamacs is an amazing TE. It’s free (not sure if it’s open  
> source), and has coloring (from the themes) and auto-tabbing (Ctrl-  
> Alt-Backslash). By far my favorite text editor. There’s also  
> TextMate, but I haven’t used it yet.

---------------------------------------------------------------|  
~Ari  
“I don’t suffer from insanity. I enjoy every minute of it” --1337est  
man alive
