3 ms·
I am diving back into node lately and it's really annoying to decipher the async and promises styles that are peppered with different anonymous function styles.
by johnchristopher 7y ago
I am diving back into node lately and it's really annoying to decipher the async and promises styles that are peppered with different anonymous function styles.
I too stick to the most explicit version (function($foo)).
It's the same for command line arguments, I have an easier time remembering words (--preserve-permissions for instancem --volume, etc.) than letters if I don't use the interface enough.
- Cthulhu_ 7y agoThis is a problem in a lot of programming languages nowadays; they borrow features and syntax from other languages without those new features superseding others, and without providing a mechanism to force one syntax over the other. So that's why we now have half-assed OOP in Javascript, we have Scala which is basically all programming languages ever, etc. Meanwhile, Go is still fighting a lot of requests to add language features, knowing full well the complexity added to the compiler (and more importantly the cognitive overhead for developers).
- oaiey 7y agoThe art of language design is staying true with its own established patterns. C# fights this battle with primary constructors or combined patterns.
- earthboundkid 7y agoThat’s a weird choice. Arrow functions in JS don’t redefine ‘this’ like regular functions, so if you don’t use them, you waste time working around the redefinition.
- hombre_fatal 7y agoAlso, if you default to `() => ...` for anonymous functions, then you can reserve anonymous `function() { ... }` for the rare times you actually want peculiar `this`. Same reason it's nice to default to `const` so that `let` becomes a signal for the bonus feature of reassignment.
- earthboundkid 7y agoNo, const inside of a function is a complete waste of time. There has never been a bug that would be prevented by const inside a function.
- johnchristopher 7y ago> Same reason it's nice to default to `const` so that `let` becomes a signal for the bonus feature of reassignment. Code documentation should be clear and concise, not to be deciphered through the code author's take on the meta meaning of reserved words.