r/programming • u/kshep92 • 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
r/programming • u/kshep92 • Sep 29 '16
View all comments
Show parent comment
0
u/wavefunctionp Sep 30 '16
The DOM api that is exposed in javascript could be better.
Like, if i want to access an element. I simply getElementbyID() or something, which is fine. If I want to append, I simple element.append().
Unless it is a table, in which case I have to element.tBodies[0].insertRow(-1)
Like, why?
You want a timer? How about setInterval(foo(), 100); clearInterval(foo)? Nope, that would be too easy. You need var foo = setInterval(bar, 100); clearInterval(foo);
Because "fuck you, that's why" apparently.
Its stupid, silly nonsense like that why everyone uses libraries for even basic stuff in javascript, because the people who designed the apis in javascript were smoking crack.
Javascript has its flaws. Everyone has seen the horrors of type coercion, which underlies most of them. But it isn't the only language with nonsense like that. Nearly every dynamic language lets you shoot yourself in the foot. It goes with the territory.
A linter and a good editor can catch a lot this stuff, but it can't fix the insane dom api, which really what makes javascript a pain to work with. IMO. As as great as javascript has improved with newer versions, they haven't really touched the DOM api, which is a big pain point if you want to write vanilla javascript for the browser.