Monday, April 5, 2010

Why Git is like a Microsoft product

That's right, I just said Git is like it's written by Microsoft. Or rather designed by. It works, which is awesome, but its design features one serious drawback of which I find Microsoft products to be the most prominent source. The drawback is namespace pollution.

In Windows, you're not allowed to name a file "CON". Why? Because of namespace pollution. There are 25 reserved names that show up in the context of file names, but that aren't really file names because they're special.

This writes "hello" into a file called "conn":
echo hello >conn
This doesn't create a file at all. I have no idea what it does:
echo hello >con
The only difference is that "con" (case insensitive) is a special name. I'm calling this namespace pollution because there are a set of names (file names) and a set of names (reserved names) that are mixed together.

In Git it's a lot clearer what I mean by namespace pollution.
git checkout thing
What does this do? Can't tell. It might revert a file called "thing" to it's state at the last commit. It might switch the entire working directory to another branch called "thing". Which of these happens depends on whether there's a file called "thing" or a branch called "thing". If both exist, I'm sure one of them happens, but I don't know which without doing an experiment or reading through documentation. I'm not going to do that. Why can't there be different syntax for the two? Like
git switchtobranch thing
git revertfile thing
I'm going to say it. SVN's syntax is much more understandable.

No comments: