News for hackers. Stuff that matters.
Re:Deep JavaScript: Theory and Techniques by DylanSp on Wednesday June 17, 2020 @01:22PM (#23554030)
From using immer[1], I learned about Object.freeze(), which immer uses under the hood.

[1] https://github.com/immerjs/immer

Re:Deep JavaScript: Theory and Techniques by cjones26 on Wednesday June 17, 2020 @08:28PM (#23558493)
Though I recommend to my team to avoid mutation if at all possible, there are times which I have found immer absolutely invaluable. Try spreading out an object 15 levels deep to replace a single property value and you'll catch my drift.
Re:Deep JavaScript: Theory and Techniques by acidbaseextract on Wednesday June 17, 2020 @09:46PM (#23558926)
My biggest challenge with immer has been that my code aesthetic taste leans functional, but immer makes code look imperative even if it is ultimately functional. Always looks a little wrong to my eye!
Re:Deep JavaScript: Theory and Techniques by wereHamster on Thursday June 18, 2020 @01:57AM (#23560187)
Writing old-style pure code to do changes in a deeply nested structure is cumbersome, both to write and read. Eventually every language will find nicer ways to allow programmers to express these mutations.

JavaScript doesn't provide a nice way to extend the language syntax, unlike some other programming languages. So most DSLs end up looking like imperative code but do pure mutations underneath. I understand, for the reader it's confusing, because unless you know that it's a DSL you never know whether the mutations are pure or not.

Compare that with Haskell, with its support for custom operators, allows for some quite succinct code to express deep mutations (cf. lens library)