Live data from Hacker News

Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node

bitbucket.org

181–190 of 304 posts

Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node

#181
post #167

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!

Thanks Steve!

I watched your video and although I don't understand everything, I learned a lot. Separating my program into functions is a good idea. Your video clarified the map function for me.

Through your video, I understood that I was running code multiple times, when it only needs to run once (how I parsed my rules was one of these instances that you went over in your video), so thanks for pointing that out.

Again, thank you so much for taking the time to review my code. I really enjoyed your feedback.

Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node

#182
post #167

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.

+1, reminds me of Destroy All Software

Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node

#183
post #167

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.

+1 Please and thank you

Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node

#184
post #167

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.

Thanks for the kind words! Will definitely consider.

Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node

#185
post #167

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!

Steve, it is outstandingly awesome that you did this and also how you did this! Thanks.

Thank you, much appreciated!

Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node

#186
post #167

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!

Kudos for taking the time for doing this! It's places like these where the HN community really shines. Thanks a lot!

Thanks! I really enjoyed making it. HN has been such a huge part of my life over that last ~10 years that it's truly the least I could do.

Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node

#187

Nice work. I'm not a JS expert but I think I saw a bug. Inside of animate() you are calling setTimeout() to automatically call animate repeatedly but this is also calling setTimeout() every time animate runs but setTimeout() should only be run once. You should be able to take setTimeout(() => { animate(); }, 100); and paste it over animate() on the last line

What you mean is setInterval and does work well for synchronous execution. His approach is correct and would even work if the animate function is asynchronous as the next tick gets scheduled at the end of animate function execution.

Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node

#188
post #167

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!

Thanks Steve! I watched your video and although I don't understand everything, I learned a lot. Separating my program into functions is a good idea. Your video clarified the map function for me. Through your video, I understood that I was running code multiple times, when it only needs to run once (how I parsed my rules was one of these instances that you went over in your video), so thanks for pointing that out. Aga…

So glad to hear, Liam! Was a pleasure to put it together.

Good luck, and feel free to reach out if you get stuck on anything.

Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node

#189
post #58

Hey looks good :)! Just a few things you might not know about: Google String.prototype.padEnd. It’s built in to JS and should be able to replace your zero fill function. And instead of mutating the ruleSet array you should be able to use Array.prototype.map like this: const ruleSet = zeroFill(8, rules.toString(2)) .split('') .reverse() .map(item => parseInt(item, 10)); And you can clone arrays like this, instead of u…

I think it is good he's learning to do the loops by hand first. It's good to have an understanding of algorithms first when learning to code.

In fact this "you should never code FizzBuzz yourself, just use util.FizzBuzz(n) to print the first n iterations" mentality probably contributes to the surprising number of software developers who can't code.

Re: Show HN: I'm 12, learning JS, and wrote Wolfram's cellular automaton in Node

#190
post #187

Nice work. I'm not a JS expert but I think I saw a bug. Inside of animate() you are calling setTimeout() to automatically call animate repeatedly but this is also calling setTimeout() every time animate runs but setTimeout() should only be run once. You should be able to take setTimeout(() => { animate(); }, 100); and paste it over animate() on the last line

What you mean is setInterval and does work well for synchronous execution. His approach is correct and would even work if the animate function is asynchronous as the next tick gets scheduled at the end of animate function execution.

Ah yes, you are right. Got those mixed up.
Post reply on HN