News for hackers. Stuff that matters.
Re:JavaScript to Rust and Back Again: A Wasm-Bindgen Tale by maxxxxx on Wednesday April 04, 2018 @07:09PM (#16760207)
Doesn't the small size only apply if you compile to assembly? If you compile to webasm shouldn't things be different? I am assuming a C# to webasm would be very different from the current C# to IL compiler.
Re:JavaScript to Rust and Back Again: A Wasm-Bindgen Tale by steveklabnik on Wednesday April 04, 2018 @07:32PM (#16760326)
> Doesn't the small size only apply if you compile to assembly? If you compile to webasm shouldn't things be different?

I'm not sure what you mean, could you re-phrase maybe? The article is talking about compiling to WebAssembly already.

Re:JavaScript to Rust and Back Again: A Wasm-Bindgen Tale by maxxxxx on Wednesday April 04, 2018 @09:45PM (#16761083)
A previous poster states that a "hello world" in Rust is 100 byte. Is that Rust compiled to machine or webasm? Simple C# compiled to an exe is bigger but by not much. But you need a big runtime. Now if you compiled C# to webasm you potentially wouldn't need the .NET runtime so the result should be quite similar to the Rust code. In addition if you modified the C# compiler to have a real linker that only includes code from the runtime that's actually used I would think the output size shouldn't grow much.
Re:JavaScript to Rust and Back Again: A Wasm-Bindgen Tale by steveklabnik on Thursday April 05, 2018 @07:22AM (#16763750)
That's Rust compiled to WebAssembly.

> Now if you compiled C# to webasm you potentially wouldn't need the .NET runtime

Why not? How does C# work without the runtime? As the docs for .NET Native say:

> You can continue to take advantage of the resources provided by the .NET Framework, including its class library, automatic memory management and garbage collection, and exception handling.

So you still have that runtime code in your binary, even if it's not JITted.

Re:JavaScript to Rust and Back Again: A Wasm-Bindgen Tale by yougane on Wednesday April 04, 2018 @08:09PM (#16760570)
I think what he means is that C# apps would have a smaller size if AOT compiled to wasm instead of shipping the mono runtime with .NET assemblies. (sorry for my English)
Re:JavaScript to Rust and Back Again: A Wasm-Bindgen Tale by pjmlp on Thursday April 05, 2018 @01:30AM (#16762064)
C# has been AOT compiled since the early days.

Just that only dynamic linking was supported on the regular .NET Framework.

Unity(with IL2CPP), Mono and Windows 8 store apps also support static linking.

So the approach is the same as Xamarin for iOS or .NETbon the Windows store.

There is an additional phase that generates the native code, using MSIL as just yet another compiler phase.

As for the runtime, yes there needs to be a minimal set of services.

But even C, C++, Go, ... need to have some kind of runtime if you want to use all language features.

Re:JavaScript to Rust and Back Again: A Wasm-Bindgen Tale by steveklabnik on Wednesday April 04, 2018 @08:42PM (#16760753)
Your English is fine!

I don’t know enough about how C# is AOTd to really answer that. I mean, some runtime code would still need to be in there, I assume?

Re:JavaScript to Rust and Back Again: A Wasm-Bindgen Tale by pjmlp on Thursday April 05, 2018 @01:34AM (#16762075)
Yes, the approach is similar to all major AOT compilers on .NET space.

NGEN, .NET Native, CoreRT, Mono, Xamarin, IL2CPP, HPC#.

A minimal runtime is always needed, for some of the language semantics, FFI and memory management.