<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Allefant Games &#187; Notes</title>
	<atom:link href="http://allefant.com/category/notes/feed/" rel="self" type="application/rss+xml" />
	<link>http://allefant.com</link>
	<description></description>
	<lastBuildDate>Sun, 07 Mar 2010 04:14:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Lua</title>
		<link>http://allefant.com/lua/</link>
		<comments>http://allefant.com/lua/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 23:43:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://allefant.sourceforge.net/wordpress/?page_id=278</guid>
		<description><![CDATA[Looked a bit at Lua lately, as tinypy doesn&#8217;t really seem to carry on (yet) and so is a bit risky to use for anything.
Good points about Lua I&#8217;ve seen at first glance:

Human readable syntax.
Simple, fast and small virtual machine.
Secure embedded execution.
Easy to embed and extend in a C program.

Bad points:

Syntax is almost too simple [...]]]></description>
			<content:encoded><![CDATA[<p>Looked a bit at Lua lately, as tinypy doesn&#8217;t really seem to carry on (yet) and so is a bit risky to use for anything.</p>
<p>Good points about Lua I&#8217;ve seen at first glance:</p>
<ul>
<li>Human readable syntax.</li>
<li>Simple, fast and small virtual machine.</li>
<li>Secure embedded execution.</li>
<li>Easy to embed and extend in a C program.</li>
</ul>
<p>Bad points:</p>
<ul>
<li>Syntax is almost too simple &#8211; it&#8217;s almost 100% identical to a 20 year old BASIC dialect.</li>
<li>Variables are global instead of local by default &#8211; catastrophic design mistake.</li>
<li>Arrays start with &#8220;1&#8243; instead of &#8220;0&#8243;. Somewhat cumbersome.</li>
</ul>
<p>The global variables are a kinda big issue, makes it very hard to use scripts in a good way if you have many of them. But of course nothing stops you from sticking a &#8220;local&#8221; before every use of a variable &#8211; which would negates the &#8220;human readable&#8221; part in the good points though. Oh well.</p>
]]></content:encoded>
			<wfw:commentRss>http://allefant.com/lua/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why reverse polish notation is bad</title>
		<link>http://allefant.com/why-reverse-polish-notation-is-bad/</link>
		<comments>http://allefant.com/why-reverse-polish-notation-is-bad/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 13:44:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://allefant.sourceforge.net/wordpress/?page_id=253</guid>
		<description><![CDATA[In one word: It&#8217;s unreadable for us humans. Just look at this example in RPN:
1 2 3 4 5 6 + &#8211; - + -
How long do you need to calculate the result if you just read along letter by letter? A long time, because until you reach the first plus sign, you simply can&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>In one word: It&#8217;s unreadable for us humans. Just look at this example in RPN:</p>
<p>1 2 3 4 5 6 + &#8211; - + -</p>
<p>How long do you need to calculate the result if you just read along letter by letter? A long time, because until you reach the first plus sign, you simply can&#8217;t do anything at all but remember the numbers. And we&#8217;re bad at remembering many things.</p>
<p>Just to make this clear, do the same in in-fix notation:</p>
<p>6 + 5 &#8211; 4 &#8211; 3 + 2 &#8211; 1</p>
<p>Reading along letter by letter, when you get to the last &#8220;1&#8243;, you already have the answer of the calculation. This is not because we are used to infix notation more than RPN &#8211; it is just because it is the natural way things work.</p>
<p>This also is not only the case for mathematical formulas, but also language. If I say &#8220;I gave you a book.&#8221;, then in RPN it would be something like &#8220;I you book a gave&#8221;. Or &#8220;I went to the shop and bought a book.&#8221; would be &#8220;Book a I shop the to went bought and.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://allefant.com/why-reverse-polish-notation-is-bad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IceJunk</title>
		<link>http://allefant.com/icejunk/</link>
		<comments>http://allefant.com/icejunk/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://allefant.sourceforge.net/wordpress/?page_id=68</guid>
		<description><![CDATA[I did this code for some allegro.cc competition called &#8220;Screen hack&#8221; (I think). A complete game, and the code fits in one 80&#215;25 chars screen.
[[Include(icejunk.c)]]
]]></description>
			<content:encoded><![CDATA[<p>I did this code for some allegro.cc competition called &#8220;Screen hack&#8221; (I think). A complete game, and the code fits in one 80&#215;25 chars screen.<br />
[[Include(icejunk.c)]]</p>
]]></content:encoded>
			<wfw:commentRss>http://allefant.com/icejunk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Options_are_Good</title>
		<link>http://allefant.com/options_are_good/</link>
		<comments>http://allefant.com/options_are_good/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://allefant.sourceforge.net/wordpress/?page_id=6</guid>
		<description><![CDATA[&#8221;Options are bad.&#8221; I&#8217;ve seen that claim too many times now. Like often, the intention of such phrases is good, but is easy to mis-interpret. This is very similiar to &#8221;KISS&#8221;: Of course it is important to keep things simple, and often even force yourself to keep your project simpler than it could be &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>&#8221;Options are bad.&#8221; I&#8217;ve seen that claim too many times now. Like often, the intention of such phrases is good, but is easy to mis-interpret. This is very similiar to &#8221;KISS&#8221;: Of course it is important to keep things simple, and often even force yourself to keep your project simpler than it could be &#8211; since else you will need to spend increasinly more time. But the things which you want need to be there nevertheless &#8211; the most simple program always is no program at all, and that is not the goal of KISS. Also, projects do evolve over time, and so a feature which initially would have violated KISS might very well be possible a year later.</p>
<p>With options, more options not only violate the KISS principle, but also the amount of testing increases. Still, options are not bad. That is &#8211; if you allow adjusting any small setting, then yes, this may be bad &#8211; many combinations might not make sense, and things get complicated, if not in code then for the user who can not know which settings make sense and which not.</p>
<p>But, if you have no options, you actually do have options &#8211; they simply are fixed and forced on the user, without the possibility to choose what they like. Which is very bad.</p>
<p>And, the claim that testing increases much is false, if you do options right. The example that may be given is, if you have 4 boolean options A, B, C and D, then you need to test your program with ABCD first, then ABC[D], AB[C]D, AB[C][D] and so on, 16 possible combinations in total. But that assumes that each option depends on all the other ones. If your options behave like that, they probably are done in a bad way. Good option are done so they automatically work together with any other options.</p>
<p>This is not always simple to achieve of course. So yes, no options is simpler than options. Such as no program is simpler than a program. But a program with good options is much better than a program with no options. Since, at least for part of the users, the hardcoded defaults will be bad defaults.</p>
]]></content:encoded>
			<wfw:commentRss>http://allefant.com/options_are_good/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimization</title>
		<link>http://allefant.com/optimization/</link>
		<comments>http://allefant.com/optimization/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://allefant.sourceforge.net/wordpress/?page_id=7</guid>
		<description><![CDATA[Optimization is good. The hardware I own usually is some years behind the newest one available at the time, so that alone makes me appreciate when something has as much raw performance as possible. There just is no good reason to make something use up more resources than it needs. Why waste CPU cycles to [...]]]></description>
			<content:encoded><![CDATA[<p>Optimization is good. The hardware I own usually is some years behind the newest one available at the time, so that alone makes me appreciate when something has as much raw performance as possible. There just is no good reason to make something use up more resources than it needs. Why waste CPU cycles to make it run 10 times slower, if you can optimize to make it run twice as fast? Why use twice as much memory as needed, when you can optimize to use only half as much?</p>
<p>Optimization is bad. It takes a lot of time better spent on implementing and improving the rest of your program, and the result is code which is hard or impossible to understand or modify, which is less robust, and maybe even has some subtle bugs. Why do something in a convoluted and complicated way, just to save some extra checks or a few bytes of memory here and there?</p>
<p>So, there, that&#8217;s my opinion on optimization.</p>
<p>Put in a different way, there is no clear yes or no answer. There&#8217;s always trade offs. The first one, it simple takes time to optimize working code. But of course, if you can make the code work better, and maybe even easier to understand, then it&#8217;s good to take the time to optimize it. Another trade off maybe, you can either optimize for size or speed, or something else. Such other thing may be robustness, correctness, or code readability. E.g. you could write something in C/C++ instead of Python &#8211; but is it really worth transfering your working code to something unmaintanable? In many cases, it is &#8211; there simply is no way around it. E.g. you can&#8217;t expect to make a graphics application by maintaining your framebuffer as a python list of lists, and then have it update more than one frame / second.</p>
]]></content:encoded>
			<wfw:commentRss>http://allefant.com/optimization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ObjectOrientedC</title>
		<link>http://allefant.com/objectorientedc/</link>
		<comments>http://allefant.com/objectorientedc/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://allefant.sourceforge.net/wordpress/?page_id=9</guid>
		<description><![CDATA[This is just an example how to get object oriented C. There are many more ways to do it, some much more advanced. This is the one used throughout Land.
About the used terms, just always assume what makes sense. Everything listed in the same line below means the same to me. Especially note terms in [...]]]></description>
			<content:encoded><![CDATA[<p>This is just an example how to get object oriented C. There are many more ways to do it, some much more advanced. This is the one used throughout <i>Land</i>.</p>
<p>About the used terms, just always assume what makes sense. Everything listed in the same line below means the same to me. Especially note terms in bold who appear more than once:</p>
<p> * base object, super class, parent class, base class<br />
 * sub object, derived object, sub class, derived class<br />
 * object instance, instance, class instance, &#8221;&#8217;object&#8221;&#8217;<br />
 * &#8221;&#8217;object&#8221;&#8217;, class, type<br />
 * object method, method, function, class method<br />
 * object property, property, variable, class variable, class property<br />
 * abstract object, abstract class</p>
<p>Assume, we have an object called Animal, with two methods &#8220;eat&#8221; and &#8220;go&#8221;.</p>
<p>{{{#!cplusplus<br />
void animal_eat(Animal *self, char const *what, int howmuch);<br />
int animal_go(Animal *self, int direction, int howfar);<br />
}}}</p>
<p>And, we also have a derived object called Bird.</p>
<p>This is how we could use it:<br />
{{{#!cplusplus<br />
Bird *bird = bird_new(&#8221;Sparrow&#8221;);<br />
animal_eat(bird, &#8220;Apple&#8221;, 1);<br />
animal_go(bird, 0, 1);<br />
bird_del(bird);<br />
}}}</p>
<p>Let&#8217;s define all the structs, and also add four properties to Animal, &#8220;name&#8221;, &#8220;hungry&#8221;, &#8220;x&#8221;, and &#8220;y&#8221;, and an extra property &#8220;z&#8221; to Bird.</p>
<p>{{{#!cplusplus<br />
typedef struct AnimalInterface AnimalInterface;<br />
typedef struct Animal Animal;</p>
<p>struct AnimalInterface<br />
{<br />
    void (*eat)(Animal *self, char const *what, int howmuch);<br />
    int (*go)(Animal *self, int direction, int howfar);<br />
};</p>
<p>struct Animal<br />
{<br />
    AnimalInterface *vt;<br />
    char *name;<br />
    int hungry;<br />
    int x, y;<br />
};</p>
<p>struct Bird<br />
{<br />
    Animal super;<br />
    int z;<br />
};</p>
<p>}}}</p>
<p>As you can see, this is defined using two C structs, one for the Interface, and one for the object itself. The interface simply is implemented as a vtable pointed to by the object.</p>
<p>Next, we define some housekeeping stuff.</p>
<p>{{{#!cplusplus</p>
<p>AnimalInterface *animal_interface;<br />
void animal_init(void)<br />
{<br />
    animal_interface = calloc(1, sizeof *animal_interface);<br />
    animal_interface->eat = NULL;<br />
    animal_interface->go = NULL;<br />
}<br />
}}}</p>
<p>This is an initialization function for the module. It defines an interface &#8211; but since our Animal is sort of an abstract base class, the methods are filled in as NULL.</p>
<p>{{{#!cplusplus</p>
<p>void animal_initialize(Animal *self, char const *name)<br />
{<br />
    memset(self, sizeof *self, 0);<br />
    self->vt = animal_interface;<br />
    self->name = name;<br />
}</p>
<p>Animal *animal_new(char const *name)<br />
{<br />
    Animal *self = malloc(sizeof *self);<br />
    animal_initialize(self, name);<br />
    return self;<br />
}</p>
<p>void animal_del(Animal *self)<br />
{<br />
    free(self);<br />
}<br />
}}}</p>
<p>We defined a constructor, and a destructor. The constructor can have parameters, and we have a version of it which will not allocate, but just initialize.</p>
<p>{{{#!cplusplus</p>
<p>#define BIRD(_base_) ((Bird *)_base_)</p>
<p>void bird_eat(Animal *super, char const *what, int howmuch)<br />
{<br />
    Bird *self = BIRD(super);<br />
    super->hungry -= howmuch * get_nutrition(what);<br />
}</p>
<p>int bird_go(Animal *super, int direction, int howfar)<br />
{<br />
    Bird *self = BIRD(super);<br />
    if (collision()) return 0;</p>
<p>    super->x += cos(direction) * howfar;<br />
    super->y += sin(direction) * howfar;<br />
    super->hungry += howfar;</p>
<p>    return 1;<br />
}</p>
<p>int bird_fly(Bird *self, int howfar)<br />
{<br />
   if (collision()) return 0;<br />
   self->z += howfar;<br />
   return 1;<br />
}</p>
<p>void bird_initialize(Animal *super, char const *name)<br />
{<br />
    animal_initialize(super, name);<br />
    super->vt = bird_interface;<br />
    Bird *self = BIRD(super);<br />
    self->z = 0;<br />
}</p>
<p>Animal *bird_new(char const *name)<br />
{<br />
    Bird *self = calloc(1, sizeof *self);<br />
    bird_initialize(&#038;self->super, name);<br />
    return &#038;self->super;<br />
}</p>
<p>void bird_del(Animal *self)<br />
{<br />
    animal_del(self);<br />
}</p>
<p>AnimalInterface *bird_interface;<br />
void bird_init(void)<br />
{<br />
    bird_interface = calloc(1, sizeof *bird_interface);<br />
    bird_interface->eat = bird_eat;<br />
    bird_interface->go = bird_go;<br />
}<br />
}}}</p>
<p>Here, we actually define the methods of the Bird object. The last function is the module init function again, which creates an interface, and this time, with both methods filled in.</p>
<p>We also have a constructor, again with a separate intialization function, and a destructor. The instance of the object always is passed as the type of the base object, Animal, and we use a macro BIRD if we need to access it as the derived object.</p>
<p>If you remember the initial example:<br />
{{{#!cplusplus<br />
Bird *bird = bird_new(&#8221;Sparrow&#8221;);<br />
animal_eat(bird, &#8220;Apple&#8221;, 1);<br />
animal_go(bird, 0, 1);<br />
bird_del(bird);<br />
}}}</p>
<p>Then this could of course be written as:<br />
{{{#!cplusplus<br />
Bird *bird = bird_new(&#8221;Sparrow&#8221;);<br />
bird_eat(bird, &#8220;Apple&#8221;, 1);<br />
bird_go(bird, 0, 1);<br />
bird_del(bird);<br />
}}}</p>
<p>And then maybe also:</p>
<p>{{{#!cplusplus<br />
bird_fly(bird, 1);<br />
}}}</p>
<p>But, the advantage of the former simply is that we might now know what types of animal it is, like, assume, this is a game involving 100 different animals, who can eat things and go around. Then our main program can be written without needing to know the type of the current animal.</p>
<p>There are also various possible variations, e.g. instead of the &#8220;super/self&#8221; and so on parameters we could have used &#8220;super/sub&#8221; or &#8220;animal/bird&#8221;. It is also possible to have deeper sub classing, e.g. a class Sparrow derived from Bird. And object may be created in a different way than the constructor function, for example there could be a mapping of strings to classes, then a function &#8220;Animal *animal_create(char const *name) could create the appropriate one. Classes who don&#8217;t need any own variables don&#8217;t actually need their own struct, but just a new vtable.</p>
]]></content:encoded>
			<wfw:commentRss>http://allefant.com/objectorientedc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LudumDare</title>
		<link>http://allefant.com/ludumdare/</link>
		<comments>http://allefant.com/ludumdare/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://allefant.sourceforge.net/wordpress/?page_id=17</guid>
		<description><![CDATA[LudumDare is a competition similar to SpeedHack, see the links:
 * http://ludumdare.com
 * http://www.freelunchdesign.com/cgi-bin/codwiki.pl?LudumDare
]]></description>
			<content:encoded><![CDATA[<p>LudumDare is a competition similar to <i>SpeedHack</i>, see the links:</p>
<p> * http://ludumdare.com<br />
 * http://www.freelunchdesign.com/cgi-bin/codwiki.pl?LudumDare</p>
]]></content:encoded>
			<wfw:commentRss>http://allefant.com/ludumdare/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Land</title>
		<link>http://allefant.com/land/</link>
		<comments>http://allefant.com/land/#comments</comments>
		<pubDate>Sat, 01 Jan 2000 07:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://allefant.sourceforge.net/wordpress/?page_id=23</guid>
		<description><![CDATA[<div class="postavatar"><img src="http://allefant.sourceforge.net/wp_/../pics/land/logo.png"  alt="land" border="0" /></div>

Progress
/!\ Broken  Needs work (./) Useable {*} Finished
{1} Immediate priority {2} Normal priority {3} Low priority &#62;:&#62; problematic
&#124;&#124; State/Priority &#124;&#124; Module &#124;&#124; Notes &#124;&#124;
&#124;&#124;&#60;=&#62; (./)  &#124;&#124; [:Land/Base:Base] &#124;&#124; &#124;&#124;
&#124;&#124;&#60;=&#62; (./)  &#124;&#124; [:Land/Widgets:Widgets] &#124;&#124; &#124;&#124;
&#124;&#124; {*} &#124;&#124; base widgets &#124;&#124; &#124;&#124;
&#124;&#124; {*} &#124;&#124; reference counting &#124;&#124; &#124;&#124;
&#124;&#124; {*} &#124;&#124; properties &#124;&#124; &#124;&#124;
&#124;&#124; (./) [...]]]></description>
			<content:encoded><![CDATA[<div class="postavatar"><img src="http://allefant.sourceforge.net/wp_/../pics/land/logo.png"  alt="land" border="0" /></div>
<p><img src="/pics/land/logo.png" /></p>
<h1>Progress</h1>
<p>/!\ Broken <!----> Needs work (./) Useable {*} Finished</p>
<p>{1} Immediate priority {2} Normal priority {3} Low priority &gt;:&gt; problematic</p>
<p>|| State/Priority || Module || Notes ||<br />
||&lt;=&gt; (./)  || [:Land/Base:Base] || ||<br />
||&lt;=&gt; (./)  || [:Land/Widgets:Widgets] || ||<br />
|| {*} || base widgets || ||<br />
|| {*} || reference counting || ||<br />
|| {*} || properties || ||<br />
|| (./)  || menus || ||<br />
|| (./)  || lists || ||<br />
|| (./)  || scrolling || ||<br />
|| (./)  || sliders || ||<br />
|| (./)  || buttons || ||<br />
|| (./)  || text || ||<br />
|| /!\  || edit || ||<br />
|| /!\  || options || ||<br />
|| /!\  || checkboxes || ||<br />
||&lt;=&gt; (./) || Themeing || ||<br />
|| (./)  || Borders|| ||<br />
||&lt;=&gt; <!----> || Fonts / Text output|| ||<br />
|| (./) || Truetype|| ||<br />
|| (./) || Bitmapped|| ||<br />
|| /!\ || Glyph pair kerning || ||<br />
||&lt;=&gt; (./) || Display || ||<br />
|| (./) || Drawing primitives|| ||<br />
|| (./) || OpenGL integration || ||<br />
|| (./) || Destination clipping|| ||<br />
|| /!\ || Palette support|| ||<br />
|| /!\ || Non- 32bit support || Currently, some places just assume 32-bit RGBA textures ||<br />
|| (./) || Views || ||<br />
||&lt;=&gt; (./) || [:Land/Images:Images] || ||<br />
|| (./) || Loading|| ||<br />
|| (./) || Source clipping|| ||<br />
|| <!----> || Drawing into images|| ||<br />
||&lt;=&gt; (./) || Tile engine || ||<br />
|| {*} || Rectangular grid || ||<br />
|| {*} || Isometric grid || ||<br />
|| (./) || Hexagon grid || ||<br />
||&lt;=&gt; (./) {1} || Sprites || ||<br />
|| /!\ ||  Bounding box collision || ||<br />
|| (./) ||  Grid hash ||  ||<br />
|| /!\ || Quadtree || Saves memory for sparse maps ||<br />
|| (./) ||  Pixel perfect ||  ||<br />
||&lt;=&gt; (./) || Containers || ||<br />
|| (./) ||  Dynamic arrays || ||<br />
|| (./) ||  Linked lists || ||<br />
|| (./) ||  Hash maps || ||<br />
|| (./) ||  Queues || ||<br />
||&lt;=&gt; <!----> || [:Land/Documentation:Documentation] || ||<br />
|| (./) || Source format.|| Python docstrings ||<br />
||&lt;=&gt; (./) || Input || ||<br />
|| (./) || Keyboard || ||<br />
|| (./) || Mouse || ||<br />
|| /!\ || Joystick || ||<br />
||&lt;=&gt; (./) || Sound || ||<br />
|| (./) || Mix single samples || ||<br />
|| /!\ || Stream wave data || ||<br />
||&lt;=&gt; (./) || Network || ||<br />
|| (./) || Send packets || ||<br />
|| <!----> || Automatic connection handling || ||<br />
||&lt;=&gt; (./) || File formats || ||<br />
|| {*} || png || ||<br />
|| {*} || jpg || ||<br />
|| {*} || gif || ||<br />
|| {*} || bmp/tga/pcx || ||<br />
|| {*} || mpg || ||<br />
|| {*} || ogg || ||<br />
|| {*} || ttf || ||<br />
|| {*} || it/xm/s3m || ||<br />
|| <!----> || mid || ||</p>
]]></content:encoded>
			<wfw:commentRss>http://allefant.com/land/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Templates</title>
		<link>http://allefant.com/templates/</link>
		<comments>http://allefant.com/templates/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://allefant.sourceforge.net/wordpress/?page_id=29</guid>
		<description><![CDATA[One feature of C++ are templates. Most notable is the STL, but templates also have many other uses. In fact, they are nothing more than better macros. Anything you can do with templates in C++, you also could manage in plain C, using those ugly #define or #include tricks. You write code once, but some [...]]]></description>
			<content:encoded><![CDATA[<p>One feature of C++ are templates. Most notable is the STL, but templates also have many other uses. In fact, they are nothing more than better macros. Anything you can do with templates in C++, you also could manage in plain C, using those ugly #define or #include tricks. You write code once, but some details of it, like certain data types or operations, can be replaced. The code is just a template, and each actual instantiation of the code will then have different things filled in.</p>
<p>This has a big advantage: You only need to write the code once, so if something changes, then you do not have to adjust multiple versions, with the big risk of doing it wrong in one or forgetting one. Of course, the same could also be done without templates or macros, by using some runtime mechanisms to choose the right version, but that involves conditionals or lookups, and will be much slower. With templates or macros, the compiler will be able to run all of its optimizations &#8221;after&#8221; the code was instantiated. So in the end, there indeed will be multiple versions, but you as programmer only have to maintain one.</p>
<p>Still, the solution is flawed. In C, writing &#8216;macroed&#8217; code is not nice, you probably will end up with lots of \ characters after each line, put stuff into #include files, and generally your algorithm will be much harder to read than the specialized version. Often it will be easier to e.g. maintain three separate functions stuck together in some file than having a single function using macros for the three different possibilities.</p>
<p>The same, unfortunately, is true for C++. No doubt, for many things, it usually is nicer to have a templated C++ version than using C macros. But it still makes the code more unreadable than using a fixed version.</p>
<p>This is what I solve with my approach. The idea is simply to use a meta language. So sort of a very powerful #define. I simply write my algorithm in Python, writing out the C code for the compiler to use. That way, I can do it in a way like with #defines or templates, but in many case, can do much better. That&#8217;s the main idea behind <i>scramble</i>. Keep the simplicity of C, and get all the more powerful features by having the whole Python interpreter as preprocessor.</p>
]]></content:encoded>
			<wfw:commentRss>http://allefant.com/templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TODO</title>
		<link>http://allefant.com/todo/</link>
		<comments>http://allefant.com/todo/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://allefant.sourceforge.net/wordpress/?page_id=30</guid>
		<description><![CDATA[infinite.. all the projects i&#8217;m contributing to.. all the games i started.. all the things i wanted to try out.. oh, and also all the other things i&#8217;m supposed to do.. can&#8217;t really even start to make an actual list, without cutting off stuff that is really important to me and therefore cutting off the [...]]]></description>
			<content:encoded><![CDATA[<p>infinite.. all the projects i&#8217;m contributing to.. all the games i started.. all the things i wanted to try out.. oh, and also all the other things i&#8217;m supposed to do.. can&#8217;t really even start to make an actual list, without cutting off stuff that is really important to me and therefore cutting off the list would defeat the purpose of the list. What a dilemma.</p>
]]></content:encoded>
			<wfw:commentRss>http://allefant.com/todo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
