TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

1072 点作者 liamilan超过 6 年前

66 条评论

sgk284超过 6 年前
Liam, this is <i>incredible</i>!<p>I thought it might be useful for you to incrementally see how someone in industry would review or change this code, so here&#x27;s a little code review via video: <a href="https:&#x2F;&#x2F;youtu.be&#x2F;UkVOrcS--04" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;UkVOrcS--04</a><p>We very incrementally build up to the final code, which can be found here: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;stevekrenzel&#x2F;b490564bf1c7f98e232a6c863bd066dd" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;stevekrenzel&#x2F;b490564bf1c7f98e232a6c8...</a><p>Hope you find it helpful!
评论 #17873896 未加载
评论 #17873844 未加载
评论 #17875083 未加载
评论 #17874755 未加载
评论 #17873711 未加载
评论 #17873850 未加载
评论 #17876037 未加载
评论 #17875209 未加载
评论 #17874970 未加载
sramam超过 6 年前
Congratulations!<p>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.<p>In addition to being a programmer, you are now a role-model. Really well done.
评论 #17872486 未加载
评论 #17873236 未加载
jacobolus超过 6 年前
Great work! I made a quick Observable notebook out of your code, in case anyone wants to see what it does without downloading or running it on their own machine:<p><a href="https:&#x2F;&#x2F;beta.observablehq.com&#x2F;@jrus&#x2F;wolfram-cellular-automaton" rel="nofollow">https:&#x2F;&#x2F;beta.observablehq.com&#x2F;@jrus&#x2F;wolfram-cellular-automat...</a>
评论 #17872146 未加载
评论 #17873333 未加载
scottmf超过 6 年前
Hey looks good :)! Just a few things you might not know about:<p>Google String.prototype.padEnd. It’s built in to JS and should be able to replace your zero fill function.<p>And instead of mutating the ruleSet array you should be able to use Array.prototype.map like this:<p>const ruleSet = zeroFill(8, rules.toString(2)) .split(&#x27;&#x27;) .reverse() .map(item =&gt; parseInt(item, 10));<p>And you can clone arrays like this, instead of using loops:<p>const oldArr = [...arr];<p>Also arrays are still mutable even if you assign them to const variables.<p>I’d offer more help but I’m on mobile. Sorry for the poor formatting. Hope this helps anyway. Good luck!
评论 #17871941 未加载
评论 #17871889 未加载
评论 #17871935 未加载
ninjakeyboard超过 6 年前
Good for you young jedi. I started coding around that age as well. I made the mistake of not going through comp-sci but have still been able to work for Google, publish books, lead teams and companies and products. You&#x27;ll do just fine.<p>You have the ability to write some code! If you want to get a jumpstart, you should take the princeton algorithms course (for free!): <a href="https:&#x2F;&#x2F;www.coursera.org&#x2F;learn&#x2F;algorithms-part1" rel="nofollow">https:&#x2F;&#x2F;www.coursera.org&#x2F;learn&#x2F;algorithms-part1</a><p>Or read the textbook by sedgewick that accompanies the course. <a href="https:&#x2F;&#x2F;algs4.cs.princeton.edu&#x2F;home&#x2F;" rel="nofollow">https:&#x2F;&#x2F;algs4.cs.princeton.edu&#x2F;home&#x2F;</a><p>There is very little math in there - it may take some elbow grease and mentorship to help to convey some of the ideas - but I believe that you could implement and solve most everything in there. That was my path - I had a teacher at the age of 14 who would explain to me how different algorithms worked and I would go and implement them. Drawing a circle (in memory - it was in C!) or sorting a list (we did bubblesort first IIRC!)<p>I think you could do it! I believe in you! The course material is approachable - much more so than basically every other algorithms&#x2F;data-structures material I&#x27;ve found. it may take you some time but you&#x27;ll be soooo far ahead with your thinking about code.<p>If you ever start working with Object oriented languages like Java, another book that may help you when you&#x27;ve gone down the road a bit is the Head First Design Patterns book. <a href="http:&#x2F;&#x2F;shop.oreilly.com&#x2F;product&#x2F;9780596007126.do" rel="nofollow">http:&#x2F;&#x2F;shop.oreilly.com&#x2F;product&#x2F;9780596007126.do</a> It&#x27;s very easy to read, mostly pictures. It is made to be very easy to read (all of the books in that series are so look around at them.)<p>It&#x27;s helpful to do both - code and also take in some material, but at 12 I imagine some of the material may be a bit daunting. You&#x27;re doing really well - keep it up.
deepaksurti超过 6 年前
Liam, brilliant!<p>I am not saying you don&#x27;t do this, but please please ensure you always sleep well, follow a good diet and go out and play.<p>Sometimes, computers make us give up good habits!<p>Kudos for your great work and keep learning, keep shipping!
shamdasani超过 6 年前
Woah - very cool! I&#x27;m a part of Hack Club (<a href="https:&#x2F;&#x2F;hackclub.com" rel="nofollow">https:&#x2F;&#x2F;hackclub.com</a>), which is a nonprofit worldwide network of high school coding clubs. Hack Club has an amazing community of young developers - I actually lead a Hack Club at my high school, and I definitely recommend that you join their slack (<a href="https:&#x2F;&#x2F;hackclub.com&#x2F;slack_invite" rel="nofollow">https:&#x2F;&#x2F;hackclub.com&#x2F;slack_invite</a>) to connect with other young makers!<p>By the way, I&#x27;m a 17 year-old developer (<a href="https:&#x2F;&#x2F;shamdasani.org" rel="nofollow">https:&#x2F;&#x2F;shamdasani.org</a>), but I probably started ~14. My main project is Enlight (<a href="https:&#x2F;&#x2F;enlight.nyc" rel="nofollow">https:&#x2F;&#x2F;enlight.nyc</a>) to teach others to code by building projects. If you&#x27;d like to contribute, that would be awesome - feel free to shoot me an email :)
评论 #17873725 未加载
评论 #17873650 未加载
rjplatte超过 6 年前
That&#x27;s awesome. What resources did you use to learn Node and JS? Just looked at your code. Kid. You&#x27;re a badass. Keep this up, you&#x27;ll go places.
评论 #17871592 未加载
tannerwj超过 6 年前
Looks great. I tried it and it runs fine. Nice syntax and convention.<p>Just a tip, you don&#x27;t need to include `npm init` in your instructions. That command only needs to run when you create a new project. It worked just fine for me with just a `node index.js 18`<p>Great work!
评论 #17871680 未加载
mockingbirdy超过 6 年前
Great that you start so early, I&#x27;ve did the same. For me it was a great way to gain confidence and build a skill which is very useful. I wouldn&#x27;t be the same person now if I didn&#x27;t program so early.<p>Seeing how things come to life that you&#x27;ve build with your own hands is a very empowering experience. Keep it up! :)
52-6F-62超过 6 年前
Far better than I could do at that age!<p>I think the furthest I was getting at that time was building out really terrible looking web pages in Notepad and making awful little animations in BASIC and Turing (learning lang).<p>Keep it up!
评论 #17871780 未加载
评论 #17873139 未加载
test6554超过 6 年前
Great job! One way to improve this code is to add comments. Use comments to describe what each function does and what the parameters are supposed to be. Then you can tell at a glance what the function does without having to analyze the code later on.<p>Us old people tend to forget things.
评论 #17873289 未加载
评论 #17872611 未加载
gilesvangruisen超过 6 年前
This is awesome! Keep up the good work. As a fellow developer who began writing software around your age, I have some advice that is definitely subjective and biased, but which you may indeed find helpful.<p>1. Keep practicing. Practice makes perfect. Explore different languages, frameworks, and problem spaces (interfaces, servers, distributed systems, statistics, etc.) to see what you find most interesting. You will make mistakes, and that is okay. That is how you learn.<p>2. Take frequent breaks. Programming is hard work. It can be truly exhausting, and you should not be afraid to step away and go for a walk or something.<p>3. The most valuable people in the industry are called &quot;T&quot;s. I.e. people with a little bit of knowledge&#x2F;experience across broad range of topics (the horizontal part of the letter T), but who have deep knowledge&#x2F;experience in one or a couple particular topics (the vertical shaft of the letter T).<p>4. Begin to develop the skill of taking feedback and accepting criticism. There&#x27;s a lot of people out there who will be quick to criticize everything you do if you put it out into the open. It&#x27;s a whole skill in itself to be able to interpret this feedback and separate the signal from the noise. Try to empathize with the person or group providing feedback and understand that their motives&#x2F;perspective may be different from yours. Sometimes that&#x27;s a useful thing. Sometimes it&#x27;s a distraction.<p>5. Dn&#x27;t take things too personally. You are not your code. A criticism of your code is not a criticism of your character. The less you take things personally, the easier it is to work with others. After all, the most impressive systems require immense collaboration.<p>6. Don&#x27;t take yourself too seriously. Have some fun with it! Programming is super fun, so you should ask yourself regularly &quot;am I still having fun?&quot;. If the answer is &quot;No&quot;, maybe find something else interesting to focus on for a bit.<p>7. Broaden your perspective. Along the lines of #1 and #2, it&#x27;s important to maintain a broad perspective and push yourself to keep expanding your perspective. This doesn&#x27;t just apply to technical problem areas or languages or frameworks. The best engineers are good problem solvers because they have a broad perspective not just of the problem space but also more generally of the world they inhabit. Try to learn about different industries, cultures, people, and places. You will become a more well-rounded character for doing so, with a higher ability to empathize with others and understand the complex mechanics of how the world works.<p>8. Be social. I made the mistake of hiding in my room on a computer for much of my childhood, and it wasn&#x27;t until high school that I really began to understand the value of social interaction and maintaining strong solid friendships. It&#x27;s as important to spend time away from the computer as it is too keep practicing.<p>All the best. Good luck!!
评论 #17871651 未加载
评论 #17871695 未加载
评论 #17871954 未加载
评论 #17872879 未加载
评论 #17871730 未加载
deusofnull超过 6 年前
This is awesome liam. im just over twice your age and am just now writing game of life simulators.... man, what was i doing at 12???
评论 #17871819 未加载
jcrza超过 6 年前
I guess I&#x27;m the only one here doubting that the combination of both this project and the language used in the comment replies is coming from a 12 year old.<p>Take it as a compliment if it&#x27;s legitimate.
评论 #17880177 未加载
评论 #17876374 未加载
jpamata超过 6 年前
Hey man, great job! You got some great advice here from the HN crowd and I&#x27;d just like to add one more: blog.<p>Set up your own site and blog about your journey and the lessons you&#x27;ve picked up along the way. Learning is about working and reflection. Blogging is a good platform for that. The very act of writing the content itself is reinforcing your knowledge. Dive into the work, research, reflect, stay hungry and repeat. That&#x27;s what it&#x27;s all about. Apart from that, you&#x27;ll be expanding your network as well. Having some amount of folks following your journey is not just a good way of inspiring oneself, but also gives you an opportunity to inspire others as well.<p>Anyways, keep it up! You&#x27;re definitely going places.
mayneack超过 6 年前
IANAL and all that and it doesn&#x27;t bother me, but the first thing I thought of was the age related ToS restrictions from the HBO Silicon Valley show.<p>From the HN &quot;legal&quot; page:<p>&gt; If you are under 13 years of age, you are not authorized to register to use the Site.<p><a href="https:&#x2F;&#x2F;www.ycombinator.com&#x2F;legal&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.ycombinator.com&#x2F;legal&#x2F;</a><p>I assume no 12 year olds actually try to follow this boilerplate on the internet. Do sites that require a DOB to sign up reject those under 12?
评论 #17880205 未加载
评论 #17873515 未加载
评论 #17874040 未加载
评论 #17873877 未加载
ArtWomb超过 6 年前
Good job! I mentor college CS majors whose code is not as clean as this. Seriously.<p>I would also recommend checking out The Coding Train. NYU ITP Daniel Shiffman&#x27;s lectures on creative coding. It&#x27;s time to get started with graphics ;)<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;channel&#x2F;UCvjgXvBlbQiydffZU7m1_aw" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;channel&#x2F;UCvjgXvBlbQiydffZU7m1_aw</a><p>And to get a headstart in Artificial Intelligence, from the same author comes the ml5.js library: friendly machine learning for the web. Best of luck!<p><a href="https:&#x2F;&#x2F;ml5js.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ml5js.org&#x2F;</a>
strainer超过 6 年前
I like how the array named &#x27;map&#x27; reflects our original use of this word, rather than the special meaning which it has acquired to programmers.<p>In Javascript and other languages &#x27;map&#x27; has become a kind of &quot;functional operation&quot; so we cant call things &#x27;map&#x27; anymore (in public). We have to say &#x27;space&#x27; or &#x27;state&#x27; or &#x27;grid&#x27; or something... but I do still think &#x27;map&#x27; was good.<p>Congratulations on a very efficient and readable project. Bravo !
评论 #17871983 未加载
g105b超过 6 年前
I&#x27;m particularly fond of this because at 12 when I was learning to program I never thought it was important to keep my work safe, or even documented at all, and it all exists on a hard drive in landfill now.<p>If you pursue a career in programming, you&#x27;ll look back at your early work and have a great personal self-documentation tool to remind you of how far you&#x27;ve come.
forthispurpose超过 6 年前
Everything about it is optimism-inducing on a very deep level. The post itself, the reaction, the answers, the discussion.
评论 #17873435 未加载
jVinc超过 6 年前
It&#x27;s amazing that at the same age Steven Wolfram himself had written his first 100 page book &quot;concise directory of physics) and at just one year older wrote his first book on quantum physics.
评论 #17871895 未加载
评论 #17872073 未加载
jrumbut超过 6 年前
I feel bad for all the other 12 year olds whose parents just saw this :)
评论 #17871926 未加载
评论 #17880236 未加载
评论 #17871674 未加载
calhoun137超过 6 年前
This is so great and I am really impressed, and even a little inspired! When I was 12 there was no internet and learning programming was really hard, but it was more fun for me than anything else. Your project has reminded me how I felt so many years ago when I was 12 and I would sneak out of bed to program QBASIC on my APPLE 2C. Thanks for the inspiration and keep up the great work! Keep working hard like this and you will become a master programmer of the first rank.
kritixilithos超过 6 年前
Congratulations!<p>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.<p>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.
mandeepj超过 6 年前
Congrats.<p>&gt; dimensional cellular automata in witch all possible rules are encoded into one byte as described here<p>Small typo here - should be &quot;which&quot; instead of &quot;witch&quot;
评论 #17873346 未加载
tinchox5超过 6 年前
Hi Liam! I&#x27;m your occasional HN neighbour I live currently just below your post :) (Show HN: A smarthome dashboard concept using zircle-ui).<p>It&#x27;s a pleasure to see the impressive reception that your post is having. Also I want to join all the voices of congratulations you have received for your work at your age! Keep doing this kind of things, It is very inspiring for all!
Qwertie超过 6 年前
Nice work. I&#x27;m not a JS expert but I think I saw a bug.<p>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.<p>You should be able to take<p><pre><code> setTimeout(() =&gt; { animate(); }, 100); </code></pre> and paste it over animate() on the last line
评论 #17874015 未加载
amasad超过 6 年前
That&#x27;s really awesome. Here it is running in a Node repl in the browser if you want to try it quickly (the code verbatim but hardcoded the rule number to 18) <a href="https:&#x2F;&#x2F;repl.it&#x2F;@amasad&#x2F;wolfram-cellular-automata" rel="nofollow">https:&#x2F;&#x2F;repl.it&#x2F;@amasad&#x2F;wolfram-cellular-automata</a>
transitivebs超过 6 年前
You&#x27;re off to an amazing start!<p>I&#x27;d say just find stuff that genuinely interests you and try to build it. I got my start focusing on games, but whatever gets you excited. You&#x27;re already way ahead of the curve, so have fun with it, experiment, and you&#x27;ll do great things :)
brianzelip超过 6 年前
Nice work! I hacked together something similar for the browser after watching a FunFunFunction video about automata, <a href="https:&#x2F;&#x2F;brianzelip.github.io&#x2F;automata" rel="nofollow">https:&#x2F;&#x2F;brianzelip.github.io&#x2F;automata</a><p>(not ideal on mobile)
Aardwolf超过 6 年前
Off topic for the main achievement :)<p>But: if I open the bitbucket link on mobile, the left part of the text is clipped and it doesn&#x27;t allow scrolling left.<p>With &quot;request desktop site&quot;, it works perfect.<p>Why does mobile mode even exist if the desktop site works better??
评论 #17872321 未加载
FuckOffNeemo超过 6 年前
This has suddenly became the most wholesome thread I&#x27;ve ever read on HN.<p>This is why HN is great.
swat535超过 6 年前
This is really amazing, reminds me of my childhood days..<p>I showed this to my girlfriend&#x27;s sister whom has shown interest in programming, today I learned that she decided to drop her art classes in favour of some programming courses!<p>Well done!
brtknr超过 6 年前
That’s so cool! When I was 12, the best I built was a game of Who wants to be a millionaire in Qbasic and this is whole another level from that! You are inspirational!
mbrodersen超过 6 年前
Great work :-) I had fun programming Basic and Z80 assembler when I was 11 as well. I always remember it as being a great time of discovery and passion.
lucasverra超过 6 年前
Just stepping by to say, congrats for shipping, congrats for posting ! Im 32 and will be posting my public beta next week !
thieving_magpie超过 6 年前
Congratulations Liam. This is great.
davekam超过 6 年前
not sure why the age matters?
neelkadia超过 6 年前
Congratulations Liam!!!<p>You&#x27;re doing phenomenal. You&#x27;ll be role model for up-coming generation.<p>Great!!
chriselles超过 6 年前
Congrats! I have shown this to my 13 and 12 year old sons to inspire them.
CommanderData超过 6 年前
Well done little one. Keep it up and hats off to your parents.
timmonsjg超过 6 年前
Impressive. Keep it up!
wavefunction超过 6 年前
Keep it up, this is exactly how great programmers are made!
slics超过 6 年前
This tells you that talent can be discovered at any age.
rootw0rm超过 6 年前
congrats! when I was 12 I was war dialling BBSes and pirating shareware games. hopefully your future turns out bright.
mvpu超过 6 年前
Great! Now redo this in Python and GoLang :)
stevefan1999超过 6 年前
Wow, you really had great potentials in CS!
fullofsid超过 6 年前
You are amazing, keep learning more. :)
mcs_超过 6 年前
Thank you Lia. You inspired me today.
willbw超过 6 年前
Well done mate, very impressive.
iammer超过 6 年前
Very nice.
benvineyard超过 6 年前
Holy $hit! Nice work man!
benvineyard超过 6 年前
Holy $hit. Nice work man!
jmkni超过 6 年前
Very nice work!
slolean13超过 6 年前
its brilliant, congratulations!
whitepoplar超过 6 年前
Great work!
adultSwim超过 6 年前
Cool!
mito88超过 6 年前
Good work!
ultrasounder超过 6 年前
very inspiring!!!
da_murvel超过 6 年前
Excuse my portion of scepticism, it&#x27;s not the fact that a &quot;12 year old&quot; built this, sure anyone can learn how to code and we can&#x27;t know how much help this person got along the way. But it&#x27;s rather the person&#x27;s language when writing plain text, here in the comments for example. It doesn&#x27;t feel adolescent but more grownup to me ... But maybe it&#x27;s just me realising my own shortcommings as a 12 year old, as I only was playing with my friends and the odd computer and video game.
评论 #17874619 未加载
评论 #17880358 未加载
评论 #17876073 未加载
评论 #17876404 未加载
评论 #17876552 未加载
saagarjha超过 6 年前
Technically, you shouldn&#x27;t be using this site ;)<p>&gt; If you are under 13 years of age, you are not authorized to register to use the Site.<p>But I applaud you for getting into programming this early.
评论 #17871740 未加载
评论 #17872093 未加载
pantheon超过 6 年前
Great work. I will give you a different piece of advice. Make sure to work out 360 out of 365 days in a year, without weights.
评论 #17873286 未加载
Froyoh超过 6 年前
wow you code better than me
crooked-v超过 6 年前
Good work.<p>For a next step, I would suggest giving a try at breaking it up into multiple files using import&#x2F;export statements (it doesn&#x27;t need it but it&#x27;s good practice), and using a bundler like Parcel to build the finished file.<p><pre><code> npm i --save-dev parcel-bundler </code></pre> ...then move your source JS files to a folder named src, and add to package.json...<p><pre><code> &quot;scripts&quot;: { &quot;prepare&quot;: &quot;parcel --target node src&#x2F;index.js&quot; &quot;start&quot;: &quot; node dist&#x2F;index.js&quot; } </code></pre> In your individual files, you do like...<p><pre><code> &#x2F;&#x2F; file-1.js import somethingName, { whateverName } from &#x27;.&#x2F;file-2&#x27; &#x2F;&#x2F; file-2.js export function whateverName { ... } const somethingName = &#x27;...&#x27;; export default somethingName; </code></pre> ...and then run...<p><pre><code> npm run prepare npm run start </code></pre> (The prepare script is also a &quot;magic word&quot; that will auto-run anytime someone does &#x27;npm install&#x27;, so usually an end user won&#x27;t have to manually run it.)<p>A bundler isn&#x27;t strictly necessary if you plan to only run something in Node, but it lets you make a package that&#x27;s usable in both Node and web projects, and it makes it simple to use Babel, which lets you Javascript features from the future that aren&#x27;t actually in Node proper yet.
评论 #17871738 未加载
评论 #17871699 未加载
评论 #17871700 未加载
评论 #17871827 未加载
modzu超过 6 年前
im 12 and what is this
评论 #17876706 未加载