Marius Gheorghe

Building software : make it work, make it good, make it fast

LISP, DSLs and C#

  Read this . It’s about LISP, lists, tree processing and DSLs. It’s about what makes LISP a great language. Invariably any programmer ends up having to write a DSL for a specific problem. This is one of the greatest strengths of a programming language and LISP really shines here.

  So how is that related to C#? Is way harder to do this in C#. Like in any static typed language you end up fighting the type system instead of solving the problem at hand.  Think about reflection, for instance. It’s a lot of code to type there ….C# 3.0 might help a little bit but, unfortunately, it will not make a big difference. We need a “dynamic C#”, we need “eval”, we need metaprogramming capabilities, we need a way to get (temporary) out of the shackles of strong typing.  Also we need a tree implementation in the BCL collections.

Case at point…..Karmencita. An embedded SQL language used to query in memory data. It’s a DSL build upon a dynamic model. It’s fast, terse and easy to use. When i started working at Karmencita i build at first a static typed model (after implementing the DataBlock OQL language). Didn’t liked too much….it was A LOT of code to type and for what ? Just to “satisfy” a parser to whom you can’t even specify the DSL rules ? Hence the dynamic model.

The Practical Common Lisp book is freely available online if you’re interested.


Now playing: George Enescu - Romanian rhapsody


Static typing for a internal DSL ?

      While working at Karmencita i had a “static typing vs. dynamic” discussion with a friend of mine.  Of course, the guy insisted that the dynamic DSL is useless unless there was a way to “type check” it . I disagreed , of course, but nonetheless i was interested in doing this in C#. Unfortunately, there isn’t any way to do it. I was thinking at something like a C# compiler plugin… that at compile time i would have access to the AST and type check the DSL.

    Unfortunately is not possible to do this in C# now. Maybe someday…..


Now playing: Elvenking - Hobs And Feathers