D to Javascript converter (a hacked up dmd)
Ary Manzana
ary at esperanto.org.ar
Thu Mar 1 10:04:35 PST 2012
On 2/29/12 2:34 PM, Alex Rønne Petersen wrote:
> On 29-02-2012 18:32, Andrei Alexandrescu wrote:
>> On 2/26/12 9:51 PM, Adam D. Ruppe wrote:
>>> https://github.com/downloads/adamdruppe/dtojs/dtojs.zip
>> [snip]
>>
>> That's interesting. So the idea is to make an entire subset of D
>> convertible to Javascript?
>>
>> What use cases do you have in mind?
>>
>>
>> Andrei
>>
>
> Avoiding writing JS directly in web apps comes to mind.
>
I think it's cool you can convert D to JS, but I don't see why anyone
would want to do it.
1. JS is a superior language: variables are dynamic and are not bound to
just one single type during their lifetime. JS objects can store any
property.
2. JS funcions are much easier to write (no need to declare types) and
also to pass around (no need to write "&"). If you'd like to annotate
variables, you could use Closure:
https://developers.google.com/closure/compiler/docs/js-for-compiler
3. With JS you don't have to compile and run your code (well, I guess
you could make something smart in D for that).
4. If you write JS you can debug it in the browser. No need to track
back to the original source code.
5. If you don't like JS syntax or verbosity, you can use CoffeeScript,
which is just a syntax rewriter, not a language/paradigm shift:
http://coffeescript.org/
6. Javascript objects have some built-in properties that are different
from D. So implementing those in D would make their performance worse
(but you can always hard-code those functions into the compiler and
translate them directly to their JS equivalent).
The good thing about writing in D is that you could probably get some
IDE for autocompletion and such. You might also like to type things
instead of using dynamic types.
More information about the Digitalmars-d-announce
mailing list