Early Observations on Ruby

I’ve been playing with Ruby for a few weeks now, and I have really enjoyed it so far. On the one hand, it’s a bit scary not to have the rich type checking and static analysis I’m used to from writing C# in Visual Studio. On the other hand, my source code feels a bit more concise, and I can’t paint myself into a corner with poor decisions about classes and interfaces. (I’m sure I can paint myself into a corner in other ways; I just haven’t found them yet.) Continue reading “Early Observations on Ruby”

Some Operator Names

I am a little behind right now, so this week’s post will be fairly short, and will also be a little bit reminiscent of something a high school Latin teacher would write. (Almost 2 years into full time programming, and I still think about Latin fairly often, and still miss my students.)

Anyway, today we’re going to explain unary, binary, and ternary. Every now and then I’ll be reading documentation and I’ll see a gem of a sentence about “ternary operators,” and I can’t help but think there’s a communication mismatch. When I imagine people reading through docs trying to figure out what a ? means in source code, I suspect that many of them do not find the phrase “ternary boolean operator” abundantly helpful. While we’re talking about ternary operators, we might as well cover unary operators and binary operators. Binary operators are extra confusing, because “binary” doesn’t seem to mean the same thing in the phrase “binary operator” that it means in phrases like “computers do math with binary numbers.” Continue reading “Some Operator Names”

TDD and Algorithms Class

As I mentioned in a previous post, I recently started taking a course on Coursera called “Discrete Optimization.” It’s hard, and I don’t have quite enough time in my schedule to finish everything, but I am learning a great deal.

My main concern with taking this course is to learn Ruby, and learn a little bit of test driven development. If I end up learning some cool algorithms along the way, I’ll take it. Continue reading “TDD and Algorithms Class”

Rube Goldberg Coursera Work

I’m taking the Coursera course Discrete Optimization. It’s fun and challenging and I doubt I’ll have time to do very well, but I really enjoy this sort of thing. The programming assignments are fun, the lectures are hilarious. (The professor dressed as Indiana Jones and pretended to be literally trying to solve the Knapsack Problem because the temple was collapsing, for example.)

The submission process for programming assignments is pretty straightforward. Basically, you get a file called solver.py, which you edit so that it returns the answer you want, and then you get a file called submit.py, which calls solver.py and sends the answer up to Coursera for grading. Many of the students will either write their solution in place in solver.py or will call another python file from that one. But the course specifically permits you to write in another language, and then just have solver.py invoke whatever else you wrote, by calling and executable and reading its output, for example.

Now, I’m trying to learn Rails, and making Rub gems, and Vagrant. I hope you see where this is going. Maybe there will be a prize for most CPU instructions executed in preparation for attempting to solve the homework question.

Here’s my setup:

  1. solver.py invokes a shell command that spins up a Vagrant box.
  2. The Vagrantfile, if it’s called in this way, will immediately spin up a rails server on localhost.
  3. Python will call localhost over http to get the answer to the assignment.

Continue reading “Rube Goldberg Coursera Work”