Starting Ruby

I decided to go ahead and learn Ruby. When I was originally learning C++, sometimes I’d get bogged down or frustrated and need a break. When that would happen, I would go make a webpage in HTML and feel better. So learning Ruby and refreshing my C++ at the same time seems like a good idea: I can switch it up when I get frustrated.

To start learning Ruby, I decided to use Ruby Monk first. It uses interactive “books” that let you try out what you’re learning. It checks your work as you go, which makes it more like having a real teacher. Sometimes it feels like the explanations are incomplete, like I want more detail on how something works. That’s pretty common for me when I’m learning something new, I end up taking longer because I need to answer whatever questions I have, so I have to research tangents. But I generally end up with more information and a better understanding of my subject matter. While Ruby Monk feels incomplete to me, it has been very useful in teaching me how to use a large variety of methods very quickly.

I don’t know if this is something that’s important with Ruby, but sometimes the lessons want me to make an educated guess as to what a piece of code is. That’s not something I learned to do with C++. For instance, in C++, knowing that “cout” prints to the screen might allow me to guess that “cin” takes input from the keyboard, but I probably wouldn’t guess that I need to change “<<” to “>>” as well. In Ruby, knowing that “puts” prints to the screen, I might guess that “gets” or “takes” gets input from the keyboard. After a guess or two in Ruby, I’d stumble upon the correct “gets” method. I don’t particularly like making educated guesses, I’d rather know. For me, guessing instead of knowing feels reckless.

There are some differences between C++ and Ruby I’ve found. First, in Ruby, it takes a lot less code to do something. The basic “Hello World!” program shows the difference. In C++ it looks like this:

While in Ruby it looks like this:

Even just looking at the line that prints “Hello World!” to the screen, the amount of code in Ruby is less. It also feels more like I’m writing a normal, English sentence since it’s missing the “<<” s. Ruby also uses periods and parentheses in its syntax. This makes the syntax feel like a blend of a normal sentence and a math equation. I’m not sure on this yet, but it also seems like Ruby treats everything as an object. Even if it’s not everything, Ruby uses more objects than C++. I haven’t gotten into it enough to know if that aspect makes it easier than C++, but it looks like it does.

So far, I’m enjoying learning Ruby. It feels like I’m learning it MUCH faster than I learned C++. I even feel like it’s going faster than my refreshing on C++. In just a couple days, I’ve learned a lot of methods and how to use them, more than I expected to learn. I’m going to continue using Ruby Monk & supplement the lessons with other reading. I think this will let me learn the code quickly as well as satisfy my questioning/tangent-following nature.

Advertisements
This entry was posted in Coding, Comparison, Helpful Sites and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s