Long-term C++ programmer (that's me) exploring other languages and is wondering whether it is worth learning much about D 2.0. (That is the clean slate re-write of D.) So far, I like what I see - many pragmatic, wise choices. Now, I want to learn a little more and want to know whether it is likely ever to be possible to do the following:
In summary, I would like to have a D 2.0 compiler with a backend capable of generating Javascript.
So my question has two parts:
For context, the reason that I would like the above is so that I could implement a bunch of business logic in D 2.0, and then use that business logic in a pure Javascript (that is no Flash/Silverlight/Java) Web Application.
Update
I have had three answers, two of which are on-topic, and one that is not and is therefore ignored.
@FeepingCreature reckons that it will never happen because "it's too incongruous with D's targeted environment". I am interested to know what that means, and have asked.
@Nekuromento , in contrast, points out that it is already theoretically possible using LDC, followed by the LLVM Javascript backend. I checked out both links. LDC support for D 2.0 looks like a work in progress. But I would guess it will get there at some point. The LLVM Javascript is also not optimised or minified, but it looks from the demos that they work. So I think that is enough to be useful at the very least.
Update 2
OK - this seems to be the best solution to date.
I will choose a best answer fairly soon, but I would like some more-informed opinion really.
Update 3
Some more information on why I want to do this.
Here is a concrete example of one project that I wish to implement. It will be a geometric modelling library, probably written by just me, taking several years to write, and ending up at about 100,000 lines of code. I would like it to contain as close to zero bugs as possible, and, therefore, I do not wish to implement it in Javascript. I would like it to run on the server, on the desktop, and in the browser too. (By in "in the browser" I mean without the assistance of any plugin such as Flash, Silverlight or Java.) The truth is that code in the browser running on Javascript is here to stay for a while. Projects will increasingly need a strategy to deal with that.
Update 4
I was hoping for some more answers, but didn't get them. Ah well, never mind. Thanks for all the feedback, including @dsimicha 's stimulating comments. (I hope it is OK to disagree technically sometimes, while at the same time keeping things civil.) I have accepted @Nekuromento 's answer.
Update 5 2018-07-18
Seven years on, LDC v1.11 supports compiling and linking to WebAssembly.3
Such a compiler currently does not exist, but there is some work on javascript LLVM-backend.
As there is LDC. It uses DMD front-end and LLVM, so theoretically one can add javascript output to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With