Tuesday, July 1, 2008

Reinventing a programming language

I decided that from today on I will be spending at least one our to develop a simple language. I don't know how to do it but I am willing to learn the basics in a month or so.

Here is what I have decided about the language. The language will be similar to C but a lot smaller. It will have following structures:

  1. Scalar values (1,2,3...) - only integers for now
  2. Variables (a,b,c...) - dynamic variables (Will hold only integers for now)
  3. Addition (+) - addition
  4. Subtraction (-) - subtraction
  5. Functions (function, return) - functions will accept dynamic variables and return any value or a void
  6. Core functions - a print() function and a general way to add core functions
  7. No semicolons

Example:
function calc(a, b) { var c = 5 c = c + a - b return c } var answer = calc(5, 7) print(sum)

I will write the compiler and core functions in Java on JVM, because I'm running Ubuntu at my desktop. There are talks that .NET and CLR is be a better suit for developing a language, but I am afraid that Mono will be too buggy for this.

Wish me luck and post any advices in comments.

No comments: