DLR, Boo, and JVM

I am just starting to try to learn more about the .Net VM subsystem, and I immediately drop something. I know this new thing is called DLR, which allows all dynamic materials in C # and the launch of IronX languages. But now I read about this language called Boo, and apparently it had dynamic capabilities long before the existence of DLR. So,

1) How is this possible?

2) What adds DLR to the equation?

3) Can a language like Boo get anything by reprofiling in terms of DLR?

From what I put together here and there, it looks like the DLR came out of IronPython when they took into account everything that was needed to support DL in .NET and put it in a reusable form. So I assume that DLR is not something special, just some libraries that help with dynamic objects in Microsoft.Scripting.dll, but nothing that you could just crash and code yourself if you had was there time I think what happened to boo? And then for 2 and 3, I assume that the commonality and reusability of DLR will automatically rebuild any future DLR improvements automatically, but it does not require an urgent “need” for re-implementation using DLR if you already made your own custom time fulfillment? Or does DLR have some secret MS sauce that makes it better than anything we could do on top of .Net?

4) Is DLR really a runtime or just a collection of libraries? (Anyway, what is the runtime? Probably I need to learn more compiler theory before I even understand the answer to this question, or is it even a question that means anything. Ignore this question. Or don't do it.)

5) How does IronPython compilation work? Will she compile a new dynamic version of CIL or add the command "ironpython.exe" to the line with the program text? Hmm, well, if a dynamic keyword is in C #, then there must be a dynamic version of CIL, right? So how does .NET know whether to use CLR or DLR on CIL?

6) Is the DaVinci project for the JVM different? This seems to be the actual reimplementation of the JVM itself. What are the implications of this approach? I guess there are huge performance gains out there, but anything else? Any reason MS didn't go this route?

7) Is DLR for Boo somewhat outdated for DSL?

+4
source share
2 answers

DLR basically brings 3 things to a party:

  • An expanded set of expression trees (first introduced by w / LINQ) that allow you to compile complete programs. They provide a much easier way to generate code than to generate IL directly - it gets rid of many cases of the ability to generate invalid ILs and turns many more cases into easily debugged runtime exceptions.
  • Built-in mechanism for caching sites, so you do not need to create your own (very useful for working well in dynamic languages). This includes things like a tiered cache and obsolescence of unused items.
  • A meta-object protocol that allows dynamic languages ​​to talk to each other at run time and agree on the correct result for the calling language (for example, return undefined in JavaScript when a member does not exist or throw an AttributeError in Python, regardless of the language the dynamic object was written in )

The metaobject protocol is the only part that is absolutely necessary for sharing - all that you could create yourself.

IronPython is completely built on top of DLR, so the compilation model should actually compile expression trees. The inner DLR layer that comes with .NET 4.0 is used to compile these expression trees, and we use an interpreter that is part of the outer layer to interpret these expression trees. Then we can lazily compile expression trees after the interpreted versions become hot. This compilation includes creating call sites, which we use to dynamically send various operations (receiving, setting elements, calling objects, etc.), and again we use DLR - in this case, it calls the site mechanism. IronPython uses a combination of both standard DLR binders for these operations and custom binders that perform specific IronPython actions (flow through a code context that supports * args and ** args calls, etc.), which then return to the standard DLR links for Interop.

The Davinci project will add “method descriptors” to the JVM that the CLR already has in delegate form. He will also add a new invokedynamic opcode, which the CLR does not have and did not get DLR work. Instead, the DLR simply uses existing primitives (delegates, generic generics) and libraries to determine the interaction protocol. Both add the concept of call sites, and they can be quite similar between them.

+4
source

There are a lot of questions! I'm not sure I can answer everyone, but I will do everything in my power:

  • Boo is not dynamic in the same sense as (Iron) Python. It is basically a statically typed language with a strong inference type and pythonic syntax. This, combined with its optional duck print, gives it a very dynamic feel, but it is certainly not the same as Python. Boo looks more (except syntax) in C # 4 than in Python.

  • DLR adds dynamic support for language developers on top of the CLR, which is more focused on statically typed languages ​​(such as VB.NET, C #, F #)

  • Not very IMHO. It will be too similar to IronPython. One of the characteristics of Boo is that it is statically typed.

  • Runtimes are libraries that support some basic language constructs. VB.NET, C #, F #, Boo, they all have runtime libraries. Usually you never see the runtime of VB.NET or C # because they come with the .NET platform. That was a great answer from Eric Lippert, but I can't find it.

  • I can not comment on this, do not have much experience with IronPython.

  • I do not know about the DaVinci project, I can not comment on this.

  • No. As far as I know, Boo macros and the extensible compiler are quite unique for the .NET language ( Nemerle has similar macro capabilities). I can’t say whether Boo DSLs can be more or less powerful than IronPython DSLs. What I can say for sure is that the DSL Boo implementation is very different from the Python DSL implementation.

+4
source

Source: https://habr.com/ru/post/1333119/


All Articles