Liam, this is incredible ! I thought it might be useful for you to incrementally see how someone in industry would review or change this code, so here's a little code review via video: https://youtu.be/UkVOrcS--04 We very incrementally build up to the final code, which can be found here: https://gist.github.com/stevekrenzel/b490564bf1c7f98e232a6c8... Hope you find it helpful!
If you would start a channel where you review code of random public repos I would definitely subscribe. Well done.
Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node
221–230 of 304 posts
Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node
#222Liam, this is incredible ! I thought it might be useful for you to incrementally see how someone in industry would review or change this code, so here's a little code review via video: https://youtu.be/UkVOrcS--04 We very incrementally build up to the final code, which can be found here: https://gist.github.com/stevekrenzel/b490564bf1c7f98e232a6c8... Hope you find it helpful!
Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node
#223Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node
#224Liam, this is incredible ! I thought it might be useful for you to incrementally see how someone in industry would review or change this code, so here's a little code review via video: https://youtu.be/UkVOrcS--04 We very incrementally build up to the final code, which can be found here: https://gist.github.com/stevekrenzel/b490564bf1c7f98e232a6c8... Hope you find it helpful!
If you would start a channel where you review code of random public repos I would definitely subscribe. Well done.
Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node
#225Congratulations! I showed your project to my 12 year old son who has just started to learn programming (in JS no less!) and his jaw dropped. In addition to being a programmer, you are now a role-model. Really well done.
Thanks a ton! Tell your son that it took me a while, and a lot of work, but it feels great to finish something (there are a lot of projects that I don't finish...). I began learning using Scratch a long time ago. They even featured me last year (the project was a solar system in which I used sine and cosine to calculate the rotation of the planets). I then used blocklike.js to move to JS. I watch a lot of YouTube vid…
Having a lot of projects that you don't finish is completely normal, so don't worry about that.
Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node
#226Liam, this is incredible ! I thought it might be useful for you to incrementally see how someone in industry would review or change this code, so here's a little code review via video: https://youtu.be/UkVOrcS--04 We very incrementally build up to the final code, which can be found here: https://gist.github.com/stevekrenzel/b490564bf1c7f98e232a6c8... Hope you find it helpful!
(rule & (1
You could just do: (rule >> i) & 1
Otherwise it was a good review! I'd probably also extract parts of this long line so it's not as cumbersome to read: return state.map((item, i) =>
rules[((state[i - 1] || 0) * 4) + (item * 2) + (state[i + 1] || 0)]
);
to return state.map((item, i) => {
const prevItem = state[i - 1] || 0;
const nextItem = state[i + 1] || 0;
return rules[(prevItem
It also uses bitwise operations instead of arithmetic, even though they are equivalent in this context, simply because we are effectively operating on arrays of bits.Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node
#227Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node
#228Liam, this is incredible ! I thought it might be useful for you to incrementally see how someone in industry would review or change this code, so here's a little code review via video: https://youtu.be/UkVOrcS--04 We very incrementally build up to the final code, which can be found here: https://gist.github.com/stevekrenzel/b490564bf1c7f98e232a6c8... Hope you find it helpful!