8

Sometimes I feel like I'm a dumb worthless retard, a pathetic excuse of an ape with no reason left to live this pathetic farce of a life.

But then I remember there are people who enforce "prefer-const" in their codebase, and there I realize that if those people are alive and well I must deserve something too, and thus I hold on.

I will outlive you. I will remove that dumb directive from your linter config and I will commit that to master. I care not what happens next.

Comments
  • 2
    Why not prefer const?
  • 1
    Constexpr is where it's at.
  • 0
    @black-kite

    When I use "const" I'm making a promise: you can change this, but you probably shouldn't. And you can expect this thing to always have this value

    Take pi. You can technically change it: maybe you don't want to stick to flat 2d surfaces but for most cases it's a constant value of 3.14 and const reflect that; at writing\compile time you know what that is. And you probably don't want to touch it.

    Now, take the result of some kind of operation, like a fetch from a server. I did never reassign it, but why should you expect this value never to change? It's some values from some external source I don't even know, you could drop there whatever and still be fine.
    With prefer-const you're forcing me to declare it with const -that is, making sure nobody changes it- when there's no actual requirement to do so.

    Which defeats the whole point of const, that is to communicate "this is a constant value and should be treated as such"

    This guy gets it https://jamie.build/const
  • 0
    Isn’t that the whole point of being able to choose between “let” or “const“?
  • 0
    I say let's deprecate const & let and just use var everywhere so we don't need to have arguments about memory allocation slot pronouns
  • 0
    @ostream here you go:

    const constants = {};
    Object.defineProperty(constants, 'PI', { value: Math.pi(), writable: false })
Add Comment