Friday, August 17, 2007

GetOffMyCase!

One of those tired old arguments you see crop up again and again among programmers is that of case sensitivity in programming languages. The general trend currently seems to be that most are advocating a move towards case insensitive languages. These people tend to call case sensitivity a legacy of the “old” days. They then go on to cite that modern compilers have long been able to save us from the case sensitive buggy-man. Perversely the popularity of case sensitive languages seems to be rising while popularity of case insensitive ones is falling... and no, I have no empirical evidence of this, just something that seems true based on my own observations over many years in the field.

The arguments against case sensitivity range a bit, but one common complaint is that mistakes in case cause hard to detect errors or lead to having two different functions whose name differs only in capitalization. Another common complaint is that comparing strings or working with things that are strings in case sensitive languages often leads to bad behavior, especially when dealing with file paths or URLs where the underlying platform is not case sensitive but the language itself is.

Look, I’ll grant a couple of things:
  • Scripting languages or any language that makes heavy use of late binding should avoid being case sensitive. JavaScript in particular would be a LOT better if it were not case sensitive. In fact, JavaScript is what I like to call a case-destructive language.
     
  • String comparisons in ANY language should, by default, use case insensitive comparisons unless explicitly told otherwise. Most languages provide a mechanism to perform case sensitive or insensitive comparisons, but most C based languages default to doing a case sensitive match. Even C# (my language of choice) is guilty of this.
While there are a couple of points these advocates make that I can agree with, I disagree overall that case insensitivity is “better”. In case sensitive languages, after a little exposure, the use of case becomes a useful tool on its own.

Once you understand the conventions of the language you can usually tell a LOT about what is going on in code just by observing which case is being used.

For example, Identifiers in C# are camel cased when they are local variables, private fields or method parameters.  Pascal case is used for public members, class names, etc. The use of Case to distinguish meaning in C# is generally very consistent from one developer to another. The adherence to good naming conventions is partially due to the case sensitivity of the language itself, and is not a work around in spite of case sensitivity.

When I see something called myName in C# I KNOW I’m dealing with a local variable or private member. When I see MyName I know I’m dealing with a public member.

This is NOT confusing to me or most C# developers. On the contrary, it is  quite elegant and we get used to noticing the case of identifiers, and the case used tells us instantly something useful about the code.

But when I deal with VB code, I have to play guessing games when I see myName1 and myName2. Sure, conventions help some there too, but the conventions always feel like sloppy workarounds where the sole purpose is to support case insensitivity.

Of course, most of this relies on a decent understanding of the conventions of the language and the programmer being competent enough to follow those conventions. I’ve been working in C# for many years and I’ve never had serious problems with case induced errors. Sure, occasionally I have made a case related error, but I can’t say that this happens more often than the mistakes I’ve made in VB due to inconsistent and awkward naming. In both languages those kinds of mistakes usually get caught by the compiler or the IDE quickly.

Case sensitive languages have another side effect though, and in my mind this is THE most important thing. Case sensitivity makes programmers pay attention to detail. This may seem like a very simple thing, but attention to details is THE skill that I’ve discovered marks the difference between a decent programmer and a great one.


Wednesday, August 15, 2007

Local Coffee Shops Suck - Go Starbucks!

I have many friends and acquaintances that "hate Starbucks". Hating Starbucks might even be more popular than hating Paris Hilton.

They all have their pet complains, usually about some isolated unfair trade practices or injustice carried out by some mid-level area manager or something. The argument always trends to wrap up with how local coffee shops suffer when Starbucks comes to town (the Wal-Mart argument).

