Why my favourite Language is .NET

31 05 2006

I quite like Microsoft's .NET initiative. And not simply because it further abstracts one from the hardware and ensures any application you write will work on all hardware, all OS's, which have the framework implemented. No, that is only a small bonus. The real great aspect of .NET is its Common Language Specification and the perfect interoperatability between all languages which meet the CLS – are .NET compliant. The fact that all languages compile/produce IL files that are basically the same, regardless of language of choice makes the case much stronger. This freedom, this flexibility, this ability to use what language fits your needs and mix and match strengths and counter weaknesses from this and that language is what I feel is .NET's greatest attribute.

For example, I am using C#, F# and IronPython for my project. Each for a specific reason. C# is what the core engine is in, the language is quite clean..at least when compared to C++. It arguably generates the fastest code of all the .NET languages and is the main Microsoft language, it would seem. I use IronPython to script the application, this is because python is a far more flexible language than C# and is more intuitive. It is also simple but in a manner which allows complex behaviour – using this as a script will allow things to be done that would not have been easy any other way. F# is used to code certain things that would not make sense in anything but a functional language. This functionality is exported as assemblies to be used by the C# app. Specifically, a simple implementation of Metamath to allow for exploration of meta-mathematical concepts in a pretty visual and innocent setting. Takes in scripts as well. A modal logic interface will be built on top of this and will control the behaviour of certain aspects to do with planes and magic etc. Again, I am wrapping some pure maths in the guise of a game. I hope. hehe. Nonetheless this freedom, the ability to not be restricted to any one language is in my mind the greatest offering of .NET. Just take a look at the number of languages available for the platform which can be made to operate with each other with little to no effort.

Why there can be no One Perfect Language

All programming language, all computers, computers running programs by a certain language are all essentially formal systems. This feature allows us to discuss things and apply things and proofs from logic on the capabilities of languages.

Formal System

In the most basic sense, a formal system is a system of logic that allows us to "reason" mechanically. A formal system is composed of:

  • an alphabet: symbols which compose its language e.g. {P,q, – }
  • a syntax which describes how to form a proper expression in the system. Formally called well formed formulae
  • A formal language, valid strings formed with our alphabet
  • Rules of inference – series of operations we perform on our sentences (strings of symbols from our alphabet e.g. pq–p) that end in something which is true in our system
  • and some starting wffs or Axioms.

A theorem in our system is a list of sentences with the first being an axiom or a proven wff (theorem) and every sentence within being a result of transformations which follow our rules – the last sentence in our string is a theorem.

Formal Language

A formal language is in the most basic sense a set of strings over some alphabet or rather, a proper subset of the set of all possible strings that may be composed with some alphabet, with an alphabet being no more than a set of symbols. Formal languages are devoid of ambiguities common to natural languages as English or Chinese (in fact there is no inherent meaning to the set of string or sentences formed in them), they are mechanically manipulable. That is, a computer can follow instructions formed in them. They were originally developed with formal logics and the wish to make math completely mechanized and in essence, air tight. All programming languages contain formal languages. In fact the term programming language is a misnomer since most programming languages are more than just languages. They are entire systems, indeed the term computer programming system would be more appropriate than computer programming language. This argument for this will be given informally later.

Should have known that no machine could replace a pup named Scooby Doo

Computers can be represented as formal systems, programming languages can be said to generate or represent rules of inferences which control the computer's state. This state may be considered sentences in the computer formal system with the act of following wffs represented by computer code transforming sentences to generate a theorem in the machine’s formal system. Indeed an operating computers actions is analogous to proving theorems in its formal system. Programming languages and computers in principle contain "within" the entirety of current mathematics. Converesly, they are tightly bound by the limits on formal systems based on their very nature.

Can the brain be considered a formal system? There are those who argue using Godel's Incompleteness Theories and similar mechanisms (Lucas , Penrose) that the brain is more than a computing machine. Indeed, no finite machine could ever hope to replicate human brains since for one, such a machine would have unprovable propositions contained within that the human brain it was supposed to emulate could. For another it is almost certain (since nothing can be certain) that the human engages in activity in the mathematic endeavour that is not limited to computable functions. Interestingly, if this is true then the Church Turing thesis – any evaluatable function can be computed by an algorithm on some computer is wrong, since we would have an example of a set of "mechanical operations" or more appropriately an algorithim that other machines could not compute. Conversely, if you feel the Church Turing thesis must be true and that the human brain can be represented by a [finite] computing machine then it is necessary that you accept the corollary (assuming consistency) that the human brain can never understand itself, there will be lines of "thought" that it simply will never be able to get to. Nonetheless such arguments for and against the human brain as a machine assume the consistency of the humans brain logical operation (note the use of consistency) and that a list of axioms may be attachable to it. The truth or untruth of this is an issue of debate, one which will not be gotten into in this post, although I do think the human brain to be more than a computing machine.

Why there can be no Perfect Language

One can show that Gödel’s theorems apply to computer languages and thus that no computer languages can ever show itself to be consistent nor are they complete in the sense that every statement in their system is decidable. Gödel’s theorems apply only to formal systems which have axioms that are fairly strong and interesting, in order words they can *encode* some representation of the natural numbers {1, 2, 3, 4, 5, …}. Every computer language that is Turing complete can do any anything that a Turing machine can do. Turing machines can arguably evaluate any computable function as can the lambda calculus (although as mentioned earlier, this statement is untrue if you like me, believe that the human brain is more than a mere computer), an equivalent but different formalism, The natural numbers are definable with the lambda calculus. Thus any Turing complete computer language is powerful enough to define the naturals.

As stated before, programming languages are actually formal systems with wffs (the syntax), alphabet, vocabulary and rules of inferences with the computer state actually being the sentences and the “computer code” being the transformations on the previous list of theorems and axioms (previous computer state) of the formal system. The computer code represents some range of the valid behaviour or transformations of our system. Thus every language coupled with the computer represents a different formal system. Godel’s second incompleteness theorem does not concern us. But the first one is of great relevance. It guarantees that our system will be incomplete and will never be complete. Every new axiom will add, every new feature or behaviour will always allow another new undecidable behaviour to crop up. In programming terms this boils down into the fact that every language will have unreachable portions, states, behaviour. That is there will be things that the computer language will never be able to do. No one language will ever be made capable of doing "everything" at least not while remaining consistent and not convoluted. There will be behaviour that our computer may be able to evince but our language will not allow us to invoke.

This is basically a very elaborate argument for the fact that no programming language can have or will ever have everything and be perfect. As such the .NET and its CLS are the perfect solution around this limitation and the closest one can ever get to a perfect language.

Emergent Story Telling

24 05 2006

As I stated the goal of this project is as a vehicle to explore certain philosophical , mathematical and particular emergent processes. A core guiding principle of this project is to capitalize on something found in nature: simple and flexible systems evince the most complex behaviours. Each feature implemented will be based on a set of relatively simple but flexible axioms whose end behaviour I will have no hope to guess on. The philisophical and mathematical aspects will be discussed in a later entry but here I will drop a little bit on the goal of creating a player experience that might evolve a complex story.

As I stated earlier the project will be implemented on an episodic bases with each new episode merging seamlessly (hopefully) and being able to communicate with previous ones. Within each module will be a set of experiences all following some underlying theme. Each experience may be invoked by any combination of encounters, conversations and puzzle solving. In essence the entire game, regardless of module count will be a set of loosely related self-contained experiences which export data on how the player chose to work through them. There are no correct paths. Each experience will also be a set of loosely coupled events – there is no correct way to unravel them and only a few simple rules will direct what and what is not possible. <— Very vague idea of how that will be implemented. But this project will have a lifespan of many years. The emphasis is in plugging in.

Earlier this year I tried to prove something about stories by relating them to geometry, i say stuff about behaviours of sets in 2^A, where A is a set composed of some alphabet. A theorem was: All stories are homorphic and there exist only a small finite number of unique stories. The proof goes on by borrowing a bunch from formal languages, i never completed it. Nonetheless I shall return to it and even unsuccesful will have some techniques that I may apply in this project.

First, know that there is no story in this game. None. Instead the player's experience will be the story. The basic idea is that of implementing a sort of logging system similar to journals in traditional RPGs with the ability to export the set of experiences. Within each module will be weighted keypoints, encounters and enemies whose entering will cause the system to attempt to generate a summary of how the player undertook the experience. There will be an attempt to keep some sort of chronological links and relating summaries across expreiences and even modules. As well, a table of the directions the player's outlook,results and reactions will be tallied across the entire play. In addition, some of these summaries may be told by books to be found in the world. A rumour passing/evolving (with constraints) system will be attempted across the world, with basic attributes of Generic non important characters (only they tell rumours ) affecting the telling. We'll see how things go when I try to prove, design and implement aspects of this system.

The Tangled Web of Existence

20 05 2006

I read somewhere that blogs allow people to think aloud and to think loudly. Begin.

I am a philosopher, one studying math but only because there is no better tool, no better way to exercise the mind than to partake in mathematics. Of course there are many who would state that musing on philosophy is a waste of time. But truly, since on the most objective scale, nothing we do on this world has meaning [without us], has no impact on the rest of the universe that is not us (which is basically to say we have no impact whatsoever), and all that we do may as well not have been since we die and it as if we never were within decades, what I ask, is a waste of time? And for those few who are remembered what good does it do the dead to remember them? Perhaps in forward thought it is good to think that you will be remembered but again, what good is that to you dead? There is an answer to this and I will give it later, in another entry.

The point of philosophy is to ask why? And to try to answer this "why" as objectively as possible by using purely subjective analogies. This is the best that may be done. This is the human, the finite minded sentient condition. All other endeavors – even physics – they do not ask why. Physics says this is how it is but it does not tell why, is this predilection for ignoring why, going about as if it is not a question worthy of pursuit,is it some sort of defense mechanism for those who would rather not ponder the pointlessness of all they do? I would rebut the last with this that is the core of this series of essays: "To each his own". Such lines of thought may ultimately lead nowhere, but then what does? Leads somewhere, that is. Again, what is time not wasted? I will note though, I feel not but scorn for those who would feel superior to others because their job requires more "skill". Pfeh. If it is not evident, I have strong tendencies towards relativism but I am *not* a relativist.

(a) Why does the universe exist? More importantly without someone self aware to perceive it would the universe exist? I am not thinking about quantum mechanics because that one does say yes to my second question. No I mean, without someone self aware to perceive it would the universe exist? Of course you could say, yes, the universe does not need to be perceived to exist – stuff still goes on and has gone on without us. But then, the notion of existence is not possible without perception, it is an invention of the ability to consciously perceive. That we are here now is required for us to be able to say but of course it existed in the past. Where "we" is the set of all beings in the universe who may perceive. "Meaning" is a sentient invention, without us there is no meaning. Certainly there is some inherent structure with a pattern that we may observe and say, yes "this is", but again, it is required that "we" exist to make this observation. If there was no one to ever observe the universe, what point would there be? Can you see what I am driving at? There may be aliens, even if we do not see them that we acknowledge that they may exist is sufficient that they exist. So, it is true that aliens exist (see modal logic, the philosophical part of my RPG is tied to this). But those who make this observation must themselves exist to make this observation. If no one did, if no one could, would anything exist? This question makes me cry. But I feel that the answer *should* be Yes. Things had to exist before us before we got here. But I feel that they had no meaning, meaning is subjective. We bring our own meaning to the universe. Without us (the set of all self aware) the universe might as well not exist. Because it would be meaningless, essentially, pointless. Do you disagree? If yes, please state, it would mean so much to me.

(b) It is often remarked that humans and similar exist because the universe would not go about the business of creating itself if there was no one to admire it. Is that the purpose to our existence? Is that why we exist? I leave that as un-answerable, and un-addressable. It may be or it may not be. This question may as well not have been asked, it may as well not exist. There is not sufficient data to even speculate on this possibility.

(c) It is more acceptable to think that we were created by random non-directed purposes and that our existence is explainable as being a result as such. But if you agree with me then you accept (a) and thus feel that we bring our meaning to the universe. With (a) in mind one cannot help but consider (b) which immediately leads to (c) which must be considered with (a). Nonetheless (a) does not imply (b). We could very well have been a result of random processes and it is only a coincidence that we validated the universe's existence. What a happy thing.

Whatever you believe, its Objective truthiness will never be known. But hopefully, your conclusion is a happy one. Me, I see that we have no impact on the universe, we may as well not exist but then again, we add our own take of meaning to it. And if we are the only life in the universe, we give the universe its meaning. This is for me, a good ending.


18 05 2006

A week or two ago I was prancing about the internet where I found to my combined dismay and delight (5% , 95%) , the awesome Croquet Project. The goal of the croquet project is similar to mine – a platform to drive education in a direction that realizes that technology exists and also have this platform be very modifiable and extensible.

Ofcourse they take their vision many, many magnitudes further than mine although they also make many directional twists that make the project quite different (like the difference between word and Windows XP). I have not seen or heard it mentioned ever, which to me is a great suprise considering how awesome the project is. Croquet is the dream child of Alan Kay, the guy from the legendary Palo Alto Xerox team that invented modern computing hehe. He helped originate object oriented design, modern GUIs – he's also the guy behind the $100 hand powered laptop.

The Croquet Project

Have you heard of Second Life? Well the Croquet Project is nothing like it. Well they are similar, the way a wagon is similar to a jet. But have that basic concept of people coming together and doing stuff together in mind. The croquet project is an open source program – an OS in time, if the project successful – that allows for the collabaration and sharing of ideas, virtually, in real time. Yes it is MO, massively online. But, it is the utlimate manifestation of distributed networking in that it uses a concept similar to P2P with the possibility of applications sharing the resources of the entire globally connected community. There is no central server. The technology is called Teatime. It will feature both replication of computation and data across the distributed network – it is being worked on by the guy whose worked originated the TCP/IP model.

People log on to the world and the emphasis is in the users modifing the world. Adding their own worlds or creating content in preexisting worlds. There exists spaces which maybe public or private and allow access into each other. The spaces are not limited to anything – you could easily create your MMORPG world in there and have people visiting from their spaces/worlds within weeks…. Modyfying a scene is reflected instantly across the world [among those acessing]. Experimentation and the hope of teaching physical laws through fun systems is there. Holding virtual conferences and lectures, this capability is there.

The program is written in squeak – a smalltalk variant. This language squeak is object oriented and has incredible meta capabilites. Not only can it modify itself, it can as well modify the virtual machine or compiler. In fact the program croquet, allows the user to modify its code in runtime and reflects these changes in realtime with no need for recompilation. The virtual machine is written in Slang, a smalltalk functional paradigm implementation. Go read about it. Tis awesome.

Images Copyright Viewpoints Research Institute Inc., Duke University, The University of Wisconsin, The University of Minnesota, and others


I do not know squeak nor do I currently have a use for it but I will begin recommending it to those just begining who wish to learn object oriented programming. I am learning it. Not only is this language powerful in that it doesnt require arcane mastery and allows you to get what you want to do with little fuss it is also very clean, uniform and intuitive. Beginners start right away on learning about polymorphism, inherintance, encapsulation, collections and get this – object object communication through messaging. You also get use of data types as dictionaries, lists etc right away. Creating a set class is quite simple and easily done by the beginner – with understanding. The syntax is also quite different from the usual C++, python kinda comes to mind. But it is still quite abit different.

