Live data from Hacker News

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

bitbucket.org

271–280 of 304 posts

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

#271
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…

This whole interaction is really reaffirming my faith in humanity. You guys are awesome!

Liam -- this response is just as impressive as the code that you wrote. You're obviously very smart, but that isn't good enough on its own. I've seen very-smart people who aren't open to critique, who get defensive rather than take the opportunity to learn new things. They don't get very far in life. On the other hand, the attitude you're showing here is tremendously valuable, and will serve you incredibly well throughout life. Never let yourself grow out of it!

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

#272
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!

Instead of this: (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 u…

Thanks for the edits! I can't change the video, but did mention that both of those lines are a little clunky. I did update the gist though! Much cleaner.

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

#273

Earlier quoted context omitted.

Instead of this: (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 u…

I like to break expressions across multiple lines, and line up any patterns that are repeated, so your eye can easily scan up and down and obviously see what's the same, and what's different. For example, instead of: var length = Math.sqrt((x * x) + (y * y)); You can go: var length = Math.sqrt((x * x) + (y * y)); That way you can see the similarity of squaring x, and squaring y. But breaking up the multiplications be…

it infuriated me that Google's style guides forbid this kind of formatting. Anytime someone else tried to get them to allow it it was shouted down as ASCII art

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

#274
Congratulations!

Are you familiar with code golf? If not, I recommend it. In Code Golf, the objective is to complete a programming task in the shortest program possible, measured in bytes. While doing so, you really learn about the nuances of your language and its obscure features.

When I was about your age, I joined the code golf community at Stack Exchange, and since then my JS skills and general programming skills have improved greatly. I hope that you would find it to be useful too.

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

#276
post #267
post #201

Earlier quoted context omitted.

JS is a bad language but it's the easiest environment to set up. Back in the day we started with Qbasic not because it is a good language but because that was easy to set up, we all had it and our friends had it and our school computers had it. And JS is less bad a language than Qbasic.

That's debatable. It's not as if downloading Python and making your first app will take you more than a few seconds, minus download time. Set up is rarely an issue, once you set up a language even as complex as C++ its completely automated. You press a button and magic happens. If the biggest selling point of a programming language is that it comes preinstalled with the OS of your choice, its not much of a selling po…

It does make a difference especially to a beginner or a child. You might not have admin privileges at your school or your friends may not be able to install those tools so you can't show your work.

But you can hack away on any computer with a browser.

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

#277

Earlier quoted context omitted.

Would you please provide an example on how one proceed with T shaped learning and expertise?

I work in cloud, and one of the things I look for when recruiting solution architects -- another role where broad is a pre-requisite and some narrow depth is expected -- is systems design skills. Besides whatever you study and learn how to do as a programmer . these days it's not often commercially applicable unless you know how to make it run well in the cloud, with all the caveats that apply. Among the things that…

Thanks. That's valuable info indeed :)

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

#278
post #152

Earlier quoted context omitted.

>I showed your project to my 12 year old son who has just started to learn programming (in JS no less!) It would be much better if he would start with Scratch, Processing, Smalltalk, or even Python. On JS he'll have to lose time coping with complicated build tools, horrible package system, async etc.

Isn't Liam's project proof that you don't need any complicated JS tooling? A simple `node index.js` can go really far.

Yes amazingly he did this without the need of `left-pad` too. >Good job Liam

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

#279
post #276
post #267

Earlier quoted context omitted.

That's debatable. It's not as if downloading Python and making your first app will take you more than a few seconds, minus download time. Set up is rarely an issue, once you set up a language even as complex as C++ its completely automated. You press a button and magic happens. If the biggest selling point of a programming language is that it comes preinstalled with the OS of your choice, its not much of a selling po…

It does make a difference especially to a beginner or a child. You might not have admin privileges at your school or your friends may not be able to install those tools so you can't show your work. But you can hack away on any computer with a browser.

there are tons of services only that will allow you to code online using any language eve C , C++ and Assembly. From inside the browser of course. Of course I am not recommending a beginner to start from any of those languages but it shows that JS does not have the monopoly of in browser coding. If you have to stick with browser no matter what.

Ideone is a popular example https://ideone.com/

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

#280

Earlier quoted context omitted.

JS is an objectively bad programming language. It is not fine, it is just annoyingly common and convenient. The main advances in its ecosystem are related to transpiling it from other, saner, languages. If he has fun writing JS, then great for him. He's 12, he'll do it if he wants. But it'd be doing him a disservice not to open his eyes to much wider, greener pastures of the programming world.

no man its objectively good language, believe me. see how that sounds? that's how you js haters sounds each time I see this bs here on this and many other platforms that wouldn't be possible without js.

> no man its objectively good language, believe me.

A language that requires a 21x21 matrix to remember how equivalency works is objectively bad: https://dorey.github.io/JavaScript-Equality-Table/unified/

A language whose default sort behavior is the following is objectively bad:

    [5, 12, 9, 2, 18, 1, 25].sort(); → [1, 12, 18, 2, 25, 5, 9]
I used to be a frontend dev. I have written hundreds of thousands of lines of production JS code for apps that many Hacker News users use on a regular basis. I well understand how much JS has made possible. The web would not be the same without it. But that doesn't mean it's a good programming language.
Post reply on HN