Saturday, January 22, 2005

Languages

Things we tried 4 years ago
Enterprise support for dynamic languages
Language oriented programming
Intentional software

If only parsers and compilers were written in a modular fashion. Then we could add anything we like at the abstract syntax tree level and have it compiled and targeted to our favorite binary format regardless of platform and language.

The distinction between logic and code is clear, why are compilers so far behind. This is the whole concept behind the push for intentional programming and domain specific languages. I want to write a search engine, why can't i have my own language for that which compiles into nice fast x86 instructions using GCC, surely its just a transformation ?

But instead i have to spend a lot of time writing good API's so that i can capture the knowledge which would be much better described in a domain specifc language... the domain specific language is what you scrawl on the whiteboard, its what you can describe to a fellow programmer and have them instantly understand what you want to do. And yet its so hard to put that down in syntax, thats because we have to do translation all the time. Surely its better to speak and think in the native language and only do translation when we want the machine to run it...

Theres such a huge gap between expressing an idea and implementing it. But if we break the problem down so that we produce a grammar for description and then a translator for implementation it becomes much easier. We no longer have to worry about bending our minds to describe and implement something at the same time.

I don't think everyone will ever write code as XML, but it makes sense to store the logic in an independent form. Programming should be more like mathematics with metadata. Less focus on the specifics, more focus on the algorithm and the description of intent.

Using a domain specific language is a natural thing for most programmers to do, after all we deal with abstraction every day. The great thing about abstraction is that it separates the problem from the solution and the implementation. We use interfaces to separate purpose from implementation, but we simply don't have the tools to separate language from logic...

What is required is good grammar processing and language description tools which can be combined with extensible editors and compilers. I can't help but think that if programming were more of a science we would have learnt long ago to separate the modelling from the construction.


Update: I noticed Jon Udell has some discussion on this topic, with a link to the same ACM Queue article that we've all read.

Deep structure redux
The deep structure of code