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";

No comments: