www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Implementing something like DLR in D?

reply Justin Johansson <no spam.com> writes:
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
Aug 27 2010
next sibling parent reply Justin Johansson <no spam.com> writes:
Hmm, perhaps "Implementing dynamic languages in D" would
have been more apt as a subject line, but hopefully people
will understand the gist of my post.

- Justin
Aug 27 2010
parent sybrandy <sybrandy gmail.com> writes:
On 08/27/2010 07:50 PM, Justin Johansson wrote:
 Hmm, perhaps "Implementing dynamic languages in D" would
 have been more apt as a subject line, but hopefully people
 will understand the gist of my post.

 - Justin
I've thought about something like that. Probably not quite what you were thinking as I was only planning on writing a language that with minimal pre-processing becomes valid D code through the use of mixins. May not be the prettiest, but what the hey? Why do all that compiler work when someone else has already done it. Casey
Aug 27 2010
prev sibling next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:

compilable and has both static and duck-typing (I think it can be
interpreted too? Not sure..).

Take a look here:
http://boo.codehaus.org/

I don't see why it wouldn't be possible to do something like that in D.


On Sat, Aug 28, 2010 at 1:44 AM, Justin Johansson <no spam.com> wrote:
 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 eac=
h
 node is an expression, for example, a method call or a binary operation s=
uch
 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. =A0My reading so far
 suggests that a higher level approach is needed and that's why we
 are seeing development of such things as DLR. =A0I'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. =A0I 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
Aug 27 2010
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2010-08-28 01:44, Justin Johansson wrote:
 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
* There is a scripting language called MiniD implemented in D: http://dsource.org/projects/minid * Walter has made an ECMA 262 (JavaScript) implementation in D called DMDScript: http://digitalmars.com/dscript/index.html -- /Jacob Carlborg
Aug 28 2010
parent Justin Johansson <no spam.com> writes:
On 28/08/10 18:47, Jacob Carlborg wrote:
 On 2010-08-28 01:44, Justin Johansson wrote:
 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?
* There is a scripting language called MiniD implemented in D: http://dsource.org/projects/minid * Walter has made an ECMA 262 (JavaScript) implementation in D called DMDScript: http://digitalmars.com/dscript/index.html
Thanks for those links. I was aware of Walter's ECMAScript (aka JS) implementation though not MiniD. To put my quest into context though, I'd hazard a guess that the complexity of the JS type system is on a par with or perhaps a little simpler than the type system in XPath 1.0. Having the the experience of developing an XPath 1.0 implementation in C++ some 10 years ago and without too much difficulty, I think I can say with some insight that the complexity of something like the XPath 2.0 type system is yet a completely different ball game and being an order or magnitude more complex. It is a dynamic language with an XPath 2.0-like type system that I had in mind as having a "non-trivial" type system. This is why I was thinking that perhaps a higher level approach was needed. Other than one very popular Java implementation of XPath 2.0, the only other really decent implementation is that in the Galax XQuery processor which I believe is written in OCaml. Cheers Justin Johansson
Aug 28 2010