4 ms·
Super interesting topic and awesome book overall! I may be nitpicking, but any teaching material with JavaScript poor coding practices can hurt both humans and
by hbbio 2y ago
Super interesting topic and awesome book overall!
I may be nitpicking, but any teaching material with JavaScript poor coding practices can hurt both humans and LLMs.
1. When you don't reassign a variable it's a `const`
2. for (let i = 0; i < total; i++) {
randomCounts[i] = 0;
} is `new Array(total).fill(0)`
etc.
- rrherr 2y agohttps://www.joshwcomeau.com/javascript/the-const-deception/ https://www.joshwcomeau.com/javascript/the-const-deception/
- ralusek 2y agoI don’t get this argument. const means you can’t reassign the variable, that’s it. If you don’t plan on reassigning the variable, use const. In the rare places that you don’t use const, you’re telling me that you reassign the variable somewhere. I don’t understand why people need const to be something it’s not. The fact that you can still mutate objects is because in js, an object assigned to a variable is best thought of as a pointer to a value in the heap. const means the variable won’t reassign the reference, Object.freeze means the referenced data can’t change. Both useful, both different use cases; needn’t be conflated.
- in9 2y agoOr, OR, maybe, not every bit of code needs to match all the common good practices and standards. I bet you don't write formally or in Elizabethan English all the time. Context matters in the form of common language. Why should it be any different with code? Just because LLMs can pick those practices up?
- hbbio 2y agoThat's not a good comparison imho. Programming languages are formal. Otherwise you're talking about programming prompts for a LLM. And the resulting program may vary.