I just switched from my company's official blog to my own blog. That's kind of exciting, but it means that absolutely know one knows about this blog. (Almost no one knew about our company blog. It was mostly employees.)
That's great! It lets me talk to myself for a bit while I try to organize the blog a bit. :)
I want to answer a simple question first. What the heck is this blog about?
Well, it's about things that interest me. However, I'm the only one who's going to visit a blog about that. (Maybe my wife? Cindy? Are you there?) Okay, so what interests me? Perhaps if people got a clear idea of what I talked about, then they'd know if they wanted to come here.
I like talking about problems that I've had. In the case of this particular post, it's about a problem that I've got right now. Many times, however, I've solved the problem already.
No one's going to read a blog with that little direction, though.
I can say that I'm a big fan of unusual solutions to problems. This is true in my life, but, if I find an unusual solution that works for me, I'm likely to write about it. You probably see a lot more unusual solutions on this blog than I typically come up with in my life. However, not all of my posts have involved unusual solutions to problems. That's okay. There's more than a few posts.
The title of my blog uses the word Programming. I do a lot of that. Programming is a great place to find unusual solutions to a wide variety of problems, too. One of the great things about diverging from our official blog is that I can talk about anything I want to.
I'm guessing that it'll end up being a blog about unusual solutions to problems in programming and game design. That's way too verbose.
Fred on Programming is wonderfully vague. I'll stick with that.
Thursday, June 26, 2008
Friday, June 13, 2008
Why I'm Creating an Independent Blog
I'm separating my personal blog from PC-Doctor's blog. This isn't an uncommon thing to do, but I suspect that some people will wonder if something went wrong. Nothing did. Instead, I expect this to benefit everyone. Read on to find out how.
I'll continue to contribute to PC-Doctor's blog, but I will actively market only the new blog. Since neither I nor anyone else currently does any marketing for our official blog, this may actually help out the official blog. Furthermore, I'll be able to talk about more than just programming here.
Why make such a sudden shift? Chris Keller, our online marketing guy, convinced me that a blog should be more than just a fun place to write down your thoughts. In part, he used Avinash Kaushik's great post here to convince me. He also showed me his own blog. However, I've been thinking about doing the same thing for other reasons.
This raises several interesting questions. First, why didn't I post links to my blog posts around the internet to try to get people to notice PC-Doctor's blog? You can rephrase the question slightly and ask why its better for me to market a blog that's separate from PC-Doctor.
The fundamental problem is that the official blog is not my blog. It has and it has to have a different purpose than a personal blog. I might occasionally write about things like video game design on the official blog, but I always made it relevant to our software. Running trails around Reno and what I might do if a bunch of 12 year olds start shooting guns at the trail in front me really doesn't fit at all on a corporate blog. It might fit here just fine.
In addition, because it's a blog about my stories, I might not mind advertising it on forums or other blogs. The reward for doing that marketing is that this blog has, over the course of several years, the chance of getting a following. Except for Andy, the PC-Doctor blog does not have much of a following. An increased number of people posting in my comments would be a large reward for me. This will require me to market my blog, and it's not entirely clear that I'll have the energy to do much of that, but I certainly didn't want to do it when it wasn't owned by me.
Should PC-Doctor change something about their blog to make it easier for people like me to stay there? No, they shouldn't. PC-Doctor's blog right now is mostly a bunch of posts by me. Customers coming to my posts will see that PC-Doctor hires at least one person who think on their own, and potential employees who come to my posts will see a confusing assortment of topics that may interest some of them. However, no one will buy our products because of my posts.
In fact, if you dig a bit deeper, there are some valuable posts there by other people. Kim Seymour wrote a great article that customers probably would be interested in. (Actually, I liked it, too. You should click on it if you have any interest at all in what PC-Doctor does.) Aki has written some fantastic articles, mostly about non-PC hardware. They've got interesting stuff to say that's relevant to our customers, and my post hides what they're saying.
Hopefully, we'll do something to encourage other employees to write more. Currently, employees are supposed to write on their own time with almost no reward. Some incentive, either monetary or otherwise, might help out. When we first started out, PC-Doctor gave away a Wii for the most prolific poster. Chris Hill won it, and I was jealous. :) They've got another prize up for grabs now as well, but it hasn't been as effective.
Writing a blog has turned out to be fun for me. I'm already convinced. It's been a great way to organize my thoughts about a topic, and I've learned quite a bit while doing it. I expect to continue to have fun in its new location.
I should point out that Doug van Aman, our marketing lead, has been nice enough to get me the copyright for the existing posts that I made. (Thanks, Doug!) I copied them all over verbatim. Without my existing library of posts, it would be much harder to do this.
I'll continue to contribute to PC-Doctor's blog, but I will actively market only the new blog. Since neither I nor anyone else currently does any marketing for our official blog, this may actually help out the official blog. Furthermore, I'll be able to talk about more than just programming here.
Why make such a sudden shift? Chris Keller, our online marketing guy, convinced me that a blog should be more than just a fun place to write down your thoughts. In part, he used Avinash Kaushik's great post here to convince me. He also showed me his own blog. However, I've been thinking about doing the same thing for other reasons.
This raises several interesting questions. First, why didn't I post links to my blog posts around the internet to try to get people to notice PC-Doctor's blog? You can rephrase the question slightly and ask why its better for me to market a blog that's separate from PC-Doctor.
The fundamental problem is that the official blog is not my blog. It has and it has to have a different purpose than a personal blog. I might occasionally write about things like video game design on the official blog, but I always made it relevant to our software. Running trails around Reno and what I might do if a bunch of 12 year olds start shooting guns at the trail in front me really doesn't fit at all on a corporate blog. It might fit here just fine.
In addition, because it's a blog about my stories, I might not mind advertising it on forums or other blogs. The reward for doing that marketing is that this blog has, over the course of several years, the chance of getting a following. Except for Andy, the PC-Doctor blog does not have much of a following. An increased number of people posting in my comments would be a large reward for me. This will require me to market my blog, and it's not entirely clear that I'll have the energy to do much of that, but I certainly didn't want to do it when it wasn't owned by me.
Should PC-Doctor change something about their blog to make it easier for people like me to stay there? No, they shouldn't. PC-Doctor's blog right now is mostly a bunch of posts by me. Customers coming to my posts will see that PC-Doctor hires at least one person who think on their own, and potential employees who come to my posts will see a confusing assortment of topics that may interest some of them. However, no one will buy our products because of my posts.
In fact, if you dig a bit deeper, there are some valuable posts there by other people. Kim Seymour wrote a great article that customers probably would be interested in. (Actually, I liked it, too. You should click on it if you have any interest at all in what PC-Doctor does.) Aki has written some fantastic articles, mostly about non-PC hardware. They've got interesting stuff to say that's relevant to our customers, and my post hides what they're saying.
Hopefully, we'll do something to encourage other employees to write more. Currently, employees are supposed to write on their own time with almost no reward. Some incentive, either monetary or otherwise, might help out. When we first started out, PC-Doctor gave away a Wii for the most prolific poster. Chris Hill won it, and I was jealous. :) They've got another prize up for grabs now as well, but it hasn't been as effective.
Writing a blog has turned out to be fun for me. I'm already convinced. It's been a great way to organize my thoughts about a topic, and I've learned quite a bit while doing it. I expect to continue to have fun in its new location.
I should point out that Doug van Aman, our marketing lead, has been nice enough to get me the copyright for the existing posts that I made. (Thanks, Doug!) I copied them all over verbatim. Without my existing library of posts, it would be much harder to do this.
Tuesday, June 3, 2008
Enums in C++ Suck
Like most strongly typed languages, C++ has a way to group a set of constants together as their own type called enums. Enums are extremely useful in a wide variety of circumstances. However, enums in C++ have a lot of problems, and, in fact, they're really a mess. I'm certainly not the only person to complain about this, either.
Enums don't fit in with the rest of the language. They feel like something that was tacked onto the language to me. This is purely an aesthetic issue, and the fact that they're useful in a wide variety of circumstances probably negates this.
More practically, you can't control the conversion of the enum to and from integers. For example, you can use the less than operator to compare an enum and an integer without using a cast. This can result in accidental conversions that don't make sense.
Perhaps the worst problem is the scope of the constants defined by the enum. They are enclosed in the same scope as the enum itself. I've seen a lot of code where people prepend an abbreviation of the enum's type to each of the enum's constants to avoid this problem. Adding the type to the name of a constant is always a good sign that something bad is happening.
In addition, you can't decide ahead of time what the size of your enum's type is. C++ normally tries to give the programmer as much control as possible. In the case of enums, this allows the compiler to store your enum in whatever type it wants to. Frequently, this doesn't matter, but when it does matter, you'll end up copying the value into an integer type that's less expressive than than the enum.
After the break, I'll explain what other languages are doing about it, what the next iteration of the C++ standard will do about it, and what you can do about it now.
Enums don't fit in with the rest of the language. They feel like something that was tacked onto the language to me. This is purely an aesthetic issue, and the fact that they're useful in a wide variety of circumstances probably negates this.
More practically, you can't control the conversion of the enum to and from integers. For example, you can use the less than operator to compare an enum and an integer without using a cast. This can result in accidental conversions that don't make sense.
Perhaps the worst problem is the scope of the constants defined by the enum. They are enclosed in the same scope as the enum itself. I've seen a lot of code where people prepend an abbreviation of the enum's type to each of the enum's constants to avoid this problem. Adding the type to the name of a constant is always a good sign that something bad is happening.
In addition, you can't decide ahead of time what the size of your enum's type is. C++ normally tries to give the programmer as much control as possible. In the case of enums, this allows the compiler to store your enum in whatever type it wants to. Frequently, this doesn't matter, but when it does matter, you'll end up copying the value into an integer type that's less expressive than than the enum.
After the break, I'll explain what other languages are doing about it, what the next iteration of the C++ standard will do about it, and what you can do about it now.
I'll use a simple example for this dicussion:
C# has enums that behave a lot closer to what I'd like. This is what they look like:
I'm not the first person to notice this problem, obviously. The next iteration of C++, C++0x, is going to add a much safer enum. This is what it'll look like:
It's actually not so hard to do a lot of that yourself if you throw out idea of using enums. For example, at home, I use something that looks a bit like this:
With only a bit of preprocessor magic, you can do the same thing.
Here at PC-Doctor, we define our enums in an XML file and use a code generation step to create the enum. The end result is the same as the preprocessor method: the enum can do whatever you want it to do.
While standard C++ enums are relics of C, lack most of the safety that C++ programmers are used to, and have a variety of other problems, there are ways around the problem. C++0x will add another alternative, but it lacks the flexibility of a home grown solution. You may decide to stick with your own solution even after your compiler starts supporting the new enums.
This post was originally published on the PC-Doctor blog.
enum Shape {
Circle, Triangle, Square
};
bool shouldBeAnError = Circle < 0;
C# has enums that behave a lot closer to what I'd like. This is what they look like:
enum Shape {
Circle, Triangle, Square
}
// Note the wonderfully ugly conversion and the need to explicitly
// say that circles are shapes.
bool isALotMoreExplicit = Shape.Circle < (Shape)0;
I'm not the first person to notice this problem, obviously. The next iteration of C++, C++0x, is going to add a much safer enum. This is what it'll look like:
enum class Shape
: int
{
Circle, Triangle, Square
};
// Note that we have to explicitly say that Circle is a Shape. That's great.
// The current standards document doesn't say how I can convert an int
// to the enum, though. I'll see if I can post a comment on that...
bool isALotMoreExplicit = Shape::Circle < (Shape)0;
It's actually not so hard to do a lot of that yourself if you throw out idea of using enums. For example, at home, I use something that looks a bit like this:
DECLARE_ENUM( Shape, int, (Circle)(Triangle)(Square) );
bool isAsExplicitAsIWant = Shape::Circle < Shape(0);
With only a bit of preprocessor magic, you can do the same thing.
Here at PC-Doctor, we define our enums in an XML file and use a code generation step to create the enum. The end result is the same as the preprocessor method: the enum can do whatever you want it to do.
While standard C++ enums are relics of C, lack most of the safety that C++ programmers are used to, and have a variety of other problems, there are ways around the problem. C++0x will add another alternative, but it lacks the flexibility of a home grown solution. You may decide to stick with your own solution even after your compiler starts supporting the new enums.
This post was originally published on the PC-Doctor blog.
Subscribe to:
Posts (Atom)