Monday, January 22, 2007

Lucian progress & Guido (working title)

It's been a while since I have blogged about my project but I *have* actually been working on my project quite a bit! I managed to do a good chunk of work over the Christmas break and have really developed the Lucian language so that it properly handles nesting now, and all kinds of primitive operations and variables. I have also, this weekend, added functions (see below for an example of a program that performs a running (2*i + 2*(i+1))*fibonacci[i] using functions in Lucian). The demo also demonstrates two kinds of nesting, where and let in. It also shows how great dataflow is, see the recursive power function in one line :) Whoohoo!

fun power x = 1 fby power*x

fun fib =
g
where
f = 1 fby f + g
g = 1 fby f
end

fun powsWithFib =
let
x = power(2)
y = next power(2)
z = fib()
in
(x+y)*z
end

print powsWithFib()


I also had a little bit of a diversion from my primary objective and started playing with a graphic development for writing Lucian code. I've currently named it "Guido" (a common Italian name throughout the ages) a play on "GUI Do", I'll probably change the name, but that's not important!

I decided that as I was writing the Lucian translator in Haskell and having a lot of fun with Haskell I'd have a crack at writing some kind of graphical tool in Haskell. I chose the wxHaskell extension which uses the wxWidgets packages as it seemed like a well established graphics library that uses the native OS widgets of the target platform. I however had an epic battle when I discovered that the latest wxHaskell, 0.9.4 (released in May 2005), completely fails to compile with the latest wxWidgets 2.8.0 (released in December 2006). So I had a battle taking the wxHaskell 0.9.4 code (written in C++), and writing compatibility hacks and code to work with the latest wxWidgets. If anyone is interested I uploaded my modififed code and wrote a short explanation of how to coax the two to compile together over at my site http://riftor.g615.co.uk/content.php?view=53&type=2.
A reasonably complete list of the changes I made can be found at http://riftor.g615.co.uk/wxhaskell/wxhchanges.txt.



Anyway, once I had all this sorted I spent an afternoon playing with making a little 'flowchart' style functionality tool, examples of how it looks can be seen here:-
Fibonnaci 'code'.



Natural numbers 'code'.




So generally things are going well. I am now working on bringing conditionals into the language, and then I think I will re-write a few bits to make things tidyer and then head into writing Lucian-J the Lucian -> Java translator, then I will formalize the semantics for Lucian and then I should be nearing completion of deliverable 1! :)