The Tool Trap

12 05 2006

Curses, the mass generator doesnt work too well, its too stupid. Or rather, the distribution is highly gay. Generated objects tend to cluster. It seems the Random class that comes with .NET is a piece of crap. I have a couple of choices, I can implement the Mersenne Twister algorithim, whose psuedo random generation is unparralleled in all areas (save predicatabilty) and is as equidistributed as they get. Or create an editor. The latter is at the moment not an option. Although I plan to create an editor I do not wish to do so till after I have completed one episode because I have no wish to get caught in the Tool Trap.

The Tool Trap

The tool trap is the manifestation of feature creep, greed and having eyes larger than your stomach. It is known that children often overstuff their plates with sweets, cakes and pies beyond what they can eat. Their eyes drink in the goodies and they try to eat as much as they can only to be beset by great stomach pains. This same behavourial pattern carries over to adulthood where those working on projects see this and that cool feature which must be had but only serve to bog the project down and cause it to loose direction.

Attempting implementation of advanced features, even the mere act of listing these features, which are not necessary to the essence of the project is an example of a rapid way to lose sight and control of a project. As the features fail to be implemented one becomes sick to their vision and lose hope and feelings of progress. It is necessary that a tight hold be kept on what is destination and the quickest way to it.

Another method is one of the misunderstanding of originality, creativity and creation. It is necessary that one know what it is they wish to do and have a clear idea of their vision. It is not neccessary to dig a hole if you wish to bake a cake. Nor is it neccessary to grow wheat if you wish to eat bread or frosted flakes. So also must all those who set out to create say to themselves: I must realize that if some kind person has helped to wash all my dishes, then I will not wash them again before I set my dinner on them. It makes more sense to get about the more important task of setting the dinner out. It does no one any good to create from "scratch".

Because truly there is no such thing as original, everything is learned, taken and reworked from somewhere. The human mind is not an original one. It cannot create. The laws of conservation apply even to creativity. Certainly there is a Mapping from the set of all people creating to another Set of all those who have written and taught. Each member of the relation essentially tells who the influences on the set of students are. Certainly it feels good to cut a tree, whittle the wood, carve a handle. Find some ore, a smelter, a forge and make a blade to then attatch to the handle so you can cut some bread with the knife but it is also a massive waste of unnecessary time. Ofcourse if the task was to create a knife then no time was wasted. Except ofcourse if you had cast the forge yourself. Thus it must be that you must know your goals and task and know how to use the tools at your disposal to allow for the most rapid development. Overpride in what must be yours and a severe misunderstanding of what is your original creation does no one any good. The essesence of your creativity is in the shaping of your goal not in the laborious side tasks of the creation of tools which facilitate such.

The final tool trap is where one actually creates more tools than they need. Or make the tools much more fancy than they need be. I fell for this once, building an editor, improving this and that and making it more and more friendly and with more features while the game languished. The tools need not do any more than they must.

To do what you wish you must do no more than you must.


10 05 2006

Alot of people often wonder what language to begin with and most people usually suggest C++ because that's what the big dogs use. And everyone wants to hang with the big dogs. Others suggest "simpler" languages like C#, Python or Java. These language although friendlier are actually not much better for the ultimate beginner.

They are languages to use after bad habits have been learned. Thus I suggest that Every pure beginner start with QuickBasic or Assembly. This may seem strange, listing those two languages in the same sentence but I will show why it is not so.

Armed with the boon of Retrospective Foresight many people say this or that language is bad because it instills bad programming habits. This is not true. By human nature any language that is chosen as first will have bad programming habits as a part of it. This is because creating misconceptions and then reordering them with experience is an essential part of learning.

