On Restarting

Posted by DaSpirit on Jan. 2, 2014, 8:22 p.m.

So, recently I've pretty much restarted on my IDE project. This got me thinking about restarting on other projects. Some reflections and tips about restarting projects:

Don't

Let's face it. It is a boring task. You have something working and you destroy it. Work on getting your game to work. What is a game if there are no mechanics?

And Optimizing?

Optimizing is also a waste of time. Don’t do it unless you either see lag or you’re already finished with your game, with the latter always being a priority over the former. Some programmers focus too much on getting things perfect. It’s funny, because these are also the programmers that have never finished anything (myself included). It’s a trap, do not fall into it. Also, be careful of early optimizations.

What About Organizing?

Organizing is indeed another time waster, and should not be done unless you are working with a team. It works as long as you know where everything is and you do not need to move stuff around if so.

What To Do If I Do Rewrite?

There are a few times where a rewrite is useful. Try to keep as much old stuff as possible. Rewrite around everything. DO NOT delete anything. Just make classes that serve to replace existing ones and slowly give them new functionality.

Anyway, I hope this small blog helps anyone, especially with F4D currently going on. I am forced to rewrite because I had to change a major class because of my plugin framework (should have done research on that earlier). I’ve fallen a victim to rewriting in all my projects. Remember, chaos is expected, this is the law of entropy. If you’ve dealt with the chaos before attempting to rewrite, you can surely deal with it some more.

Comments

Toast 10 years, 4 months ago

Well, yes, that's what optimisation means. I'm saying I don't know if it is smaller, since relational operators are ultimately implemented using bitwise operators anyway (at least that's what I'm guessing cos that's the only thing that makes sense)

I'm wondering this because I'm programming a game boy, if you're programming game maker you don't need to give the tiniest shit

I suppose this is what all that fancy stuff like profiling is for.

Toast 10 years, 4 months ago

Yeah for the most part I just make sure I'm programming in the elegant way and not the dumb way eg using objects the way you're meant to use objects: using polymorphism and not having massive switch statements everywhere. Optimality makes no odds for most things

Powerful Kyurem 10 years, 4 months ago

CyrusRoberto: I wasn't referring to every situation. I was merely stating that unless it limits it (as you pointed out) the general idea is that it runs faster by eliminating steps and/or makes the source code shorter (to make the file smaller). In toast's case. "If (x&0x8000)" is better.

However, inline functions aren't shorter. They just copy and paste code, but I think to be fair, we are not talking about preprocessor commands.

(BTW, optimization can also refer to how easy it is to work with the code.)

colseed 10 years, 4 months ago

Quote:
(BTW, optimization can also refer to how easy it is to work with the code.)
i think you may need to check your definitions sir

Astryl 10 years, 4 months ago

I'll agree that focusing on formal optimization, and over-organizing small projects, can lead to the death of a project (Or the extremely slow development/death/stagnation of the project).

However, I do recommend something called logical optimization. Make careful decisions about the system you're creating from the beginning, so you don't get bottlenecks later on down the line.

On the topic of organization… don't play pretend. Playing corporate manager is fun until you realize how little you actually end up doing. This directed towards organization of your 'team'. If you're working alone, as you say, it's pointless.

On the other hand, making sure your code is organized in some manner is damned well important.

This covers basic things like file/class naming, consistent naming conventions, etc.

Also, having a little schedule is good, especially if you're working on a long term project. Make it a loose one; just committing to working a few minutes a day on a project is going to get you further than procrastinating over it and doing perhaps a few minutes a week.

Either way, this sort of thing scales. Larger projects require more optimization, more organization, better management. Smaller projects, not so much.

If you're having to restart your project, you have to ask yourself why. What happened to the project that forced you to begin again.

Cesque 10 years, 4 months ago

Quote:
CyrusRoberto: I wasn't referring to every situation. I was merely stating that unless it limits it (as you pointed out) the general idea is that it runs faster by eliminating steps and/or makes the source code shorter (to make the file smaller). In toast's case. "If (x&0x8000)" is better.

However, inline functions aren't shorter. They just copy and paste code, but I think to be fair, we are not talking about preprocessor commands.

(BTW, optimization can also refer to how easy it is to work with the code.)

Anyway.

At least Python programmers have it easy. Just use as many built-in functions as possible, because Python code runs faster the less of it is actually Python.

What's weird is that unlike Toast, I think I actually "get" optimisation pretty well, even though I don't think of myself as a programmer in the first place. Then again, I have no idea what "if(x&0x8000)" means. Don't other programming languages have some neat equivalent of timeit?

Astryl 10 years, 4 months ago

Quote:
I have no idea what "if(x&0x8000)" means.
That'll perform a bitwise AND on all the bits in that expression.

0x8000 translates to

1000000000000000b in binary, and if you were, say, comparing it to:

1000101011110100b, the result would be:

1000000000000000b.

Of course, in the case of comparing if(x >= 0x8000) and if (x&0x8000), they will return different results anyway. Using & could be used as a makeshift equality operator (if(x&y == 0) then x and y are equal). But really, a CPU is pretty good at equality tests anyway.

As for condensing code, it's pointless. The only reason that was ever done was when we had limited memory. And I mean limited. Applaud Microsoft for fitting their first BASIC interpreter in 8KB of ram. Because that's nearly ten times shorter than the length of this page (Save it and see :P).

Toast 10 years, 4 months ago

Quote:
Of course, in the case of comparing if(x >= 0x8000) and if (x&0x8000), they will return different results anyway.
x is a 2 byte integer, so 0x8000 is the most significant bit. So x&0x8000 returns 0x8000 for any number greater than 0x8000, 0x0000 otherwise. So both if statements are true and false at the same time.

Anyway I don't know why I brought it up since I answered my own question: you don't need to know how it works, you just need to know if it's faster by timing it.

Astryl 10 years, 4 months ago

Quote:
x is a 2 byte integer, so 0x8000 is the most significant bit. So x&0x8000 returns 0x8000 for any number greater than 0x8000, 0x0000 otherwise. So both if statements are true and false at the same time.

I derped again. :3

In terms of development on an IA32/64 system, the CPU has comparison operators that basically invalidate the need to use such methods for comparison; on a system like the GB though, it'll definitely save you a cycle or two.

Speaking of which, I feel like trying out a bit of GB development. I'd like to see if I can make a little game for it :P

Alert Games 10 years, 4 months ago

too many comments, dr;

Its a good idea to start over if you want to reorganize and optimize in some way. Keep the old stuff, and copy and paste the good stuff over in the right way. And rewrite the stuff that is bad.

Starting over takes a considerably less amount of time than it did before when you were working through the problem.