But the sad fact of it is that any company that size will have ass-hats that occasionally do bad things. I try not to hold that against a company unless that kind of behavior becomes the executive policy of the company as a whole (which is why I don't hate Wal-Mart or Starbucks but do hate Disney and Apple).

Anyway...

Let me tell you why Starbucks kicks ass... aside from the fact that they actually serve a decent enough cup of coffee.

The reason Starbucks kicks ass is because they understand this that you can't stir a 20oz cup of hot liquid with a fucking 4 inch tall plastic stick!

Starbucks has big sticks that fit down into the cup all the way to the bottom without burning your fingers! Out of dozens of local shops I've been to in dozens of towns, maybe one or two have had sticks that are appropriate for their larger size cups.

You'd think that if your fucking business IS coffee, then you'd take the time to notice that 4 inches of stick does NOT-the-fuck fit into 10 inches of cup!

How god-damned hard is it to understand ?!?!

See, Starbucks pays attention to those little details.

They provide this level of service in EVERY store.

So... I don't have to wonder if I'll have a way to stir my shit when I get to Starbucks because ALL of their shops have good sticks.

I don't have to wonder if I'll be stuck trying to open half a dozen tiny little packets of sugar (which is always messy) because Starbucks has both packets AND a free-pour canister of sugar on the counter (I know... almost unbelievable!)

That is why Starbucks is killing your local coffee shop.  


Friday, July 27, 2007

VS 2008 and .NET 3.5 Beta 2 Released

VS 2008 and .NET 3.5 Beta 2 Released - ScottGu's Blog

Been waiting on this for a while :) I haven't figured out if it shipped with a go-live license yet though.

I'm particularly eager to get a good look at the Team System stuff in 2008. I've been putting off testing of the beta team system stuff until it got more stable (deploying team server is a pain, even if you are using a virtual server).

Assuming this does have a go-live license, it will finally allow me to put together an update for the CCK project on the new platform too. More on that later...

Microsoft Robotics Studio

Microsoft Robotics Studio

Microsoft is a REALLY big company. Even for those of us that work in IT and make our livings off Microsoft's technologies exclusively, they still sometimes manage to slip products and technologies by us... but rarely does Microsoft have an entire development platform that manages to elude my notice.

I just came across this one. I wasn't even aware Microsoft was doing anything in robotics, much less actually had a development platform on the market.


Thursday, July 26, 2007

Reddnet now powered by BlogEngine.net

I've replaced the reddnet site with a new blogging application based on the BlogEngine code base.


Most of the scribbles section made it over to the new application, but the old posts' formatting remains a mess. I didn't move the old comments or ratings over though. I'll be fixing the formatting, tagging, and categorization of the posts over the next few weeks.


BlogEngine is a pretty neat community application. It is very simplistic in scope compared to the CSK code-base that reddnet previously used, but simplicity is a good thing since I have very limited time to manage my personal site. I will of course switch reddnet over to the CCK code-base once I've finished writing it :)


I'll be reviewing BlogEngine.net here in the near future.

Tuesday, March 6, 2007

Imaginary Usefulness

Few subjects frustrate me faster than mathematics. Math is an essential skill and a useful tool. But our school systems, secondary and primary both, totally fail to teach common sense along with it.

I’m constantly amazed at how many smart people are made stupid by an extensive education in Mathematics. Mostly this is because math is taught more as theory than applied science... especially in primary education. Through high-school most people learn a crap-ton of math theory and mechanics.  But there just aren’t many classes taught that apply math in a useful way. 

This leads to the question eventually asked in every math class, “when will I ever need to use this in the real world”. For higher math, anything above basic Algebra, the answer for most people is “probably never”.

That aside, the mechanics and theory still need to be taught so as to give students the possibility of going into a career where they could actually use higher math. A basic familiarity with more advanced math is useful to a sorta degree, but much more useful would be classes on the applied uses of math... classes that show how and when math is useful.  But what I’d like to see taught most is common sense.

For example, in my 10th grade Algebra II class we spent about three straight weeks going over imaginary numbers. Ok, let me get this straight... due to the practical limitations of the universe this math cannot be done. But if you ignore that little rule, you can still use the mechanics of our math system and generate numbers that have no meaning... they are imaginary.

Umm... excuse me, but shouldn’t that be the fucking end of the lesson?!?!?  But NOOOOoooo!  After that we had to spend weeks working math problems that result in imaginary numbers. Then we had tests on how accurately we could solve these problems.

So, we are going to be tested on our ability to come up with accurate answers to a math problem where both the question and the answer have absolutely no meaning at all?

