D to Javascript converter (a hacked up dmd)
Piotr Szturmaj
bncrbme at jadamspam.pl
Tue Feb 28 18:42:43 PST 2012
Adam D. Ruppe wrote:
> On Tuesday, 28 February 2012 at 19:27:57 UTC, Piotr Szturmaj wrote:
>> Can it compile a function to native code and JS simultaneously? I want
>> to execute the same code on both client and server side.
>
> You'd have to run dmd twice because it exits before getting
> to the backend when doing js.
>
> But you can run the same code:
>
> dmd -md file.d # outputs file.js
> dmd file.d # outputs file.exe
I see.
> You might need versions or something for library support,
> but that's just because I haven't ported much over yet.
I realize that work on project has just begun :)
> I just now tried:
>
> import std.algorithm;
> auto range = sort!"a < b"(["b", "a"]);
> window.alert(range.front);
>
> .. and it produced 44 KB of Javascript
> code that *almost* worked.
44 KB - that's not bad!
> Looks like I have to fix the dollar expression,
> but otherwise, almost usable.
Some time ago, I was interested in translation to JS, but I rather
thought about binary translation, like in http://bellard.org/jslinux/.
There's similar "emscripten" project which translates LLVM bytecode to
JS: https://github.com/kripken/emscripten. And there's also commercial
Morfik: http://en.wikipedia.org/wiki/Morfik. Perhaps you might find
these links useful, if you don't know them already.
More information about the Digitalmars-d-announce
mailing list