Invent a programming language

The programming language I'm working on is called Lemur, named after the curious species from Madagascar. Hopefully the language takes after this little animal's agility and spunk.

Lemur's ancestors are C/C++, Perl, ASP, PHP and the Unix shell: It inherits much of its syntax and its compiled nature from C and C++, and is object oriented. It is perhaps most like Perl in that it adopts the "do what I mean" philosophy, where as most languages behave in more of "do what I say" manor. Also like Perl, arrays are dynamic (by default anyway), associative arrays are built in, and native support for regular expressions is available via the =~ operator. Lemur adopts ASP's/PHP's method for generating web content: The <% %> sytnax. Last but not least, it is designed with the spirit of the Unix shell in mind, which means that it tries to make dealing with files, directories, and interfacing with external commands as easy as possible.

Lemur isn't simply a blend of existing languages; it brings many new things to the table. It introduces some powerful, SQL-like constructs for dealing with arrays and sets of data, such as the where clause. It also introduces some very useful sub languages for doing things such as parsing command line arguments.

Here's an example program that reads a file and prints it to the screen:

print [/tmp/demo.txt]

Here's an example program that downloads a website and saves it to disk:

[/tmp/demo.txt] = [http://www.danielbigham.ca/]

Here's an example program that is a simple implentation of the grep command:

[usage: pattern file]

for each line in [[arg:file]]

    if line =~ /$[arg:pattern]/
        println line
        next
    end

end

The first line uses the [usage: ] directive to define the program's usage. This is all that is required to parse the program's command line arguments.

The 'for each' line does quite a bit: [arg:file] returns the name of the file that was specified as one of the command line arguments, and the fact that it is surrounded by another set of square brackets causes Lemur to read the file from the disk. Because 'for each' is looking for an array to iterate over, Lemur takes the hint and splits the contents of the file into lines so that the 'for each' block is executed once for each line.

Finally, a Perl-like way of checking against a regular expression is used.

I'm still very early in the design process, but so far it has been very enjoyable. I'll need to take the compiler course at Waterloo and then start planning the compiler.

For an introduction to Lemur, see this document, which is still very much a work in progress.

June 12, 2007: Advanced Programming Language Design

I ordered and received this week a book entitled Advanced Programming Language Design by Raphael Finkel that looks quite interesting. It should be good preparation for thinking about what will be involved in compiling my language, as well as good prep for the compiler course at Waterloo.

Ideally I would be able to do a self-paced / part time masters program at Waterloo so that the design and implementation of the language would be the focus of my study, but who knows. I should probably talk with a prof and see what they think. So many possibilities!

June 1, 2007: It's gotta be fast

While I'm still just starting to learn Ruby, the reading I've done online suggests that it's quite a slow language.

This reminds me that speed of execution is a very high priority for Lemur. If it's slow, I won't be happy with the result. Ideally it should be about as fast as C, but I know I'll be forced to make trade-offs between making life easy for the programming VS fast execution times.

May 26, 2007: Encouragement from Ruby

This summer and fall I will be learning Ruby (and Ruby on Rails). I've picked up a couple of books, one of which is Programming Ruby by Dave Thomas. The forward to the first edition was really neat to read, because in it, Yukihiro Matsumoto, the inventor of the Ruby langauge, says some things that I've said in my head several times!

Man is driven to create; I know I really love to create things. And while I'm not good at painting, drawing, or music, I can write software.

Shortly after I was introduced to computers, I became interested in programming languages. I believed that an ideal programming language must be attainable, and I wanted to be the designer of it. Later, after gaining some experience, I realized that this kind of ideal, all-purpose language might be more difficult than I had thought. But I was still hoping to design a language that would work for most of the jobs I did everyday. That was my dream as a student.


That second paragraph describes me to a T. But I also like his statement about man being driven to create -- what a strange thing, this burning desire we have to use our hands and intelligence to make something new.