
CoreRT – A .NET Runtime for AOT - matthewwarren
http://www.mattwarren.org/2018/06/07/CoreRT-.NET-Runtime-for-AOT/
======
MarkSweep
I think it is really cool how much of the CoreRT is written in C#. Garbage
collection and stack frame walking are implemented, but most everything else
is C#, including exception dispatch:

[https://github.com/dotnet/corert/blob/master/src/Runtime.Bas...](https://github.com/dotnet/corert/blob/master/src/Runtime.Base/src/System/Runtime/ExceptionHandling.cs)

and type-casting:

[https://github.com/dotnet/corert/blob/master/src/Runtime.Bas...](https://github.com/dotnet/corert/blob/master/src/Runtime.Base/src/System/Runtime/TypeCast.cs)

~~~
matthewwarren
Yeah, that's what impressed me as well!

Turns out that even more components could be written in C#, but the ROI just
isn't worth it, see
[https://github.com/dotnet/coreclr/issues/17576](https://github.com/dotnet/coreclr/issues/17576)
for an interesting discussion

------
keyle
quick unrelated show of hands - who here uses .NET for their after hour /
geeking session / projects?

I know .NET quite well, I've used it a lot in enterprise, but I just never
find it to be my go-to language. It just feels like work, it doesn't feel fun.

I usually end up with nodejs, nim, or even pascal.

~~~
manigandham
I find development "speed" to be directly correlated to happiness in side
projects, as in getting things done quickly.

So with that in mind, C# with the right IDE (VS + Resharper, or Rider) is
faster to write than anything else I've ever used and makes working on
projects incredibly nice. Add in the solid standard libraries and the ability
to make everything from websites to desktop apps in the same language and it's
the best choice around, for both work and play.

~~~
macca321
I can recommend getting a a licensed copy of LINQPad. It's a brilliant tool
for trying out ideas and prototyping.

~~~
hnrodey
I love LINQPad. This tool alone is a huge reason why I have a problem using my
Macbook for .NET development.

------
mwcampbell
If the compiler does tree-shaking, I wonder why it takes ~4 MB just to print a
message on the console using the standard library. Is there any way to do a
more fine-grained breakdown of where all that code is coming from?

~~~
naikrovek
They are big leaves/fruit and there are only about 30(?) or so of them.

There is no easy way that I'm aware of. IIRC, early versions of this included
the entire framework, so it's gotten a lot better.

~~~
matthewwarren
> They are big leaves/fruit and there are only about 30(?) or so of them.

Ah, yeah that makes sense, I'd not thought about it like that.

> IIRC, early versions of this included the entire framework, so it's gotten a
> lot better

Yeah, they're definitely improving things over time

------
lwansbrough
As I understand it, this paves the way for .NET based wasm implementations.
Exciting stuff!

~~~
mythz
.NET already runs on WASM, see:
[https://github.com/aspnet/Blazor](https://github.com/aspnet/Blazor)

Although I personally don't think it's a good idea to build HTML UI's with C#,
which adds overhead + friction.

~~~
threeshoes
Blazor currently runs on Mono. CoreRT might allow it to run on .net core

~~~
mythz
The important part is that it's AOT compiled into WASM so it can run in the
browser which is what you can do now with Blazor.

~~~
lewurm
no, blazor uses a Mono version that interprets at runtime .NET. AOT is in the
pipeline though

------
wolfspider
Alright, so here is the big question since ILASM is so powerful really and
.NET Native can potentially reduce the footprint here...What would be the
strategy for a bespoke native CoreFX? The mscorlib/System.Private.CoreLib
issue is that for new platforms it needs to be built PE agnostic temporarily.
PAL needs a placeholder platform to get itself created. CoreCLR is great but a
huge moving target which receives updates at such a furious pace- well imagine
trying to contain dynamite in a closed fist. Actually, mad props to MS and the
open source community for actually making this so solid on a consistent basis!
So, CoreFX needs a seed CLI distributed platform specific. CoreRT may have the
answer to this and really interested in what happens next. You see I wonder
with this platform sharing if a CoreFX could be potentially created with
CoreRT _first_ and then backtrack into a full platform? We'll see- I'm glad
this was shared here on HN also gives me a lot of hope for C#.

------
dmarlow
Waiting for the day to use CoreRT with ASP.NET.

~~~
AdeptusAquinas
You can with aspnet core. Bit tricky tracking down all the reflection types in
the rd.xml file, but once done it results in a really nice, zippy little
deployment

~~~
dmarlow
Are there any tutorials for this? I would love to learn more.

~~~
matthewwarren
I'd start with the WebAPI sample and it's rd.xml file, see
[https://github.com/dotnet/corert/blob/master/samples/WebApi](https://github.com/dotnet/corert/blob/master/samples/WebApi)

Also take a look at this project
[https://github.com/shtik/cli/tree/dev/src/slidey](https://github.com/shtik/cli/tree/dev/src/slidey),
AFAIK it's the project that inspired the video I embedded in the post

