Hacker News new | ask | show | jobs
by johnchristopher 2398 days 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.

2 comments

This 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).

The art of language design is staying true with its own established patterns. C# fights this battle with primary constructors or combined patterns.
That’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.
Also, 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.
> 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.

No, 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.