D to Javascript converter (a hacked up dmd)

Nick Sabalausky a at a.a
Thu Mar 1 21:52:10 PST 2012


"Ary Manzana" <ary at esperanto.org.ar> wrote in message 
news:jiodnj$ric$1 at digitalmars.com...
>
> 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 "&").

Are you insane or just masochistic? ;)

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

Meh. I've done a lot of web work where "no compile" is common, and I've 
never seen it as really being that big of a deal (unless you're using 
something like C++ that takes ages to compile). It's an overrated selling 
point of such langauges, IMO, much like "Our langauge doesn't require 
semicolons!" Meh, so what? Trivialities.

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

Not a bad point. Although Adam's suggestion does help mitigate it.

> 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/

Bleh. I hate JS with a passion and I'd still much rather use straight JS 
than CoffeeScript. CoffeeScript has a few nice bits of sugar, but the basic 
syntax is just plain horrid. At least plain JS doesn't have that 
indent-syntax abomination that's so popular these days.

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

If you're doing any non-trivial JS, you can *expect* it to be slow, period. 
This is like saying "I drive a $100k sports car with 600 horsepower and yet 
I care about my gas mileage". Just kinda goofy.




More information about the Digitalmars-d-announce mailing list