📚 node [[2023 10 27]]
  • Friday, 10/27/23 ** 14:03 Using javascript in my free time - I don't miss macros or type systems or good autocomplete (that's what AI is for). I miss immutable variable aliasing.

JS, like other functional language, encourages creating intermediate values that do not mutate previous results - but you can't update the existing value without mutating it.

Common pattern with 'let's in functional languages is to redeclare the current variable you're working on.

i.e.: value1 = a; value2 = change(value1); value3 = change(value2);

I never want the intermediate values for the end state because all I'm doing is applying pure transformations to input, but those intermediate values are excellent for print debugging. I might also want to split values up and merge them back together.

I AM SO STUPID you can use 'let' to do this but we have an eslint rule set up to avoid it

This reveals that (1) I should learn more about javascript semantics and (2) that I should learn to use a debugger instead of handling all of this intermediate value business

but also - redeclaring, not mutating, is a good default, and i wish i could do it with const

lol 'const' allows this too

ah, js does not allow you to alias function arguments!! ** 14:24 I like dynamic languages because you can accept whatever input you want as an argument and normalize it

I keep getting confused; is this a path? a string? a relative path? an absolute path?

Type systems can't capture that complexity without a lot of pushing types around. In some cases, they have to use dependent type systems to capture these semantics, like ensuring a number is above such and such value.

It's okay to sanitize incorrect inputs because users are stupid and make different assumptions about arguments they can provide! Strong types require the caller of a function to be very precise with their usage of the function. Weak types require the implementer of the library to consider all of the possible usages of the function and accomodate them. I like the latter because it's really cool to make things as easy to do as possible and as expressive as we want.

📖 stoas
⥱ context