New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

corlib and JIT updates #7

Open
wants to merge 4 commits into
base: master
from

Conversation

@ncave
Contributor

ncave commented Aug 14, 2017

Here are a few fixes and updates to the corlib and JIT:

  • Better C# support (added some missing JIT features, some bug fixes and updates).
  • Added F# support (uses custom FSharp.Core, see here for a working example).
  • Tried my best to keep the corlib light, it's still around 260k (in release mode).
  • Release build assemblies now work too (after JIT bugfixes).

I see you added CLR debugging in the browser, that's awesome!

@Terricide

This comment has been minimized.

Show comment
Hide comment
@Terricide

Terricide Aug 17, 2017

This looks like a good pull request. I'm excited for this project

Terricide commented Aug 17, 2017

This looks like a good pull request. I'm excited for this project

@stavroskasidis

This comment has been minimized.

Show comment
Hide comment
@stavroskasidis

stavroskasidis Aug 24, 2017

C# client side ??
DO WANT !!!

Seriously this looks great.

stavroskasidis commented Aug 24, 2017

C# client side ??
DO WANT !!!

Seriously this looks great.

@rvhuang

This comment has been minimized.

Show comment
Hide comment
@rvhuang

rvhuang Aug 25, 2017

That's awesome! By the way, do we have Blazor on official Core 2.0 instead of preview version?

rvhuang commented Aug 25, 2017

That's awesome! By the way, do we have Blazor on official Core 2.0 instead of preview version?

@chris-ray

This comment has been minimized.

Show comment
Hide comment
@chris-ray

chris-ray Aug 25, 2017

+1 adding my support for this project. Reaaaally want to see it come to fruition!

chris-ray commented Aug 25, 2017

+1 adding my support for this project. Reaaaally want to see it come to fruition!

@Huarru

This comment has been minimized.

Show comment
Hide comment
@Huarru

Huarru Aug 25, 2017

How can one help with this project? Because I seriously want to see this getting bigger :)

Huarru commented Aug 25, 2017

How can one help with this project? Because I seriously want to see this getting bigger :)

@stavroskasidis

This comment has been minimized.

Show comment
Hide comment
@stavroskasidis

stavroskasidis Aug 25, 2017

+1 @Huarru I too would love to know how I can help.
This project needs to get a team behind it, Microsoft !!

I really think this can be a solution for the messed up, mangled mess that we today call web development. https://twitter.com/thomasfuchs/status/708675139253174273?lang=el

stavroskasidis commented Aug 25, 2017

+1 @Huarru I too would love to know how I can help.
This project needs to get a team behind it, Microsoft !!

I really think this can be a solution for the messed up, mangled mess that we today call web development. https://twitter.com/thomasfuchs/status/708675139253174273?lang=el

@stavroskasidis

This comment has been minimized.

Show comment
Hide comment
@stavroskasidis

stavroskasidis Aug 26, 2017

I tried implementing a new feature but the missing reflection features are blocking me. I tried using DNA from this PR but still there are a lot of basic reflection stuff missing.

I think the first thing to do should be extending DNA, although I am not sure if this is the way to go since Mono is also working to bring their runtime to wasm.

http://www.mono-project.com/news/2017/08/09/hello-webassembly/

Maybe switch to Mono runtime ? (when ready)

stavroskasidis commented Aug 26, 2017

I tried implementing a new feature but the missing reflection features are blocking me. I tried using DNA from this PR but still there are a lot of basic reflection stuff missing.

I think the first thing to do should be extending DNA, although I am not sure if this is the way to go since Mono is also working to bring their runtime to wasm.

http://www.mono-project.com/news/2017/08/09/hello-webassembly/

Maybe switch to Mono runtime ? (when ready)

@JohnGalt1717

This comment has been minimized.

Show comment
Hide comment
@JohnGalt1717

JohnGalt1717 Aug 26, 2017

Here's why reflection in this type of project is not desirable:. Reflection prevents a linker from pruning code unless done very carefully.

