What is an ‘engine’?
I’ve had a few people ask me what exactly an engine is, and why it’s so difficult to make one.
First of all, it is not difficult to make an engine, it is difficult to make a good one (my current work should not be mistaken for a ‘good engine’, at least not yet). The difference between something which works, and something which is both dynamic and clean, is that you can build an ‘engine’ which does precisely what you tell it (by hard-coding every possible outcome), whereas a dynamic/clean engine enables you to add things easily, externally, using an interface of some kind (usually an Application Programming Interface, like an API).
Secondly, to answer ‘what is an engine’ in brief: an engine is effectively a series of mechanisms (functions or methods, with the option for classes or modules, depending on your language). These mechanisms perform logical tasks, like drawing a box, or detecting a mouse click. There are different types or mechanisms (e.g. callbacks which fire when something is done, literally ‘calling back’). There are different purposes (input from keyboard/mouse, audio output, graphical output). Each of these parts require their own distinct components, usually external (unless you’re building the hardware too, in which case you probably have to do it yourself to some extent).
It is not difficult to build basic mechanisms, but it is time consuming to decide what you want. Even though I entered this with a fairly good idea of what I wanted, I have already had to compromise when I found elements I chose to use don’t quite do what I want — and not wanting to have to modify them heavily, thus breaking ease-of-update later, I had to make minor changes (e.g. I now have a single global variable, and this is rather annoying).
I hope this provides an answer suitable to the question. I might, at a later stage, run through building some trivial components in a non-OOP way, for those who are interested (feedback on this would be useful, either here or via IM/e-mail for those who have it, so I know I’m not wasting my time before I begin).
-
swixel posted this