Why can’t I just answer “turd-jam” for all the questions and still get credit? After all, “turd-jam” has just as much meaning in context with the questions as the actual numerical “answer” would... and in 10th grade it would have at least been funny, which is more useful than any other answer I might have derived. This is a classic example of the failure to apply common sense in math. As far as I can tell, the first major failure to teach common sense in math starts when they teach you the concept of negative numbers.  Numbers measure quantity. That’s fucking it... Quantity. The real usefulness of any math is in the question “quantity of what?” 

The only non-intuitive thing about quantity is the concept of zero, but this is fairly easy to explain to kids. Once zero is understood is becomes common sense. Zero also becomes the only non-positive number that remains meaningful. 

But negative numbers are NOT real. They cannot, and do not actually exist. If you solve a math problem, and the result is a negative number then all you have learned is that problem is flawed, you have incomplete information, and/or the number you produced is not a valid measure of anything that exists in the same context as the original question. Since the basis of the question was wrong, any number you derive no longer has any meaning and you should stop right there. If you continue with negative numbers then you are either just making shit up, or you are measuring something in a different context than the context assumed in the original question.... and you had better have a damned good idea what the new context of your answer is, or you are screwed! 

But they never teach that concept in school.

Let us use a practical example.
You own an appliance company. You have 1refrigerator in stock. A customer comes in and buys 4 refrigerators. How many refrigerators do you have left in stock?
If you answered negative three (-3), then just kill yourself now.

In-stock means “physically sitting in your warehouse”. If you walk back to the warehouse, I can only guarantee one thing... you, the fuck, will not see negative three refrigerators sitting back there.  The only meaningful answer to this question is “unknown”. How many refrigerators you have in stock after selling 4 of them depends on if you gave the customer the one fridge you had already, or if you are waiting to deliver all 4 fridges after your vendor deliveres them to you. The original problem contains insufficient information. When you walk back there, you will either see zero or one fridge in your warehouse... So when you see -3 in your answer, what it really means is that you are measuring the wrong thing. You don’t have -3 of anything. You may have +3 of something else, like refrigerators you need to order from a vendor, but that number is valid only in a different context, and only when the new context makes that number a positive number or zero. 

Which brings us back to imaginary numbers. How surprising is it that it is impossible to perform some mathematical operations when you are using numbers that simply mean you are working with values from a different context than the one your math problem represents? In the case of imaginary numbers you are working with numbers from a context that cannot exist at all, so you should just give the fuck up right there, rethink your math problem so that it addresses a real question in a meaningful context.

I see this junk all the time in programming. I get requests like, “I need a report that shows the number of brain cells left in my head”.

Sorry... but that report results in negative numbers and therefore has no useful meaning.

Why not ask a different question like “how many brain cells will I need to have implanted before I regain the ability to chew gum and walk at the same time?”.   Any math should answer a question in such a way that the answer has some useful meaning. If you are coding with negative numbers then your code measures the wrong thing. Flip something around so you are measuring things that exist. Your code will be easier to understand and will produce results that have more meaning.

With math, please always use common sense. Mechanics are neat, but you have to understand the “why” of your math, not just the “how”. That is especially true when you are making up math that gives answers that other people have to interpret.


Thursday, July 13, 2006

World of Warcraft Idea

Though I game far less than I once did, I do play World of Warcraft. Not so much because it is the best game evar or anything (it is pretty good though), but more because there aren't any better out there that don't require massive and continuous commitments for my time.

One thing I always wondered though is why more games didn't learn from the old Jumpgate MOG (I refuse to use the longer acronyms, so MOG is Massive Online Game... that's as  much hype as you'll get from me). Like most games, especially MOGs, Jumpgate started a web site long before the game released. But from the start one thing really stood out about their web site. The site was linked very deeply into the actual game (in beta at the time). You could look up who was online, where, what they were doing, see statistics, and even manage your in game character a little.

Where the fuck is that feature in every game released since then? Jumpgate is years and years old... I don't even know how old. And it had deep integration with their game database back then.

What I'd love to see is WoW implement a way to actually log into the web site and see your character info, spend your talent points, talk to in game players (at least ones in your guild), and most of all... monitor and participate in the auction house. Man I'd love to be able to watch the AH for those rare items from work without having to actually log into the game itself (which is a sure way for the boss to know you aren't working :P).

Anyway... I do hope future games take some Qs from Jumpgate. Make your web site PART of the game... not just a bullshit marketing ad.