Although we’re still trying to get Ruby on the Mac, I did get a chance to try it out on another computer. It’s very confusing to jump straight into it, although I do think that’s the best way for me to learn it. I read through the first bit of the chapter on Ruby in the “Seven Languages in Seven Days”, and I did understand a few things. Only a few, though, so my phrasing and understanding may be off.
In programming Ruby, there are strings. Strings, as defined by Ruby-Doc, “hold and manipulate an arbitrary sequence of bytes, typically representing characters.” This is a rather obtuse definition. With ones like these, I try to break it down. Firstly, I didn’t know what bytes were. By looking it up, however, I found out that bytes are each composed of 8 bits. 1 bit is equal to 1 binary digit (1 or 0). So bytes are just 8 digit long sequences of binary. Bytes can be converted into bigger units, but for our purposes now I’ll stick to just bytes.
Bytes are therefore comparable to words. By putting different sequences of bytes together, you can create different “sentences” to command the computer. So strings, by my understanding, act like a word document to save the “sentences” you make with bytes. As with a word document, you can make changes to the strings and save the new version.
Now that I think I understand strings, let’s look at Ruby as a whole. Ruby is called an object-oriented language. But what does that mean? Well, an object is defined as a data structure where not only is the data type defined, but also the types of operations that can be applied to it. In simpler terms, an object is like a noun with a collection of verbs that can be used with it attached and an adjective specifying what it is. For example, an object could be the data structure (noun) “fish” with the data type (adjective) “goldfish” with the applied operations (verbs) “swim”, “eat”, “see”, etc. attached to it.
To summarize, bytes are like words. Strings are like word documents that hold a sentence (just one). Objects are like nouns with adjectives and verbs attached. By making comparisons between Ruby the programming language and actual language, I believe it will be easier for me to understand and learn Ruby.