Monthly Archives: September 2009

The First Program

Just a bit of fun! No, it doesn’t ‘actually run’. As I wrote it I was thinking about the power of God’s Word, in particular how his very command can cause things to be created, to come to life or to perform any action that he requires. In a way, it is similar to a programmer – one voice of absolute power with the ability to see, create, destroy and command all things. The parallel text can be found at the very beginning of your Bible.

[word@god ~]# cat creation.word
#!/bin/word                                             // 1:1-5
begin creation
public earth = new domain();
earth.content = 1/0 * void();
earth.startCreation('spirit');
var light = new creation();
try    {
  earth.addChild(light);    }
catch {
  throw(E_BAD,'LIGHT FAILURE'); }
earth.light.status = E_GOOD; // all ok
list day('Day','Night') =
     earth.light.filter(dark==false,dark==true);
earth.templates.day = day; // save for future days
earth.today = 1;
earth.days[earth.today++] = byVal earth.templates.day;
//firmament routine                                    // 1:6-8
var f = new creation();
for (var a in earth.waters)
   if (a.index>f.index)
     {
     f.waters.addChild(a);
     earth.waters.removeChild(a);
     }
private heaven = f;
earth.days[earth.today++] = byVal earth.templates.day;
earth.waters.defragment();                             // 1:9-13
var dryland = earth.waters.getFreespace();
var seas = earth.waters.getUtilisation();
try { dryland.generate(E_GRASS,E_HERB,E_FRUIT) }
catch { throw(E_BAD,'LIFE ON EARTH NOT GOOD'); }
dryland.status = E_GOOD;
earth.days[earth.today++] = byVal earth.templates.day;
//lights in heavens, use for signs/seasons/days/years  // 1:14-19
var lights = Array();
lights[0] = new light
   (size = 10,
     attach = earth.templates.day[Day]);
lights[1] = new light
   (size = 2,
     attach = earth.templates.day[Night]);
foreach (lights as l) heaven.addChild(l);
var stars = Array();
for (var a = 0; a < inf; a++) stars[a] = new star();
foreach (stars as s) heaven.addChild(s);
if (earth.checkStatus()) earth.status = E_OK;
else throw(E_BAD,'LIGHTING ERROR');
earth.days[earth.today++] = byVal earth.templates.day;
earth.generate(E_WATERCREATURE, E_FOWL);                          // 1:20-23
earth.setGenerationSpeed(1000);
foreach (earth.creation as x)
  if (x.typeOf == E_FOWL) x.setDomain(earth,heaven);
earth.generate(E_WHALES);
foreach (earth.creation as x)
   x.limitChild.typeOf=x.typeOf; //after their kind
if (earth.creation.checkStatus()) earth.status = E_OK;
else throw(E_BAD,'CREATION ERROR');
foreach (earth.creation as x) x.nice--; //more CPU
earth.days[earth.today++] = byVal earth.templates.day;
var livingcreatures =                                             // 1:24-31
   Array(E_CATTLE, E_BEAST, E_CREEPING);
earth.generate(livingcreatures);
foreach (earth.creation as x)
   x.limitChild.typeOf=x.typeOf; //after their kind
if (earth.creation.checkStatus()) earth.status = E_OK;
else throw(E_BAD,'CREATION ERROR / LIVING THINGS');
//man project
var man = new creation();
man.style = byVal earth.parentNode.style; //cp God
foreach (earth.creation as x)
   if (x.hasLife) x.addController(man.groupId);
man.addVariant(E_FEMALE);
man.addVariant(E_MALE);
man.addFood(livingcreatures,E_GRASS,E_HERB,E_FRUIT);
man.nice--;
earth.creation.addChild(man);
foreach (earth.creation as x)
  if (x.hasLife && (x.typeOf == E_BEAST || x.typeOf == E_CREEP ||
x.typeOf = E_FOWL)) x.addFood(E_HERB);
if (earth.getStatus() && heaven.getStatus()) return (E_VERYGOOD);
else throw(E_BAD,'FAILURE ON DAY 6');
earth.days[earth.today++] = byVal earth.templates.day;
daemonize();
//TODO: rest
//TODO: expose parent API to creation
//TODO: invoke interactive-mode man object (sometime later)
end program
[word@god ~]# date
Mon Jan 01 00:00:00 GMT 0000
[word@god ~]# ./creation.word
Creation started as pid 143. To stop type: kill -9 143
Got status: E_VERYGOOD
Appending output to creation.log
[word@god ~]# _

Hope you found it worth the read! Drop me a comment if you liked it; but please no technical questions on syntax or language!first_programme