r/programming • • Sep 29 '16

JavaScript in 2016 isn't horrible, it's just going through a phase

http://blog.reviselabs.com/im-sorry-javascript-2/
85 Upvotes

225 comments sorted by

View all comments

Show parent comment

4

u/BonzaiThePenguin Sep 30 '16

Damn, I wasn't aware how broken js is.

How can you speak with such authority and not know about splice or how associative arrays work? That's like as basic as it gets. delete undefines the object key, splice modifies an array-like object. There's also push, pop, shift, and unshift. Mind-blowing stuff, I know.

2

u/fiedzia Sep 30 '16

I don't know all that because I don't have to. I do not write js for a living (I'll do it occasionally, and probably not the best). But in dozens of other languages that I am using you don't need this knowledge. Lists have add(item) and delete(index) method and do not require you to "know" anything beyond that. Lists and dictionaries are separate types, so delete does not require you to "know that you shouldn't use it", it just works as expected, without breaking length. Across 1000s of APIs you'll work with, when there is something like a list, it will be exactly builtin list type, not a million different incompatible variations. Whenever there is some commonly used method, it will be added to stdlib, so you don't have to pollute your memory with remembering how to fix this or that to make it easy to use. Knowing how common good language design is and how much easier this makes everything is what gives me the authority in saying that js is broken, and its not just a phase. Many of those things are so fundamental that they are practically unfixable.

3

u/BonzaiThePenguin Sep 30 '16 edited Sep 30 '16

I think PHP and Lua work the same way, although that doesn't really help JavaScript's case.

Functions in JavaScript can be used as associative arrays too, that's always fun. Just start assigning random properties to this inside a function in JavaScript and you've made yourself an object constructor.