On work and clean code

It’s been like 6 months of me working on Unity. So far so good. We’ve done a big new release recently, so after some pre-release insanity we’re a bit more relaxed. I guess not for very long though, we have more stuff planned than we can handle :)

It sure feels nice to work on an actual software product. I think it’s probably the first time in my carreer that I know people are using my work and I do care about that. Having worked on projects before, it’s very different - a project just comes and goes, and once it’s finished you never think about it again. And most of the time you don’t care about “the clients” that much either. Working on a product is much more rewarding (especially if the users seem to like it).

Another interesting here is that we are a very small software shop. So everyone has to be a one-man-army (the others certainly are, not sure about myself). Design, program, fix bugs, decide on features, do support, write docs and even do html tweaks for the website. Of course, it could be Jack of all trades, master of none (*), but somehow I feel that we are managing pretty well. And I like to be involved in various aspects of making a product.

(*) though wikipedia says that the full saying is Jack of all trades, master of none, though ofttimes better than master of one - which looks like a positive thing to me.

A completely different theme: when programming, it’s always good to massage the code you’re working with a bit. Remove unneccessary #includes. Write a comment on tricky code block. Fix warnings. Do small refactorings. Remove unused code paths. It does not take much time and helps to keep the codebase clean. Removing unused code is especially good - for some reason I love removing code. Could do that all day long; probably I’m some kind of anti-programmer :)


Windows on a Mac experience

A post on GrammerJack blog made me post similar impressions about Mac vs Windows etc. So:

I was the evil guy to install Windows on my MacBookPro (via BootCamp) as well. That was like a month ago. The thing is, I think I haven’t booted into windows for like 20 days on this machine. At first I though gee, I’ll use VisualStudio on this machine, will watch demos and have a proper Subversion client! But I use VisualStudio, watch demos and have a proper Subversion client on my work PC, so there are not that many reasons to boot windows on the laptop…

Plus BootCamp has small annoyances that GrammerJack mentions: no two finger scrolling (it’s the best thing in laptops I’ve ever seen), no backspace key, function key not supported, the machine never seems to come to proper sleep (i.e. it’s always hot to touch), trackpad sensitivity and precision much worse than on OSX etc.

And in general, I must admit that I kinda like OSX. “It feels nice” would be my best attempt at explanation, for I can’t think of any serious reasons why I like it. Well, yeah, the UI is nice etc. Mind you, I like Windows as well, but at least on this laptop, OSX “feels much nicer”.

Now if only Apple could throw the bunch of crap called XCode away and make something like VisualStudio+VisualAssist; and if only OpenGL would be so sweet to use as D3D! I’d jump on OSX bandwagon immediately and be a happy man. Alas, XCode is just lighyears behind (*).

(*) Though Apple has some really cool development tools as well (Shark etc.)


Back to some shader programming

There is something magic in programming shaders. Like, when you edit one of our standard shaders and save, say, nine instructions in it - the feeling is really good. Maybe because, well, it’s a standard shader - so that means everyone’s graphics will actually render faster. Nice!

Maybe it’s because shaders are such a short piece of code, without too complex dependencies… I’m sure anyone who knows graphics hardware will corect me here, but let’s oversimplify and pretend that shaders actually execute in a simple way… So when you make a shader shorter, you pretty much know it’s going to be faster. When you make it “look better”, it almost certainly will look better. Try doing that in your regular big codebase - by optimizing something you may break something else; and in general you have no clue what to optimize unless you do your profiling homework. So, my take is that shaders are much simpler, so the joys of looking at assembly output actually make sense.

So, yeah, I’m back to some shader programming.


It's always unexpected

I have a MacBook Pro now and slowly am getting used to it. It’s quite hard, considering that I’ve never had a laptop before; and actually used any Mac for the first time just a couple of months ago. My daughter thinks the best part about it are the weird image effects in PhotoBooth. I just can’t disagree.

On the unrelated note, now I am a Microsoft DirectX MVP. Just about the time when I almost stopped using it! I’d love to, but we’re making a product that primarily runs on the Macs… quite hard to use D3D there. But almost every day I wish I could, and every second day I’m annoying my coworkers by saying that D3D is lightyears ahead of TheOtherAPI!

The MVP award just came out of nowhere. It’s one of the things that you never expect - but hey, it feels good anyway. And now I have a MVP laptop case for my MacBook :)


OOP and other things now and then

Approximate conversation at work the other day:

Yeah, I split this into separate files, removed this and made these classes to make it actually work.
Ok, but don’t go too fancy with objects here.
Sure! I think it’s the only place where I actually use inheritance!

Heh. I’d imagine how that would have looked back some 5 years ago. “What design patterns did you use here?” etc. Funny how things change.

I think I’ve got it by now - took me way too much time for such a trivial thing - there is no silver bullet. OOP or any other buzzword is just a means to do something; sometimes it fits, sometimes it does not. Regarding OOP, I highly recommend Execution in the Kingdom of Nouns essay - it’s way exaggerated, but has the point. The best part:

advocating Object-Oriented Programming is like advocating Pants-Oriented Clothing

There is one thing about the codebase that we have at work that I love: it does not use any particular design/programming technique. A bit of OO, a bit of metaprogramming, a bit of plain C style, a bit of preprocessor macros, etc. I like to think that we’re using the best of those worlds, of course :)