Thursday, November 29, 2007

My New Programming Language - "Harry".

Being a programmer who has no fear of programming a disaster, I've decided to write my own programming language.

"Madman!" I hear you cry, but no, seriously. And on the face of it, it's not that difficult. On the face of it, it's just a case of reading a text file and turning that into "symbols", which your interpreter/compiler converts into something existing, whether it's Bytecodes or good old machine code.

My language is called "Harry", and is similar to Lisp, since everyone seems to rave about it, and I've been quite impressed with it. However, there are a few (minor) problems with Lisp, which no doubt people will take me to task for. Here's my : it's not standard enough (there seem to be lots of variants), and it's not very practical (in order to do something like graphics or databases, you need to find libraries).

I've written the interpreter in Java for platform-independence. It's still in the development stage, so no download yet. The current problem I've got is functions and the variables contained within. What happens if a function names a variable with the same name as a global variable? And scope is a problem, i.e. "unsetting" the variable once the function has finished, so the global var becomes available. But what if the function calls another function? And recursion? And what about if a parameter to the function has the same name as a variable?

Anyway, to whet your appetite, here's an example of the code (which should be self-explanatory):

; Add, eq, print
(print (eq 2 (+ 1 1))) ; returns 1

; Set
(set lst (quote 1 2 3))

;quote, contains, if, return
(print (if (contains 2 lst)(ret true)(ret false))) ; prints "True";

Monday, November 19, 2007

Why Are Named Parameters Rare?

One of the things that seems common to most languages, even the supposedly better new ones, is the lack of "named parameters". Surely it must have come to the attention of most language designers that having a line like the following is ridiculous:-

// Do some stuff
int x = MyFunction(true, false, true, true);

Okay, it's probably bad programming practise to have something like this, but even a simpler line with just one boolean would be bad. What on earth does each parameter mean? The only way of finding out is to query the underlying function's code, but that defeats the object of having well named functions. I'm still surprised that having named parameters isn't in most modern languages. How much better is the next line:=

int x = MyFunction(foo:true, bar:false);

Here you can see, without having to browse the underlying function, what each parameter means. Okay, this is nothing earth-shattering that will lead to perfect code, but it has to be a step in the right direction.

Thursday, November 15, 2007

Eclipse and Subversion (Subclipse)

I've blogged before about using Subversion and Eclipse - if you haven't installed Subclipse then don't do it! However, I've discovered another problem and solution to Subclipse...

Even when Subclipse is installed, if you have seperate src and bin directories, the bin directory can confuse Subclipse, since Eclipse likes to effectively delete it and recreate it with each build. The solution to this (apart from adding the bin directory to your ignore list) is to not "Scrub output Folder when cleaning projects".

Wednesday, November 14, 2007

New Game - Chain Reaction

And this time it's original! I knocked it up in Java over about a day (though most of that was trying to work out how to turn "bouncing balls into each other" into something resembling a game).

It's called Chain Reaction. Basically, you have to bounce a certain number of balls into each other. The page (just like all my other applets) keeps track of your scores in a global high-score table, which I think greatly improves the competitiveness. And it's pretty addicitve (and hard) to boot!

Tuesday, November 13, 2007

I Bought a Domain!

I've finally bitten the bullet and bought a domain - My original "default" domain was "", which doesn't really roll off the tongue quite as well, and bears no meaning to the content of the website.

Thursday, November 08, 2007

New Project

It's called Survival (at the moment).

[Added 19/11/07] A few other details since the original post was so sparse: it's written in Java and uses jMonkeyEngine to do the 3D.

Tuesday, November 06, 2007

BBC & Microsoft

(This blog is getting a bit political, I know). What happens when an ex-Microsoft employee starts working for the BBC? They develop a Windows-only iPlayer and claim that only 400-600 Linux users visit the BBC site, before hastily correcting themselves after getting it 16,000% wrong.