Implementing something like DLR in D?

Justin Johansson no at spam.com
Fri Aug 27 16:44:29 PDT 2010


As one who has an interest in developing dynamic languages, I'm
finding that implementing a DL which features both static and dynamic
typing in classical OO/imperative languages to be quite a challenge.

Recently I came across Microsoft's Dynamic Language Runtime (DLR).

This "is a runtime environment that adds a set of services for dynamic
languages to the common language runtime (CLR). The DLR makes it easier
to develop dynamic languages to run on the .NET Framework and to add
dynamic features to statically typed languages."

More info is here:
Dynamic Language Runtime Overview
http://msdn.microsoft.com/en-us/library/dd233052.aspx

The "Expression Tree" feature is particularly interesting as this
allows AST nodes to directly express computable expressions, which,
in a way, IMHO, unifies the idea that expressions can be thought of
as lazy values.

"Expression trees represent code in a tree-like data structure, where 
each node is an expression, for example, a method call or a binary 
operation such as x < y."

What I'm wondering now is whether languages like D, C++, Java are
really suited for implementing a dynamic languages which feature
a mix of static and dynamic typing capability.  My reading so far
suggests that a higher level approach is needed and that's why we
are seeing development of such things as DLR.  I'm not sure how
dated this is but time ago there was the Spineless Tagless G-machine
(STG) which was developed to underpin the implementation of the Glasgow
Hashell Compiler.

The following PDF article by Simon Peyton Jones gives a good rundown
on the STG machine:

Implementing lazy functional languages on stock hardware:
www.dcc.fc.up.pt/~pbv/aulas/linguagens/peytonjones92implementing.pdf

Amongst other things, one of the things that seems to be missing in D
which would ease the development of DL's is "pattern matching"
capability such as is found in the Scala language.  I seem to recall
that the topic of pattern matching has been briefly discussed on this
ng before (bearophile et. al.???)

To sum up, I'd really appreciate feedback as to whether or not is
worth considering D as a suitable language for implementing a dynamic
language having a non-trivial type system, or is a higher level
approach (such as DLR or STG) really required?

Thanks in advance for all responses,
Justin Johansson


More information about the Digitalmars-d mailing list