On 01-03-2012 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.

You're arguing with a crowd gathered around a statically typed language. I think we can predict what this argument will lead to. :)

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

See the above.

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

? The D -> JS converter just translates it. It's no different from running e.g. the CoffeeScript compiler.

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

Valid argument. Maybe we can make the D -> JS converter help in some way here?

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/

Don't even get me started on the horrible "features" in CoffeeScript. The guy who wrote the language literally had no clue what he was doing (he admitted to reading some "make your own language" book), and it isn't much better than JavaScript in terms of odd behavior and weird design decisions.

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

Can you be a little more specific here?


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.

To be fair, excellent JS IDEs exist already; Visual Studio has great JS auto-completion, and ReSharper enhances it a lot too.

--
- Alex

Reply via email to