[WIP] Embed .NET (Core) in your D app
evilrat
evilrat666 at gmail.com
Tue Feb 11 05:21:20 UTC 2020
Hi everyone,
recently I was working on .NET embedding, and I have done simple
library for hosting .NET Core in D, it is accompanied with small
C# library that takes care of some limitations of current .NET
implementation regarding native delegates.
It allows to embed .NET runtime in your program and call .NET
code, for example it might be some important library implemented
only in C# or maybe you want to build your own game engine and
use it as scripting* engine like Unity does.
*Oh, and this is also interesting because .NET Core 3.1 size is
roughly 70 MB with libs, which is nearly the same size as
CPython, but has advantage of performance AND security features.
It is still in quite early stage and lacks some important
features, so I don't recommend using it in production.
However I think some might find it useful, others might like to
evaluate the possibilities.
I have quite fuzzy roadmap for future related projects ATM and I
can't give any precise dates, but anyway here is 4 projects that
I have in mind:
1) host utility library (WIP, already has some crucial
features, prerequisite for all future work on this list)
2) D .NET host library (WIP, .NET Core low level stuff done,
high level .NET wrapper generator is still not designed though)
3) utility tool that outputs proper declarations to use in D
(planned)
4) D to .NET compiler, this ultimately requires all previous
steps done, and I still haven't sorted out what D features could
be problematic to implement (not yet started)
Wrt. to compiler my biggest concern is actually not the language
features itself, since .NET has almost everything D can do, but
rather D runtime and standard library. This is however is so
distant future that I can't even say I will ever do this.
The good thing is that I can work on compiler itself thanks to
dmd-as-a-library dub package.
Now of course the question is why I am even bother doing this?
- .NET 5 is going to release later in 2020 finally unifying both
MS .NET and Mono VM's
- it will have many improvements, features and stuff, all this is
cross platform (you can find more info on the net) (oh crap,
sounds like some BS ad)
- AOT/JIT (D lacks this, can benefit REPL's, and can also in some
cases give you that last drops of performance)
- so far no other "serious" language have targeted .NET so this
niche is quite empty, this could give D enormous advantage and
recognition especially in enterprise (don't quote me on this
though)
- ???
- profit (oh, I hope so)
source code
https://github.com/Superbelko/dotnethost-d
More information about the Digitalmars-d
mailing list