Misconceptions exist because the schema, the set of knowledge which the person contains on a certain subject (here programmaing) is entirely underdveloped. To function, as the brain is wont to do, certain assumptions and groupings will be made, erronous and not truly correct connections that are only available because the schema for a topic is so devoidly underdeveloped. There is not enough for the brain to work with to create an accurate understanding or picture of it all. This can only be rectified with knowledge and experience.

QuickBasic is a good enviroment to learn "programming thinking" because it is among the most forgiving languages out there and it is limiting in just the right way to forestall the grevious misconceptions that attempting to learn a language as C# first would create. It as well is equipped with everything required to pick up and go with virtually nonexistant fuss. Many high level language constructs – those that a beginner should be exposed to anyway – are there. You can start with graphics right away and there exist a large amount of resources to get you started. This is the path suggested for one who wishes to become a high level techniques programmer. Visual Basic is no good but I suppose Darkbasic might be okay as it follows in the same vein as QuickBasic.

Assembly is suggested as an alternative because of its authoratarian nature, you must be specific and accurate or you will die. In fact programming in assembly is virtually the same as writing a formal proof in an axiomatic system, which any mathematician will tell you, anyone can do without thought (once the basics are understood ofcourse). One is forced to learn the workings of the machine and become close to the machine. There is less room than most languages for the development of grevious misconceptions due to the explicit and tight nature of it all. This is suggested for those who wish to go the low level or engine programmer path. After Quickbasic learning a language like OCaml would be suggested. Some say Haskell is good as well but I know nothing of it.

Disclaimer: The above are only opinion and are not to be taken as fact.

Gameplay and Preoutlook

10 05 2006

So I am making an RPG which is a tool. It is a tool that will help me explore certain concepts.

Firstly would be certain philosphical issues. In this game you will spend alot of time talking and solving puzzles, there is no correct way but a running score will be kept of what path you take. The maker of a module can use this information to their wish.

If you are not into reading and then showing comprehension of such then this would not be such a game for you, there will be a fair bit of reading involved. it has many academic leanings. For example the magic system will actually be a formal system, have its own language (the use of F#) which affect how the spells unfold. The system will be simple with a set of a few rich rules but the most complicated systems are like that.

But that is far in the future. I wish to begin exploring philosophy, where it is possible to argue certain planes into existance and then visit them but before that there are a few basic gameplay elements I wish to lay down.

Gameplay elements

In this game you can start out as powerfully as you wish, an experienced archmage or a simple apprentice it does not matter, the fighting element is not the only way to progress in power. And even then, you can gain power without lifting a hand to allow the defeat of the more powerful creatures if such a need ever arises.

  • You choose your name and background. There are a few pieces you can put together, i.e. the idea is that you can make your history, a lord or not, orphan or with live parents, old or young all these affect gameplay since the module maker can account for these. Hence your race is picked implicitly. But nothing else is chosen.
  • The concept of unlocking powers is key. For example when you are killed you become a ghost. There are several ways to come back to life. Find a priest, convince them to heal you. Force yourself back to life – this will be handled via solving a puzzle, if you read a certain book then you will know how to enter a certain 'shadow plane' and do a quest that lets you auto live when you die. You must convince (using your own intelligence) a certain being to keep your mortality safe to you wish it back (what penalties this incurs can further be reduced as your character gains in power) and finally enter the shadow plane and fine a doorway back to yourself. This will be in the first module. But accessible in any module forward.
  • Apart the first module, you can start from any module you wish.
  • The game will be part based on live skills and character skills. For example, your past determines your strength but your actions determine the ingame intelligence and wisdom.
  • There is no health at first but in the first module there are several way to make your self less vulnerable. You can learn how to alter the probabilities of a certain event occuring in your precense, specifically getting hurt. You can create magical shields that are run down, they drain from your mental reserve. Which when too low causes you to hurt and then die. Alter the chaos and order balance of the weapon swinging you, psychically affect the weilder. All these are unlocked.

I tire of typing.