It is imparitive that blazor implements a linker to shrink the size and using DNA keeps the monster size of mono out of this. (see how large the same app is for xamarin Android versus Java if you have any questions and that's with a linker)

On the web all you need is event handling, http requesting, and operations in the Dom (and cookies, storage I etc) all with strong typing. Essentially everything else is noise that should be done server side.

If a model that uses razor syntax for binding with eventing can be created that matches angular but does so with dnx and web assembly using mvc pages and mvc routing we'd have a massive win and would forever change web development, which is a disaster right now) for the better.

And as an aside, Al of this has the benefit of being natively executable for server side pre-rendered for SEO with seamless handoff and no nodejs involved which is another HUGE win.

JohnGalt1717 commented Aug 26, 2017

Here's why reflection in this type of project is not desirable:. Reflection prevents a linker from pruning code unless done very carefully.

It is imparitive that blazor implements a linker to shrink the size and using DNA keeps the monster size of mono out of this. (see how large the same app is for xamarin Android versus Java if you have any questions and that's with a linker)

On the web all you need is event handling, http requesting, and operations in the Dom (and cookies, storage I etc) all with strong typing. Essentially everything else is noise that should be done server side.

If a model that uses razor syntax for binding with eventing can be created that matches angular but does so with dnx and web assembly using mvc pages and mvc routing we'd have a massive win and would forever change web development, which is a disaster right now) for the better.

And as an aside, Al of this has the benefit of being natively executable for server side pre-rendered for SEO with seamless handoff and no nodejs involved which is another HUGE win.

@stavroskasidis

This comment has been minimized.

Show comment
Hide comment
@stavroskasidis

stavroskasidis commented Aug 26, 2017

@JohnGalt1717 Ok, that makes sense

@pineywoods

This comment has been minimized.

Show comment
Hide comment
@pineywoods

pineywoods Aug 26, 2017

+1 for this project. I'm waiting with baited breath.

pineywoods commented Aug 26, 2017

+1 for this project. I'm waiting with baited breath.

@RonPenton

This comment has been minimized.

Show comment
Hide comment
@RonPenton

RonPenton Aug 26, 2017

I get that reflection is tricky when it comes to dead code elimination, but it's also an integral part of many codebases.

Perhaps an approach like .NET Native's "Runtime Directives" can be used?

https://docs.microsoft.com/en-us/dotnet/framework/net-native/reflection-and-net-native

RonPenton commented Aug 26, 2017

I get that reflection is tricky when it comes to dead code elimination, but it's also an integral part of many codebases.

Perhaps an approach like .NET Native's "Runtime Directives" can be used?

https://docs.microsoft.com/en-us/dotnet/framework/net-native/reflection-and-net-native

@RonPenton

This comment has been minimized.

Show comment
Hide comment
@RonPenton

RonPenton Aug 26, 2017

PS if anyone needs an extra hand for this, sign me up.

RonPenton commented Aug 26, 2017

PS if anyone needs an extra hand for this, sign me up.

@yanglee

This comment has been minimized.

Show comment
Hide comment
@yanglee

yanglee Aug 26, 2017

What kind of knowledge is required to contribute to this project? Does anyone have any recommendations on which books I should read?

I think rather than wasting countless hours writing awkward JavaScript/TypeScript code, I would rather spend those hours contribute to this project.

yanglee commented Aug 26, 2017

What kind of knowledge is required to contribute to this project? Does anyone have any recommendations on which books I should read?

I think rather than wasting countless hours writing awkward JavaScript/TypeScript code, I would rather spend those hours contribute to this project.

@ncave

This comment has been minimized.

Show comment
Hide comment
@ncave

ncave Aug 26, 2017

Contributor

@SteveSanderson Separated the Blazor-Hackaton baseline to help the review.

Contributor

ncave commented Aug 26, 2017

@SteveSanderson Separated the Blazor-Hackaton baseline to help the review.

@csells

This comment has been minimized.

Show comment
Hide comment
@csells

csells Aug 26, 2017

csells commented Aug 26, 2017

@TylerBrinkley

This comment has been minimized.

Show comment
Hide comment
@TylerBrinkley

TylerBrinkley Aug 30, 2017

Just saw the announcement of an official .NET IL Linker at dotnet/core#915. That seems like great news for this project to reduce code size!

TylerBrinkley commented Aug 30, 2017

Just saw the announcement of an official .NET IL Linker at dotnet/core#915. That seems like great news for this project to reduce code size!

@chrisdunelm

Nothing in-depth, just some minor comments having skimmed the code...

Show outdated Hide outdated src/DNA/corlib/System/String.cs
Show outdated Hide outdated src/DNA/corlib/System/String.cs
Show outdated Hide outdated src/DNA/native/src/Generics.c
Show outdated Hide outdated src/DNA/native/src/Heap.c
Show outdated Hide outdated src/DNA/native/src/Heap.c
Show outdated Hide outdated src/DNA/native/src/JIT_Execute.c
Show outdated Hide outdated src/DNA/native/src/Heap.c
@@ -0,0 +1,33 @@
//
// IReadOnlyCollection.cs

This comment has been minimized.

@davidfowl

davidfowl Sep 3, 2017

Collaborator

Why copy from mono instead of corefx?

@davidfowl

davidfowl Sep 3, 2017

Collaborator

Why copy from mono instead of corefx?

This comment has been minimized.

@ncave

ncave Sep 3, 2017

Contributor

No particular reason, this interface is the same either way. Perhaps one reason, the original DNA seem to be based on mono (although I can't be 100% sure), and the mono implementation is usually a bit smaller and simpler. In any case, I have refrained from copying too much, only the bare essentials to get things going.

@ncave

ncave Sep 3, 2017

Contributor

No particular reason, this interface is the same either way. Perhaps one reason, the original DNA seem to be based on mono (although I can't be 100% sure), and the mono implementation is usually a bit smaller and simpler. In any case, I have refrained from copying too much, only the bare essentials to get things going.

This comment has been minimized.

@chrisdunelm

chrisdunelm Sep 3, 2017

Yes, DNA originally used Mono code for classes that didn't require any integration into the C interpreter, and I didn't have the time/inclination to write from scratch. Clearly corefx didn't exist at the time!
Note that the classes I wrote were generally written to be small, rather than performant; the platform I originally wrote this for was very resource limited. Although this was all so long ago I can't really remember details.
Switching to using corefx code might now make some sense.

@chrisdunelm

chrisdunelm Sep 3, 2017

Yes, DNA originally used Mono code for classes that didn't require any integration into the C interpreter, and I didn't have the time/inclination to write from scratch. Clearly corefx didn't exist at the time!
Note that the classes I wrote were generally written to be small, rather than performant; the platform I originally wrote this for was very resource limited. Although this was all so long ago I can't really remember details.
Switching to using corefx code might now make some sense.

@ncave

This comment has been minimized.

Show comment
Hide comment
@ncave

ncave Sep 5, 2017

Contributor

@SteveSandersonMS Rebased to latest.

Contributor

ncave commented Sep 5, 2017

@SteveSandersonMS Rebased to latest.

@arpadbarta

This comment has been minimized.

Show comment
Hide comment
@arpadbarta

arpadbarta Sep 17, 2017

Love the project and eager to experiment with some ideas, but there are quite few outstanding PR's that contain a lot of changes. Could some of the PR-s be merged?

arpadbarta commented Sep 17, 2017

Love the project and eager to experiment with some ideas, but there are quite few outstanding PR's that contain a lot of changes. Could some of the PR-s be merged?

@SteveSanderson

This comment has been minimized.

Show comment
Hide comment
@SteveSanderson

SteveSanderson Sep 20, 2017

Owner

@arpadbarta I know it's taking a while to merge this, and apologies for that. But please don't expect this repo to be a typical open-source project in a normal phase of maintenance. Instead, this repo is an experiment, not intended to have any particular level of support. Future plans are still being worked out.

Owner

SteveSanderson commented Sep 20, 2017

@arpadbarta I know it's taking a while to merge this, and apologies for that. But please don't expect this repo to be a typical open-source project in a normal phase of maintenance. Instead, this repo is an experiment, not intended to have any particular level of support. Future plans are still being worked out.

@TylerBrinkley

This comment has been minimized.

Show comment
Hide comment
@TylerBrinkley

TylerBrinkley Sep 20, 2017

Future plans are still being worked out.

I like the sound of that, given the Blazor-Hackathon on the official ASP.NET github org I'm hoping this may mean official Microsoft support!

TylerBrinkley commented Sep 20, 2017

Future plans are still being worked out.

I like the sound of that, given the Blazor-Hackathon on the official ASP.NET github org I'm hoping this may mean official Microsoft support!

@MaverickMartyn

This comment has been minimized.

Show comment
Hide comment
@MaverickMartyn

MaverickMartyn Sep 20, 2017

I can't wait to see what this becomes. I am getting all giddy. XD

MaverickMartyn commented Sep 20, 2017

I can't wait to see what this becomes. I am getting all giddy. XD

@ebekker

This comment has been minimized.

Show comment
Hide comment
@ebekker

ebekker Sep 20, 2017

I'm hoping collaboration with mono-wasm can speed things along by sharing resources, and advancing both experiments to an officially supported set of tools. Each project has a different architectural approach (e.g. client-side Razor vs. browser-targeting XAML), but so much of the underlying core and foundation would be common and sharable by both teams.

ebekker commented Sep 20, 2017

I'm hoping collaboration with mono-wasm can speed things along by sharing resources, and advancing both experiments to an officially supported set of tools. Each project has a different architectural approach (e.g. client-side Razor vs. browser-targeting XAML), but so much of the underlying core and foundation would be common and sharable by both teams.

@gulshan

This comment has been minimized.

Show comment
Hide comment
@gulshan

gulshan Sep 20, 2017

And there's also this- dotnet/corert#4480

gulshan commented Sep 20, 2017

And there's also this- dotnet/corert#4480

@JohnGalt1717

This comment has been minimized.

Show comment
Hide comment
@JohnGalt1717

JohnGalt1717 Sep 20, 2017

Microsoft really really really needs to take command of this, make it official and pull all of these initiatives together and get a cohesive whole that has 2 paths:

  1. HTML with angular/razor style markup that generates an SPA
  2. XAML SPA

Pick which you want to use. In either case, both should automatically become a best of breed UWP application when targeted at the store with additional functionality available.

And they should direct compile to iOS and Android as well. (without a requirement for a mac, meaning MS has to put the build and test stuff in the cloud for iOS and give it away free to devs so they have no reason to ever use a mac)

JohnGalt1717 commented Sep 20, 2017

Microsoft really really really needs to take command of this, make it official and pull all of these initiatives together and get a cohesive whole that has 2 paths:

  1. HTML with angular/razor style markup that generates an SPA
  2. XAML SPA

Pick which you want to use. In either case, both should automatically become a best of breed UWP application when targeted at the store with additional functionality available.

And they should direct compile to iOS and Android as well. (without a requirement for a mac, meaning MS has to put the build and test stuff in the cloud for iOS and give it away free to devs so they have no reason to ever use a mac)

@stavroskasidis

This comment has been minimized.

Show comment
Hide comment
@stavroskasidis

stavroskasidis Oct 9, 2017

Every single time I fire up a "React getting started" tutorial with typescript, webpack and redux, 5 minutes later I have stopped reading in frustration and I find myself back to this repo, gazing at the "what-could-be" future.

I have done the "Todo List" sample in Blazor multiple times by now, demoing it to some colleagues, and every time it reminds me how easy and natural it feels writing in it.

The timing is right. I believe that web assembly will even the playing field. It's time to seize this opportunity and make C# the go-to language for full stack web development.

Please make this happen !! T_T

stavroskasidis commented Oct 9, 2017

Every single time I fire up a "React getting started" tutorial with typescript, webpack and redux, 5 minutes later I have stopped reading in frustration and I find myself back to this repo, gazing at the "what-could-be" future.

I have done the "Todo List" sample in Blazor multiple times by now, demoing it to some colleagues, and every time it reminds me how easy and natural it feels writing in it.

The timing is right. I believe that web assembly will even the playing field. It's time to seize this opportunity and make C# the go-to language for full stack web development.

Please make this happen !! T_T

@ncave ncave referenced this pull request Oct 30, 2017

Closed

What about tailcalls? #8

@SteveSandersonMS

This comment has been minimized.

Show comment
Hide comment
@SteveSandersonMS

SteveSandersonMS Oct 30, 2017

Collaborator

Thanks @ncave for continuing to contribute to this! Just so you know, our hope is to move away from the DNA runtime shortly and replace it with a more full-featured one. If this works out (no guarantees yet though) then you could absolutely still continue to develop DNA (and there might indeed be demand for that as it might always be the smallest .NET runtime there is), but it would be good to move that over to another repo under your control. Does that sound OK?

Collaborator

SteveSandersonMS commented Oct 30, 2017

Thanks @ncave for continuing to contribute to this! Just so you know, our hope is to move away from the DNA runtime shortly and replace it with a more full-featured one. If this works out (no guarantees yet though) then you could absolutely still continue to develop DNA (and there might indeed be demand for that as it might always be the smallest .NET runtime there is), but it would be good to move that over to another repo under your control. Does that sound OK?

@ncave

This comment has been minimized.

Show comment
Hide comment
@ncave

ncave Oct 30, 2017

Contributor

@SteveSandersonMS Thanks Steve, I figured you guys are up to something, and that's awesome, can't wait to see it. I already have another DNA development repo, that's where the updates are coming from.

Contributor

ncave commented Oct 30, 2017

@SteveSandersonMS Thanks Steve, I figured you guys are up to something, and that's awesome, can't wait to see it. I already have another DNA development repo, that's where the updates are coming from.

@mattwarren

This comment has been minimized.

Show comment
Hide comment
@mattwarren

mattwarren Oct 30, 2017

BTW In case you haven't seen it, I wrote a post to try and let more people know about DNA, see DotNetAnywhere: An Alternative .NET Runtime.

There's also some interesting follow-up discussions, see HackerNews and /r/programming (including comments from @chrisdunelm)

mattwarren commented Oct 30, 2017

BTW In case you haven't seen it, I wrote a post to try and let more people know about DNA, see DotNetAnywhere: An Alternative .NET Runtime.

There's also some interesting follow-up discussions, see HackerNews and /r/programming (including comments from @chrisdunelm)

@ncave

This comment has been minimized.

Show comment
Hide comment
@ncave

ncave Oct 30, 2017

Contributor

@mattwarren Of course I've seen it, great write-up, so much depth and detail. Thanks for the links!

Contributor

ncave commented Oct 30, 2017

@mattwarren Of course I've seen it, great write-up, so much depth and detail. Thanks for the links!

@Postlagerkarte

This comment has been minimized.

Show comment
Hide comment
@Postlagerkarte

Postlagerkarte Oct 30, 2017

It is so great that this thing keeps moving! Can't wait to see it happen.

While waiting I enjoyed browsing the following three repositories:

CoreRT

WebAssembly is a new technology for running code at near-native speed in browsers. A group of folks on the .NET team worked together to see what WebAssembly might look like using CoreRT.

They also issued a call for help dotnet/corert#4659

I have seen several pull requested merged in the last few days. So there is some action going on there.

WebSharp

This project is intended to support running .NET code as an Electron Plugin, running code using the Mono runtime, side-by-side the V8 engine and to provide both C# API bindings to Electron's plugin API as well as the Web browser API.

Last commit was 6 weeks ago. Seems like no public action going on here anymore.

MonoWasm

This project is a proof-of-concept aiming at building C# applications into WebAssembly, by using Mono and compiling/linking everything statically into one .wasm file that can be easily delivered to browsers

This repository is owned by Laurent Sansonetti who works for Microsoft in Belgium. Steve and Laurent exchanged some emails and they tried to get it running with Blazor.

Last commit was 10 days ago.

Postlagerkarte commented Oct 30, 2017

It is so great that this thing keeps moving! Can't wait to see it happen.

While waiting I enjoyed browsing the following three repositories:

CoreRT

WebAssembly is a new technology for running code at near-native speed in browsers. A group of folks on the .NET team worked together to see what WebAssembly might look like using CoreRT.

They also issued a call for help dotnet/corert#4659

I have seen several pull requested merged in the last few days. So there is some action going on there.

WebSharp

This project is intended to support running .NET code as an Electron Plugin, running code using the Mono runtime, side-by-side the V8 engine and to provide both C# API bindings to Electron's plugin API as well as the Web browser API.

Last commit was 6 weeks ago. Seems like no public action going on here anymore.

MonoWasm

This project is a proof-of-concept aiming at building C# applications into WebAssembly, by using Mono and compiling/linking everything statically into one .wasm file that can be easily delivered to browsers

This repository is owned by Laurent Sansonetti who works for Microsoft in Belgium. Steve and Laurent exchanged some emails and they tried to get it running with Blazor.

Last commit was 10 days ago.

@Terricide

This comment has been minimized.

Show comment
Hide comment
@Terricide

Terricide Oct 30, 2017

In excited for the debugging support that blazor is doing. Hopefully it will be useful for the other frameworks.

Terricide commented Oct 30, 2017

In excited for the debugging support that blazor is doing. Hopefully it will be useful for the other frameworks.

@stavroskasidis

This comment has been minimized.

Show comment
Hide comment
@stavroskasidis

stavroskasidis Nov 6, 2017

Moved to mono runtime!
Awesome

stavroskasidis commented Nov 6, 2017

Moved to mono runtime!
Awesome

@wanton7

This comment has been minimized.

Show comment
Hide comment
@wanton7

wanton7 Dec 5, 2017

Not sure if this is correct place to ask. But after browsing ClientServerApp sample I noticed it uses bootstrap that uses jQuery. How does Blazor work with jQuery without memory leaks? What I mean is, lets say you have following

<div id="foobar">
  <a id="my">Click me</a>
</div>
<script>
$("#my").on("click", function () { console.log("clicked"); });
$("#my").data("foo", "bar");
$("#foobar").html("");
</script>

In this situation jQuery automatically removes events and element data attached to #my from memory. But if you replace $("#foobar").html("") with document.getElementById("foobar").innerHTML = "" it doesn't remove them and this causes memory leak.

api.jquery.com/html

Also about Bootstrap modal that is used in sample, when you open a bootstrap modal it appends elements to end of body that need additional cleanup to remove completely. With Bootstrap 3 it's harder to clean up. With Bootstrap 4 you can use .modal('dispose').

How can you remove jQuery components properly with Blazor? This applies to vanilla JavaScript components as well that need cleanup. Angular 2+ has ngOnDestroy, React has componentWillUnmount and VueJS has beforeDestroy events for that.

wanton7 commented Dec 5, 2017

Not sure if this is correct place to ask. But after browsing ClientServerApp sample I noticed it uses bootstrap that uses jQuery. How does Blazor work with jQuery without memory leaks? What I mean is, lets say you have following

<div id="foobar">
  <a id="my">Click me</a>
</div>
<script>
$("#my").on("click", function () { console.log("clicked"); });
$("#my").data("foo", "bar");
$("#foobar").html("");
</script>

In this situation jQuery automatically removes events and element data attached to #my from memory. But if you replace $("#foobar").html("") with document.getElementById("foobar").innerHTML = "" it doesn't remove them and this causes memory leak.

api.jquery.com/html

Also about Bootstrap modal that is used in sample, when you open a bootstrap modal it appends elements to end of body that need additional cleanup to remove completely. With Bootstrap 3 it's harder to clean up. With Bootstrap 4 you can use .modal('dispose').

How can you remove jQuery components properly with Blazor? This applies to vanilla JavaScript components as well that need cleanup. Angular 2+ has ngOnDestroy, React has componentWillUnmount and VueJS has beforeDestroy events for that.

@ChicagoDave

This comment has been minimized.

Show comment
Hide comment
@ChicagoDave

ChicagoDave Dec 18, 2017

Wish list:
basic XAML (doesn't need to be all of WPF), canvas, controls, layout, and styles first...animation later
full HttpClient

ChicagoDave commented Dec 18, 2017

Wish list:
basic XAML (doesn't need to be all of WPF), canvas, controls, layout, and styles first...animation later
full HttpClient

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment