Experiments with emscripten and D

Piotr Szturmaj bncrbme at jadamspam.pl
Thu Aug 15 14:55:52 PDT 2013


bearophile:
> Piotr Szturmaj:
>
>> Then open sdl.html in the web browser. It should print sorted and
>> mapped array contents and run simple graphics demo.
>
> Very nice. D is meant to run efficiently, but the Web is very important.
> There are many situations where it could be useful to run D code in a
> browser, so your work is important.
>
> Integration with asm.js too is useful. (Expecially when asm.js gets a
> garbage collection, as Mozilla says). Currently only C and C++ are
> perhaps the only two languages usable to write asm.js+WebGL games for
> the browser. This could become one of the few niches open for D. There
> is also WebCL (http://www.khronos.org/webcl/ ) for heavy computations in
> the browser.

Also D is garbage collected like JS. This means that high level code 
translation (like Adam D. Ruppe's work) should be more straightforward. 
On the other hand translating LLVM IR opens the possibility to mix D 
with C/C++ libraries.

> I have found some related activity from Rust people:
> https://github.com/mozilla/rust/issues/2235
> https://github.com/Yoric/Mozilla-Student-Projects/issues/33
> https://mail.mozilla.org/pipermail/rust-dev/2012-April/001607.html
>
> Once your work is more more completed, the dlang site could show (in a
> sub-page) the compiler that compiles the online examples of the docs
> that's able to produce html+JS on the fly from the D code written in the
> browser.

Yes, and it could be used to write rich web applications (which is the 
reason I'm working on it). JavaScript certainly wasn't created for big 
codebases...

The other big advantage would having one codebase shared between server, 
browser (including mobile) and desktop apps.


More information about the Digitalmars-d mailing list