A long-term C ++ programmer (that I) study other languages ββand wonder if it's worth learning a lot about D 2.0 . (This is a pure slate rewriting of D.) So far, I liked what I see - a lot of pragmatic and wise decisions. Now I want to know a little more and want to know if it is ever possible to do the following:
- Enter the code in D 2.0. (Perhaps this is a well-defined subset of D 2.0.)
- Compile the code from 1.
- Get Javascript source code from compiler.
In general, I would like to have a D 2.0 compiler with a backend capable of generating Javascript.
So my question has two parts:
- Does such a compiler already exist?
- If such a compiler does not exist, and if I decided to implement it, where would it be best to start?
In context, the reason I would like to dwell above is that I could implement a bunch of business logic in D 2.0 and then use this business logic in pure Javascript (this is not Flash / Silverlight / Java). Web Application.
Update
I had three answers, two of which were related, and the other was not and therefore are ignored.
@FeepingCreature believes this will never happen because "it is too incompatible with the D environment." I am curious to know what this means and asked.
@Nekuromento, by contrast, points out that this is already theoretically possible using LDC, followed by LLVM Javascript. I checked both links. LDC support for D 2.0 looks like work. But I guess he will get there at some point. LLVM Javascript is neither optimized nor optimized, but it shows that they work. Therefore, I think this is enough to be useful, at least.
Update 2
OK - this seems like the best solution to date.
- LDC call. (@Nekuromento) LDC integrates Digital Mars interface with LLVM backend.
- Follow the output from 1. through the LvvM Javscript backend. (@Nekuromento)
- Follow the output from 2. although Closure (@BCS)
I will choose the best answer pretty soon, but I would like a more informed opinion.
Update 3
More info on why I want to do this.
Here is a concrete example of one project that I want to implement. It will be a geometric modeling library, which is probably written only by me, takes several years to write, and ends with approximately 100,000 lines of code. I would like it to contain errors as close to zero as possible, and therefore I do not want to implement it in Javascript. I would like it to run on the server, on the desktop and in the browser. (In βin the browser,β I mean without the help of any plug-in, such as Flash, Silverlight, or Java.) The truth is, the code in the browser running on Javascript is here to stay for a short while. Projects will increasingly need a strategy to solve this problem.
Update 4
I was hoping for a few answers, but did not receive them. Good, never mind. Thanks for all the reviews, including @dsimicha, stimulating comments. (I hope itβs normal to sometimes disagree technically, while at the same time maintaining civil status.) I accepted @Nekuromento's answer.