Experiments with emscripten and D

Gambler fake at feather.org.ru
Sun Aug 18 03:45:21 PDT 2013


On 8/18/2013 12:52 AM, deadalnix wrote:
> On Saturday, 17 August 2013 at 16:43:14 UTC, Piotr Szturmaj wrote:
>> What happens when you forget a semicolon or a comma? Or make some
>> typos? It silently breaks. I don't care if there are tools to help
>> with it. It's still a mess. Did you see WAT
>> (https://www.destroyallsoftware.com/talks/wat) ? If not, please do.
>> Here are some examples of JS "additions" which WAT demonstrated:
>>
>> [] + [] // yields empty string
>> [] + {} // [object Object]
>> {} + [] // 0
>> {} + {} // NaN
>>
>> Seriously, WTF!
>>
> 
> I could explain, but I'm not sure you are interested. The ambiguity on
> that one come from {} being either an object literal or a block statement.

This is what slays me about JavaScritpt community. There is always
someone who says "I can explain!" and starts posting type conversion
trivia. Which is irrelevant, because no one cares *how* exactly this
happens. What's important is *why* and there are no graceful
explanations for that. JavaScript's type system is a bloody mess.

[0, -1, -2].sort() returns [-1, -2, 0].

["1", "2", "3", "4", "5", "6", "7", "8", "9"].map(parseInt) returns [1,
NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN].

2147483648 | 0 returns -2147483648.

But I'm not even sure that's the worst part of the language. I think the
absolute worst aspect of JS is that it's missing huge chunks of *basic*
functionality, so everyone invents their own "design patterns" by
abusing the hell of what's available.

Actual example from StackOverflow with 145 upvotes:

var CONFIG = (function() {
     var private = {
         'MY_CONST': '1',
     };

     return {
        get: function(name) { return private[name]; }
    };
})();
alert(CONFIG.get('MY_CONST')); //I invented constants!!!

So in the end every project ends up using their own little set of ugly
hacks that's both hard to read and differs from whatever everyone else
is doing.

> I feel pretty confident I can do a wat speech for D.

Not with such succinct, hilarious, obviously broken examples, I bet.

>> Obviously, you can't share every possible code. It's about sharing the
>> cross cutting parts. Imagine an application with a server, web
>> frontend and desktop frontend. With shared codebases, you could write
>> one client code. Just use the same abstractions for the web and for
>> the desktop. Then you can create similar interfaces from the same
>> codebase. It's a huge win. Duplicating efforts is tiresome, error
>> prone and obviously takes time.
>>
> 
> It has already been done, but didn't caught up. Actually I can't even
> find theses project in google, so I guess ti was a compete fail.
> 
> It worked, but cause many problem, especially securitywise.



More information about the Digitalmars-d mailing list