On 2012-03-01 19:04, Ary Manzana wrote:
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.

I really miss static typing sometimes in my day to day work (Ruby, JS, ...).

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

D's new lambda syntax is way more superior than the one in JS. Most of the times I would like to be able to specify types in function declarations.

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).

True.

4. If you write JS you can debug it in the browser. No need to track
back to the original source code.

True. But if you're compiler is good enough that won't be a problem, i.e. CoffeeScript.

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/

Already doing that. But if you're doing that you would most likley pre-compile it and have the same problems as 3. and 4.

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.


--
/Jacob Carlborg

Reply via email to