Live data from Hacker News

For modern development Javascript indeed is a shit language

live.julik.nl

31–40 of 243 posts

Re: For modern development Javascript indeed is a shit language

#31
> They are not solvable by making a new ECMA spec.

As it turns out, many of the issues outlined are not only very much solvable by making a new ECMA spec but either already solved in ES5 or solved in ES6.

> JS has callable attributes

> This is a shitty design decision

I strongly recommend not following the provided link, which is basically inane, uses the term "slots" in a rather disturbing manner and makes completely incorrect assertions e.g.

> Self [is] slot-based. This gives one substantial advantage: not having to specify that you want to move a block of code as a value explicitly. So you can do, for example in JS

      // boom! we transplanted a method
      someVar.smartMethod = another.otherMethod;
to my knowledge, you most definitely can not do that in such a manner in Self. Slots manipulation in Self can only be done through primitive messages (e.g. `_AddSlots:`, which takes an object whose slots should be copied into the receiver).

> Hobjects are unusable for stable keys

> The mixup between objects and hashes is also a very bad idea, because it defies the premise that objects can have metadata on them - which alllow you to establish a rudimentary type system or at least any kind of introspection.

Magnificent baseless assertions. Javascript allows for object metadata through the prototype, or through properties (Object.defineProperty/Object.defineProperties) which — amongst others — allow setting non-enumerable properties. ES6 also introduces the concept of names. I'm not saying maps-as-objects is great, but I am saying these assertions are 1. wrong and 2. nonsensical.

> Fobjects are unusable for type systems since an object does not carry any type information.

> This one is a biggie. Even in the Ruby world, where everything is happily quacking like a duck, we often use the Object#class to get information about an object.

In ES5, the exact same behavior is provided by Object.getPrototypeOf providing access to the internal [[Prototype]]. Most implementations also provide direct access via the __proto__ property, which IIRC ES6 standardizes. And of course the `instanceof` operator has been there since ES3, but that's only ~13 years ago.

> Nothing will happen. Since ojects are hashes[...], our constant with the wrong key will be undefined, and will happily bleed into the callee. This makes stack traces huge.

'Nothing will happen' (and the related "What is the error that you will get if MyApp.Views.WidgetView is not defined yet? undefined is not a function of course! [...] And why? Simply because everything is a hash and the language is incapable of doing any kind of introspection." later) and 'objects are hashes' have nothing to do with one another. Hashmaps does not actually require unmapped keys to return nil or undefined. Javascript does because it is shit. Same for Ruby or Java. Python does not have that issue, accessing an empty key will raise a KeyError.

> and the language provides zero facilities for constants

All runtimes but MSIE (unless they've added it in IE11) already implement `const`, and it's standardized in ES6.

> Callback hell

> [...] In a normal situation this would have been fixed simply by adding a wait primitive to the language which would schedule the events when the result is still being fetched.

You mean, something like ES6's yield?

> Terrible exception handling

No objection there, javascript may well have a worse exception handling than Go, a language whose users try very hard to make others believe doesn't have exceptions in the first place. At least runtimes are finally trying to generate callbacks worth reading.

Not that this help when mixing with async, as your final traceback will lack 90% of the necessary context.

Re: For modern development Javascript indeed is a shit language

#32
The webpage is difficult to view in the Android Browser (though not Opera Mini) due to the overlay at the bottom.

http://m.imgur.com/9eOKqJZ

On that note, at what resolution, if any, do embedded code snippets from GitHub and the like stop getting get cut off on the mobile? At 800x480 they get cut off even in landscape mode.

Re: For modern development Javascript indeed is a shit language

#33
post #15

"JS has callable attributes, Hobjects are unusable for stable keys...object does not carry any type information, Null everywhere, since ojects are hashes" I find most of the problems listed are related with dynamic type system of JS. These all can be solved most easily by a statically typed language. Therefore the debate mostly is between static vs dynamic typing.

I would also argue that expecting an object to carry type information is an unfair expectation of a non-object-orientated language.

Re: For modern development Javascript indeed is a shit language

#34
post #27
post #5

I'm very glad JavaScript is the language of the web. It has a combination of things I like that I don't find in many other languages: * lexical scope * first-class functions * prototypal inheritance

Not many languages have prototypal inheritance, but most modern languages have first class functions these days. And what sane language uses dynamic scoping?

Do you mean lexical scope? Scheme has it and it is awesome. If you think it is not a good feature you should grab a SICP and see the magical stuff you can do with it.

Re: For modern development Javascript indeed is a shit language

#35
post #11

Sadly I agree, you can just start with this: > [1,10,5,-15,-2,4].sort(); [-15,-2,1,10,4,5] And yes saying "oh but it is because it has weak types" doesn't excuse it, it is broken and that's that. Naming the brokeness with a label or showing why historically it is there, doesn't fix it. On the other hand they do have nice closure support, I do like some of that. But in large, the language makes me angry every time I h…

> And yes saying "oh but it is because it has dynamic types" doesn't excuse it

It has nothing to do with dynamic types[0]. It has to do with

> If compareFunction is not supplied, elements are sorted by converting them to strings and comparing strings in lexicographic[0]

period end of the story. You might argue it's a shitty default, but please argue against reality, not what you (wrongly) believe it is.

[0] this is the MDN translation, the exact specification is steps 14 to 18 of the SortCompare abstract operation, defined in ECMA-262 5.1 15.4.4.11 "Array.prototype.sort (comparefn)":

    13. If the argument comparefn is not undefined, then
        a. If IsCallable(comparefn) is false, throw a TypeError exception.
        b. Return the result of calling the [[Call]] internal method of comparefn passing undefined as the this value and with arguments x and y.
    14. Let xString be ToString(x).
    15. Let yString be ToString(y).
    16. If xString  yString, return 1.
    18. Return +0.
[0] your edition to "weak types" is just as wrong as the previous version I quoted was.

Re: For modern development Javascript indeed is a shit language

#36
post #22

It's interesting to see so many people say "JS is great and we used it to build X" on one side and people who hate JS on the other side. Obviously Node (and JS) has some things that it is strong in. People use it to build those things. Good developers won't use a tool in their box which is inferior to another tool they can use effectively. In between, there is a lot of room for "good enough" where tools overlap. I th…

>Obviously Node (and JS) has some things that it is strong in. People use it to build those things. Good developers won't use a tool in their box which is inferior to another tool they can use effectively. In between, there is a lot of room for "good enough" where tools overlap. People use JavaScript not because it's good but because it's the only option to develop in a browser. Having the same language on the client…

> Having the same language on the client and the server is a very strong point

Only if you're so incredibly strapped for cash that you can't hire real devs that can pick up another language in a day or two.

Almost every language used commonly on the serverside is vastly preferable to js.

This whole "well, it's THE SAME" benefit simply isn't. It's a red herring.

I'm convinced the whole ecosystem has sprung up because of hordes of terrible copy-paste browserside devs that don't actually fully understand what they're doing in js, who resultantly would be incapable of building anything serverside in another language at all because their overall comprehension of programming is marginal at best.

Anyone not stupid or insane just learns ruby or python or scala or go or even php or .NET.

PS: cue replies from all dozen people on the whole internet who know pointer math and still like coding webapps in js, who don't realize that I'm not talking about the 12 of them but the 12,000 who are doing the js/node problems on codeacademy this instant.

Re: For modern development Javascript indeed is a shit language

#37

The webpage is difficult to view in the Android Browser (though not Opera Mini) due to the overlay at the bottom. http://m.imgur.com/9eOKqJZ On that note, at what resolution, if any, do embedded code snippets from GitHub and the like stop getting get cut off on the mobile? At 800x480 they get cut off even in landscape mode.

The same happened on a windows phone

Re: For modern development Javascript indeed is a shit language

#39
post #11

Sadly I agree, you can just start with this: > [1,10,5,-15,-2,4].sort(); [-15,-2,1,10,4,5] And yes saying "oh but it is because it has weak types" doesn't excuse it, it is broken and that's that. Naming the brokeness with a label or showing why historically it is there, doesn't fix it. On the other hand they do have nice closure support, I do like some of that. But in large, the language makes me angry every time I h…

[deleted]

Re: For modern development Javascript indeed is a shit language

#40
post #11

Sadly I agree, you can just start with this: > [1,10,5,-15,-2,4].sort(); [-15,-2,1,10,4,5] And yes saying "oh but it is because it has weak types" doesn't excuse it, it is broken and that's that. Naming the brokeness with a label or showing why historically it is there, doesn't fix it. On the other hand they do have nice closure support, I do like some of that. But in large, the language makes me angry every time I h…

    > [1,10,5,-15,-2,4].sort(function(a,b) {return a > b})
    [ -15,
      -2,
      1,
      4,
      5,
      10 ]
    
    > [1,10,5,-15,-2,4].sort(function(a,b) {return ""+a > ""+b})
    [ -15,
      -2,
      1,
      10,
      4,
      5 ]
Perhaps .sort was initially designed to do something else, like sorting strings, rather than integers.
Post reply on HN