Software Design


18
Oct 10

What Is So Great About Ruby?

I had a bit of a meltdown on Twitter the other day… well, it wasn’t really a meltdown, it was just frustration. Frustration with C# and desperately wanting a language which allows me to work without a lot of the ceremony that comes with most strongly typed languages. For a while I thought IronRuby was going to help me achieve the goal of moving off C# at least for my web development. I thought that once I got full IronRuby support inside of ASP.NET MVC, bam! That would have been it, I would have used it, no question about it. Alternatively, if I had gotten full Ruby support, I would have also had the option of moving to Rails which makes for interesting conspiracy theories about the downsizing of the IronRuby team.

I got myself pretty upset, I even stayed up until about 2 in the morning on Thursday night writing a long blog post. I’m glad I slept on it for a few days and talked to half a dozen people about it. It made me realize that I didn’t really have any good goals for the post other than to burn off some steam. I thought for a while about what my goals should be, and I thought back to the conversation I had on Twitter. Many of the comments that I received were along the lines of "stop complaining about C#, show me why Ruby is better!" I was actually surprised that I got this comment several times. I mean, everyone knows Ruby,right? (Was that elitist enough for you?)

So, I realized that my goals were really to explain why I am frustrated with C#, and why I think that Ruby (or a Ruby-like language) would make my life easier. I also don’t want you to think that I am saying that C# sucks, I’m not saying that at all. C# is a great language with goals that were different from the highly testable, abstracted, dependency injected world in which we live now. Developers (or at least many developers) on the Microsoft platform *need* a more malleable and flexible language, one which is a first class citizen in the ecosystem. If Microsoft developers don’t get this, then the string of defections to other platforms won’t end any time soon. So, before you fall asleep, let’s get on with the show…

Continue reading →


23
Sep 10

Your Software Can Learn A Lot From ATMs

How many times have you used an ATM? A hundred times? A thousand times? Depending on where you are from, you probably have an ATM on just about every corner, and you probably use them on a fairly regular basis. How many times has an ATM given you an incorrect sum of money? How many times have you heard of friends who have received an incorrect sum of money from an ATM? I’m willing to bet that you haven’t. Pretty amazing, right?

With the millions of bills that are fed out of ATMs every year, it is amazing how reliable the mechanisms inside it are, right? I mean, if ATMs so rarely give out incorrect amounts of money, then they must have developed an amazingly reliable mechanism to divvy up the bills and then feed them out to the user, right? All those crisp new bills are so insanely hard to get apart, I just had to wonder what sort of engineering had gone into making absolutely sure that bills didn’t get stuck together!

Continue reading →


13
Sep 10

Classes Are Not Objects

I was reading a blog post by Derick Bailey last night and I got into the comments due to a few tweets that I saw (I’m on Twitter if you want to follow me). It was a lot of noise and ranting, but one topic that came up was that people working in languages such as C# and Java quite often mistake classes for objects. Working in a language like C# they can feel quite similar, since the distinction is merely that a class represents the abstraction of a set of objects, while an object is just an instance of a class. You can think of the class as the cookie cutter and the object is the cookie.

So what is the importance of this distinction? Well, in C# prior to 4 the distinction wasn’t very important. You didn’t really have a good way of interacting with a class in a way that the class definition didn’t provide. In C# 4 the dynamic type was introduced along with a late binding mechanism that allows the object to respond to methods which don’t exist on the class definition. So, are they really method calls at all? We aren’t actually calling a method, right? This is exactly why many languages will talk about message passing rather than calling methods.

Continue reading →


11
Mar 10

How The U.S. Census Can Make Your Software Better

Form

You might be thinking, what kind of silly question is that? The census is produced by the government, and everyone knows that the government can’t do much of anything correct. Right? Well, today I received in the mail the same letter from the U.S. Census Bureau that people across the net have been decrying for a while now. It is a thin envelope, and inside of it is a letter letting me know that in about a week I will be receiving a census form. At first glance you might think "What a waste! They mailed you a letter to tell you that they were going to mail you something?!" In the immortal words of Tracey Morgan, "That’s just crazy!" And at first, it does seem that way, but I think that the truth is a bit more involved.

Continue reading →


10
Jan 10

The TekPub LINQ Challenge Part 2 – Faster Algorithms

In order to challenge others to the TekPub LINQ challenge, I felt like I had to create my own solution first, before I challenged anyone else to the task. What I came up with is an algorithm that works, and is also terribly inefficient. There are a few optimizations that can be made in order to speed it up though.

My original solution looked like this:

var primes = Enumerable.Range(1, 20)
    .Where(i => i != 1 && !Enumerable.Range(2, i - 2).Any(j => i % j == 0));

Here you can see that we take our range, check to make sure that 1 is not involved (since 1 is not prime!) and then take the range from 2 to one less than the number and then use “Any” LINQ extension method to check to see if any of the numbers in between divide evenly into it. A brute force approach, which works, but it is not super efficient.

Continue reading →