Monday, March 19, 2012

Ruby and Me

Last year, I made a sort of life-changing decision. I decided to go back to school and get a computer science degree, with the idea that I could then get a decent job doing something with computers. Since I'm always doing something with computers anyway, I might as well get paid for it, right?

So, I'm currently enrolled at the local community college, getting an associates that I can transfer to a larger institution to get the computer science degree. I'm taking my first high level language programming course, learning the basics of Java. The last programming language I learned was Pascal, and before that, BASIC, so it's been neat to learn how to code.

The problem is that we are going really slow. Baby steps and all, I guess, but man. We've made it to the midterm without going over objects. Since Java is an object oriented language, I was looking forward to some formal instruction in how to program with objects, which we didn't cover in Pascal or BASIC. I'm sure we're going to get there eventually, but in the meantime, I'm getting a little bored. I've been resigning myself to the notion that my newly chosen field may be kinda boring at times, and I've been sloughing through, excitedly coding what I can, and cooling my heels while I wait for the next lesson.

During our last exam, we had to write a program, and I needed a placeholder variable to keep track of individual characters in a string as I tested them as to whether or not they were vowels. In a fit of whimsy, I named the variable moxie, and was immensely proud of myself for having done so. I went home and rewrote the program again on my own, just to see if my pen and paper program would actually work. (It didn't.) I kept the variable named moxie on the new program.

Then we had a week off for spring break, and going slowly turned to not moving at all. I worked on some other projects, but missed coding. Then I read this article on Slate about Why the Lucky Stiff and Ruby. It prompted me to check out some of the resources mentioned. The next thing I knew, I was coding Ruby examples. I started taking the programs that I had written in Java for the course and rewriting them in Ruby. I've been coding in Ruby for two straight days now.

There's something very appealing about its simplicity and its flexibility. That and _why's poignant guide with its cartoon foxes talking about chunky bacon just click with me. Maybe naming a variable moxie was a sign of things to come.

Spring break is over, and I had Java class today. Evil Fultz (I'll tell you about him later) sulked as usual, and the two kids sitting behind me would not shut up, as usual. (I'll tell you about them now: the guy is gregarious and not too bright; the girl is talkative and smart as whip; they sit together every class and talk about frisbee golf and what parties they've been to recently. I had trouble hearing the professor over their babble today. Next class, I'm moving to another part of the room. Yes, I'm old.) We got into for loops, do while loops, and nested loops. There was a tantalizing hint about methods, which we'll apparently get to in the near future. But as I sat there in class taking notes, I started working out in the margin how to do the examples on the board in Ruby.

Tonight, I'm going to continue translating my Java into Ruby. Last night, I got hung up on how to get keyboard input into an array, but I think I worked that out this morning. [I did! It worked!] I've also been working through the Ruby Koans, a set of exercises that teach you by having you fix errors in code. But mostly I'm just excited to wade in and start writing code, and that maybe the most liberating thing about Ruby. I don't feel free to just start coding in Java because it feels like there's just too much that I don't know. Ruby, on the other hand, is so simple and natural that it seems like it is practically begging me to start exploring.

One thing I do wish I could find would be a repository of beginning programming problems, something for me to work on while I learn how to make the code do what I want. Eventually I'm going to work my way through everything we've done in Java. At the rate I'm going, it could be by the end of the week. Then I'll be left to my own devices with Ruby, which apparently leads to chunky bacon and starmonkeys.