
The LDC D language compiler can now generate WebAssembly - ingve
https://wiki.dlang.org/Generating_WebAssembly_with_LDC
======
CyberShadow
Cool, great that you can now do this with LDC directly.

There was a way to compile D to WASM before (using the dscripten package),
however that was more akin to a collection of loose pieces strung together.

As with Go, a big obstacle for running typical D code in browsers is reliance
on a garbage collector, which requires scanning stacks and temporaries for
reachable heap object. Though it's possible to overcome in theory with just
compiler support, garbage collection in WASM itself seems to be an ongoing
discussion.

~~~
jokoon
Please no, leave that to js.

Why can't they just let devs embed their own garbage collector? Isn't he role
of an assembly language to let the developer do stuff at a low level?

~~~
ben-schaaf
I'd wager there's a lot of lower level optimisations - especially for
different architectures - that you just can't get with platform agnostic
'assembly'.

I also think its better for everyone if you don't need to load/download,
decode, compile and run a full language runtime on every page load. Imagine a
JVM running on web assembly: Every page load first has to decode and compile a
full many-MB JVM, then the JVM can start booting - without any
platform/architecture specific optimizations.

The more stuff that's common for webasm-targeting-languages that we can move
into the browser, the less effort wasted overall.

~~~
megaman22
Somebody wake me up when we move beyond reimplementing Java applets and Flash
once more. We had nice batteries-included VMs in the browser, and we turned
our backs on them and went back to square one. Again, and again, and again. So
we could bang rocks together with javascript.

Almost makes me wish VBScript IE had won. We might be writing browser apps in
.NET now...

~~~
kodablah
One might be seen as sleeping back then too if they considered proprietary,
complicated, insecure behemoths with large, sometimes shitty standard
libraries and forced high-level constructs as "nice batteries-included VMs".

~~~
crooked-v
> sometimes shitty

I still have to do .stream() and .toList() (or .collect(Collectors.toList()))
back and forth in Java all the time just to get reliable access to map/filter
lambdas while still having a valid return value.

~~~
megaman22
Java's shittiness is a problem, but for the mid 2000s, it wasn't extra shitty
in comparison. That long stagnation after 1.6 really hurt.

------
Ace17
The title is misleading : only a small subset (-betterC) of the D langage
currently is supported, and that's too bad!

~~~
giancarlostoro
It's a start and ideally eventually all of D will be able to run under
-betterC or just enough of it at least is what I understand is the goal.

------
earenndil
This was already technically possible by compiling to llvm bitcode and then
using emscripten to compile that to wasm (or asm.js). Still cool though!

------
Tim_cas
This is great news!

