Tuesday, April 19, 2005

Programming languages

I enjoy programming. My brother taught me BASIC when I was 8 years old, and I've been finding ways to make the computer do what I want ever since. And I've always been looking for a better language; one in which complex ideas and plans can be expressed simply and which provides the best transport between thoughts and bytes.

I've been using Python more than anything else for quite a while now, and it's been difficult to pin down exactly what it is about Python that I like so much. I think a big part of it is the "batteries included" philosophy: there is a very powerful and comprehensive standard library present for every Python installation, so programs are easy to move around, and I know exactly where to look for tools and the documentation on those tools, and I know the documentation is going to be good. It's helped me learn Python much faster than any other language, and get to know more of the details that let me make best use of the language.

I'm big on Python's DuckTyping too. Python makes working with objects and classes easy.

Still, there are things missing from Python. I've messed around with various Lisp dialects over the years, and really enjoyed the constructs like lambdas and macros, and the way everything returns a value (even useful values, much of the time). Python has a distinction between statements and expressions that seems fairly artificial to me. That rigidity sometimes blocks me from writing my programs in the way I want them to be. Python lambdas, for example, can only contain expressions, due apparently to syntax constraints; and there are formatting and whitespace issues that are forced on to the code. The lack of macros grates sometimes. And Python's constructs (like assignment, and function definitions, and loops) can't return values, necessitating a few more steps in code than might otherwise be necessary. Now, I fully agree that most of the time, these issues encourage better and more readable code. But not all the time. I'd like a little extra freedom in some cases.

There are still a lot of languages out there to try. OCaml and Haskell probably stand out as the next ones I need to learn. But I'm just a bit too attached to Python's standard library and clean extension API and a bunch of other things, that I was motivated to try putting a lispish syntax on top of Python.

I looked at Logix, and I tried really hard to like it, but it felt too clumsy. It apparently translates Logix code to valid Python underneath, so it has to go some extra lengths to avoid the same shortcomings as Python.

So I've written my own language, that I call Noodle, which has a lispish syntax and compiles to Python bytecode. Its lambdas are not restricted, and it has macros, and things like function definitions return values. What's more, it still makes attribute usage and access simple--something I haven't seen any lisp dialect do.

It's coming along very well. It's almost to the point where I can make the first public release. I still need to implement defmacro, allow Noodle modules to be imported as well as .py files, and clean up a few other odds and ends.

I will probably want to get a decent start on the documentation too, before releasing. Or maybe not; maybe I can point interested users to the current test suite and let them look up syntax from there. Then maybe others can help with the documentation before the next release.

0 comments: