2 ms·
Out of curiosity (if you're at liberty to say), what has bit you? I do Node / TypeScript basically all day these days, and I'm probably too close into the fore
by shadowgovt 5y ago
Out of curiosity (if you're at liberty to say), what has bit you?
I do Node / TypeScript basically all day these days, and I'm probably too close into the forest anymore; I'm wondering if other people are getting bitten by things that I just roll right past because I'm used to the pain.
The extremely weak (and frankly incorrect) Date handling that's built into JavaScript is the first thing that comes to mind.
- lliamander 5y agoFair question, here's a few: - object methods cannot be passed as arguments to a function or another method like regular functions can because they lose their 'this' pointer. - array.sort() is broken. It does the sort in-place and converts the elements to strings before sorting. - const doesn't support separate declaration and assignment. This makes it harder to conditionally decide what to assign to a variable while still making it const. - number types. - the fact that you have to use '===' for the normal understanding of equality - Date handling could be better - NPM has a number of problems, including default behavior of updating your dependency versions.
- shadowgovt 5y agoThat's a good list, and I was right; I've been at this so long I've forgotten that most of those are 'WAT' to the average user. Regarding `object methods cannot be passed as arguments to a function or another method like regular functions can because they lose their 'this' pointer.`: yeah, the fact that JS objects are actually kinda weird li'l things is frustrating. There are nowadays two ways to handle that: - referencing the object in a closure binds the object instance. `(x) => foo.bar(x)` will do the right thing - there is an explicit bind operator, so you can do `myCallbackTaker(instance.myFunction.bind(instance))` ... but I agree that in a better language, you'd be expected to do neither of those things.
- lliamander 5y agoThanks for the tip about binding the object instance. Just to share an experience on the other end, I worked with Erlang several years back. While it was a harder language to learn, every new thing I learned about the language gave me the impression that the language designers did the right thing. Don't get me wrong, I'm having fun with my current Typescript/NodeJS stack at work, but if I was building my own stuff it would absolutely be on the Erlang VM.