Sunday, April 30, 2006
Sunny days ahead...
They were off at Grandads today, and he picked up gran as well and they all went to the beach. I put down some weedkiller and kicked back and watched some T.V. After a full day out and about yesterday I felt like a relaxing day before I head into work tomorrow. Everyone else is off on holiday, but I dont have the days to spare so...
Should be good fund tomorrow, as I start on the threading stuff for real. I was laying the ground work and rearanging the code a bit on Friday, so now I can actually start coding it.
I asked Russ to do a mini code-review on Andrews code as I suspect that his opinion will be respected more than mine. The problem with not being "Mr C++" is that not many people respect your code, which I find irritating beyond belief. In fact it pisses me off quite a bit, probably because the people who tend to do that, usually don't code in the real world, and are too deep into whats "proper" rather than whats right and what's best. At my review Luke said that my code wasn't designed properly and wasn't maintainable, which I personally find to be rubbish, since I've always managed to maintain my code and do whatever I need with it. The review was done ages ago and still pee's me off a bit, and Im not sure if its over the stuff that was right, or the stuff thats was wrong.
Friday, April 28, 2006
Multi-tasking a "yuck"
I've started looking at threading my application at work, and have been trying to come up with the best way of doing it. Theres lots of ways you can thread an application, the simplest being you simply decided to run a bit of code on the other thread and it sleeps when its no busy. This is fine, and for tools usually what you need sine the other threads tend to be worker threads. But in games, you want to try and load balance a bit more - kind-of like what windows does, but a bit better.
So, I've come up with a way of using a thread pool that allows me to spawn off many tasks in the game as I come to them, this means that processes may switch back and forth from CPU to CPU, but allows the system to load balance it.
So how does this work in practice. Well, if you have 2 CPU's, you'll have 2 main running threads the second is synced to the first and will only start once its told to - it could even be a thread in the thread pool itself. These 2 threads then start ticking through the list of processes in their own time, meaning that if one slows down on a complex bit of processing, then other can pick up the slack. If something comes along that will block the thread - file or networking, then these are passed off to the threadpool but the file or network manager, and the main 2 threads carry on as normal.
It should work fairly well, and should allow for almost transparent use of multiple CPU's on the system. In theory.... However, if your application spends 95% of the time on one thing, then your still stuffed no matter what you do; you should learn to code better!
I love doing multi-threaded stuff, its greatfun seeing all your processes getting dished out and seeing all the available CPU's doing something. I have an old (very old) 12 processor SGI at home, and watching all the processor activity bars on the front being used to the fullest is very cool.
Tuesday, April 25, 2006
POD casting....
This was all part of my drive to understand templates, and in doing this, Russell and I figured out how to use these POD types correctly. He had thought he was using them right before, but it turns out that although he'd tested it, he had then added stuff that made it a plain old class again. Problem is, the compiler doesn't tell you it just switches, and the only way to know for sure is to disassemble the code and see what its using!
Anyway, I'm starting to get the hang of templates on a rudimentary level at least and while I'm still a long way off from using them in anger, at least I can now follow code that does use them - almost.
Monday, April 24, 2006
Ben Nevis
I've been busy playing with templates and STL today and it's starting to come together I guess. It's a bit strange and I know that it's going to take time to actually use correctly, but I guess I'll manage okay. I did dig a little deeper into the STL stuff, and didn't like it. I don't mind the interface and all the rest but I don't like the complexity of the STL library. Even in release mode it generates a lot of code, much of it I think unnessasary by most coders and the features it adds I dont think should be up to STL but the programmer to wrap it.
Still, it must be said, for the average programmer doing normal sized programs STL is fine, and easy to use. However, I worry about using STL and large programs, the memory footprint and fragmentaion isn't very good and the ammount of code bloat with many unique classes can be nasty, particually when used with other templates.
Saturday, April 22, 2006
To STL or not STL...THAT is the question...
So, here I am at home playing with linked list templates and trying to figure out what STL is all about. Its odd really, to be good at your job you have to be able to do things properly, an quickly. But whenever you have to learn something new, one half of that won't be true anymore. You'll either do it quickly and wrong, or slowly and right. This is one of the things that grates me about learning new stuff, particually something as complex as templates. Yes, the basics of templates are easy enough, but to get the best use out of them, you have to be more clever than that.
STL is a case in point. when you decided you want to include a list, its easy enough: list< class > var;. And your done. And this is usually as far as most programmers get. But I'm not most coders, I want to understand whats going on under the hood to see why I should use STL, rather than just being told its a good idea. And under the STL hood, theres a demon waiting to escape - its horrible. From this, I can now see why windows slows down with each iteration, and it frightens me that most coders just dont know what its doing, burning away your time and memory without you realising it.
A small example... everytime you decided to "push_back()" a new object, you have to figure in a few more things.
1) You're allocation of the object itself.
2) a small class that now links the objects together. (around about 16 bytes for a list)
3) 2 memory block headers that malloc() will allocate for each bit of memory you've allocated.
4) a Critical section In/Out each time you add (I'm guessing this is an implementation detail that some might not use, and possibly only in debug as well - I've yet to find out).
Thats a hell of a lot of work to add a link. If your dealing with thousands of links (or tens of thousands) then this is slow and memory consuming work; and most programmers will never understand why. In the C++ book there are 2 very good bits of advice. 1) Don't reinvent the wheel, and 2) Don't believe in magic, understand the libraries and what they do, and how.
Good advice.
Thursday, April 20, 2006
I've been doing some SQL Database stuff reciently, and it's pretty easy but good fun. Its kind-a like HTTP, TELNET etc. where you send simple strings and deal with the result, and I've been dealing specifically with updating my database dynamically. This is pretty basic stuff I guess, but its fundemental to what I'm doing so I have to make it "nice" as it were.
Oh well... off the get the kids from school, so much for a holiday; once you have kids all that goes out the window, but I wouldn't trade it for anything.
Tuesday, April 18, 2006
Still, A whole day of typing and it worked first time! The only other time I rememebr doing this was way (WAY!) back in 1992(ish) when I was doing Lemmings 2 on the SNES, I spent a week writing a single (although complex) routine that let me draw graphics onto the screen. It worked more or less first time too. Perhaps I should take the hint and write all my code this way, you seem to read it more before you run it and hence spend less time debugging the bugger.
A passing comment from Russell had me fizzing inside again; I remember telling Dave that one of the things I won't have, is being told I'm wrong. Now don't get me wrong, Russell knows what he's doing and I respect his judgement over most peoples, but he mentioned that something I did was badly designed, and I almost screamed. Part of the problem with learning new stuff is that you hardly ever use it correctly at first, and the "badly designed" part was a suggestion from someone else. I didn't want to do it that way in the first place. Every job I've worked, at somepoint someone has told me I'm wrong about something Im doing, and over the years I've come to notice that in the stuff I do, I'm usually not - not if its something I've sat down and thought about. I told Dave there were a couple of things that would make me leave. First one was being told I'm wrong all the time, 2nd was not enjoying my job or not being allowed to do the job I want. It'll be interesting to see if any of these come true here...
Looks like we might have mice again... I really need to move the rabbit hutchs so they dont attract mice and rats. We had rats a couple of months ago (well a rat - but it was big enough), and it ate everything in sight!
*sigh* its never easy.
Monday, April 17, 2006
I was listening to Pinks new album, and one song in particular struck a cord: Dear Mr President. The main reason is that it goes on about a hard day's work, and I have to begin to think about what would happen should I leave the game industry. It's true that being a coder, I've never truly known a hard day in my life. Sure, we have some "crunch times" where we might work a full 24 or even 36 hour day, and we might never get any overtime, or a life after work - but when all is said and done, its easy work; enjoyable even.
I know if I worked 9 to 5 in McDonalds it would probably feel like a living hell, very few people actually really enjoy that kind of work. So have have to feel lucky in the position that Im in, even if I'm unsure as to what the future of that might be, at least I know what involved, and love my work. I come home at night and do more with out a second thought, I can't see people in shops or McDonalds doing that.
I've been having more woes with the new Visual Studio 2005, its really nice overall, but has some very irritating little quirks. Ever since Microsoft had security problems with buffer overruns, it seems that they've been at pains to force everyone to learn from their mistakes. It never seemed to occur to them that we might not make that mistake in the first place, but VS2005 almost forces you to use these new functions - even if you dont want to!
Saturday, April 15, 2006
I lost my mum to cancer last August, and I'm still kind of struggling with it. Before it happened I alwasy wonder how people manaed, and assumed that you'd just get over it since people don't cry forever. But after its happened to you, you begin to realise you never ever get over it, you simply start to accept it. Now not a day goes by when I don't think of her, and whenever I'm watching TV and theres a death of some kind, I'm almost in tears all over again. I think the main thing is that you can think about them in the past and as long as you dont dwell on you feelings or theirs, you manage - just, but as soon as you start to really think about them and what they're missing, thats it, you're in tears again. I don't think people are designed to lose ones they love, and its one of the (many) reasons I think my religion helps me.
Anyway.... Luca has been emailing me asking about my retro project again.(http://xeo3.plus4.net) so it's probably time to start that up again. It would be nice to get it finished, its only taken 6 years so far!!! Thats the problem with doing games, you just cant be bothered doing them when you come home again.
Thursday, April 13, 2006
Course... thats not to say my codes perfect, its a prototype so by its very nature some of its just not going to be right until its rewitten; but it does allow it to look as pretty as is possible under the circumstances - which is a good thing.
Wednesday, April 12, 2006
We also had a discussion about things like static_cast<
So, the ugly question of what should I do comes up again... I think a friend of mine might have some opportunities soon, but it might just be too soon. I don't really want to haul anchor and leave when Realtime are just starting to get things orginised with the new technology, since at the moment, I'm kind of integral to their plans. Leaving now would be a set back for them, and I don't really want to do that. At the same time... you can't ignore certain opportunities, because they are rare and you simply might not get the chance again.
Tuesday, April 11, 2006
Saturday, April 08, 2006
What gives us the strength to carry on?
1) Carry on doing pure research, and accept that your only ever going to figure things out, and let other people actually do the work. I'm actually fairly good at this, and can usually see past abstract problems to simple solutions. But I don't know if I like the idea of people looking down their noses at the code I produce.
2) Accept that I simply can't keep up, and move on. Leave the industry I love, and do something else completly. This is a hard one, because if I leave, I'm fairly sure I'll never manage to get back in.
The problem gets more complicated for me, since I know that if I leave, I'll probably end up doing some drudge job I hate, and come to seriously regret leaving in the first place.
It's the first time I've ever thought about what I'll do after games... and the first time I've ever look at what life would be like doing something I hate. At the end of the day, that may be the thing that keeps me in one more day, until something comes along that gives me a chance to do something else I'll love, why leave?
Friday, April 07, 2006
The life of a games coder.....
I keep thinking I'd like to write a book, but I'm fairly sure almost everyone does at some point. Normally I think people have lots of ideas and just think it would make a great story, and thats abouit it; but I keep thinking about the same story line. It's not like I feel I've any great talent for writing, in fact I know I pretty much suck. It's just that its the kind of story I'd like to read - in fact, you could say that if someone else were to write it, I'd be happy enough not to have to. Its not like I have loads of spare time either. Oh well... add it to the list of things to achive in my life I guess.
Work's taken a slightly odd turn too... I had my appraisal a couple of weeks ago, and it's actually left me wondering if I should remain in games and in fact programming as a whole. Dave (being Dave) seemed hell bent on trying to reasure me about things, but I remain unconvinced. I can't decide if I'm lagging too far behind in style and procedure, or if everyone else I'm invloved in is too deep into "style" over content for their own good.
Currently, almost everywhere I look, I think people are over complicating things and I have a theory. I'm not very bright - when you get right down to it - and I think because of this, I code in a simple way. Thats not to say its bad, unthought out code - no. Its a plain, and simple approach that means its never over burdened with language features just for the sake of it.
I don't know.... I used to think that the whole key to staying in games was to learn everyday, and keep up to date. But now I'm beginning to wonder if I have - or can.