303 comments

[ 3.1 ms ] story [ 269 ms ] thread
All your work is in 1 commit and you only have 3 total commits in your repo. I'm skeptical that YOU wrote this program.

I'd happily be proven wrong.

This comment violates HN's rules. Please assume good faith and don't attack people.

https://news.ycombinator.com/newsguidelines.html

https://news.ycombinator.com/showhn.html

Consider the ridiculous downside of someone being 12, posting their program to HN, and meeting with this as a first comment. How awful.

No it's not awful. People will doubt him sometime, and it's better to learn how to deal with that and gain a life skill rather than expecting every person to be sweet and supporting.

There are some kids who just goes on game chats to mess with others, play loud music, bully them, grief them etc. They are usually around 12 years old to 16 years old. I'm sure these things are not new to this kid.

Welcome to the planet.

TL;DR - It is okay to be an asshole because the world is full of assholes... ?
Yes, bullying exists. But we should discourage it wherever we can.
Those "no pain no gain" guys with a negative attitude are simply toxic. I was never doubted even when I started to freelance when I was 16y/o.

I simply wrote the code. There's not much room to bullshit your way through it.

I think it's mostly jealous people who see some clean code from a 12y/o (I like the functional programming patterns) and think about their own mediocrity. There's nothing to gain when dealing with those people except cynism. It's almost always better to have an empowering environment. We're not playing Darwin games here and feeling threatened by a 12y/o shows a lack of decency and commitment IMO.

When I was 12 or so I had an interest in being an artist. I was also playing a game that happened to be looking for art work. Specifically, they wanted some models for new monsters in the game.

I put together my best attempt and submitted it. The work was subsequently torn to shreds by the people on the board, and rightly so: The "monster" looked like a walking boob, and everyone said that the special attack could be to squirt milk.

I wish I'd been old enough to laugh it off, since it's quite hilarious, but in reality I just stopped trying to be a 3D artist. Stuff like this can have a big impact at a young age.

People can, and do, make that same harden-the-fuck-up argument to support any kind of violence. And it makes sense, since perpetrators were always first victims. But on HN, in our internetty and admittedly trivial way, we want to break that cycle. So no, you can't rough up a 12-year-old here—or do anything with a high probability of amounting to that.
Guys, I think you should ALL calm down and stop playing SJW. He simply stated that he doubts the kid wrote the code. Since when having a doubt is considered BULLYING??? Did he insulted the kid? Did he used a slur against him? No. He expressed his legit and reasonable doubt.

So please turn on your neurons and stop playing mother hen and SJW ok?

Being skeptical is a right we all have to take advantage of and since it has been made in a respectful way, there are no reasons why attacking the user in the way you all did.

This politically correct thing is slipping thru your fingers and out of your control of you REALLY and SERIOUSLY think that expressing a legit doubt is considered an act of bullying. Ponder about that.

Going to be honest, when I was 14 and learning to program, I quickly learned how shitty and harsh the internet can be, especially the types that frequented forums.
I'm sorry that happened. But it's a good reason not to inflict it on others.
Full heartedly. Ever since, I've always tried to be better to young people online especially when they are looking help or advice.
Everything being in 1 commit seems perfectly normal for this situation.

He likely wrote the entire thing without Git (because he's the only one working on it), then decided to push it to BitBucket when he wanted to publish it.

I'd bet he wrote it locally and then committed it.
So you're saying it's more likely that this 12-year old would have written this thing if he had split everything nicely into small readable commits?

That makes absolutely no sense

I disagree. I'd say having all of the work in 1 commit makes it more likely to have been created by a young programmer. What impresses me the most, and makes me skeptical, is the good code style. I know at least 3 12 year old programmers who might be able to do this, but none of them have this diligence for style.

The program is short enough and I was enough of a nerd at this age to be interested in doing something like this. I just focused on making poorly-designed computer games instead.

The good style might be a result of using ESLint.
If so, then it's good that the author has learned to use useful tools.
you'd be surprised how many personal projects have only one commit.
That's awesome. What resources did you use to learn Node and JS? Just looked at your code. Kid. You're a badass. Keep this up, you'll go places.
Thank you! I'm watching a lot of Youtube videos. This is how I got to cellular automata. My dad showed me git last week.
That's so freaking cool. Git rocks, and I remember how psyched I was when I learned about it. What's your next project?
I'm not sure. I'm always messing around with different projects.

I used blocklike.js to jump from Scratch to JavaScript. Then I worked for months on this one game for the app store called Sticky Quest. You can find it here: https://itunes.apple.com/us/app/sticky-quest/id1425679649?mt... This how I learned how to use npm packages such as Cordova and Eslint.

I'm 28 and have been using Javascript for years and still have no idea how to use Eslint in a terminal.
You could try expanding this project beyond elementary CAs.

One option is a 'totalistic' CA which looks at the average value of a given neighborhood, and can have more than two states.

http://mathworld.wolfram.com/TotalisticCellularAutomaton.htm...

Or you could generate CAs with different starting conditions. Some beautiful elementary CAs don't 'show up' with just one initial point.

The Moveable Feast Machine is similar to cellular automata, but different in some important ways, that make it extremely robust and fault tolerant:

It's a "Robust First" asynchronous distributed fault tolerant cellular-automata-like computer architecture.

Robust programs running on massively parallel unreliable hardware can actually tolerate hardware failure and repair themselves. The Demon Hoard Sort algorithm is an inherently robust sorting algorithm for the Moveable Feast Machine.

http://movablefeastmachine.org/

The "Distributed City Generation" video demonstrates a Movable Feast Machine rule that builds a self-healing city that fills all available space with urban sprawl, with cars that drive between buildings, and city streets that adaptively learn how to route the cars to their nearest destinations, and the city even repairs itself after disasters!

https://www.youtube.com/watch?v=XkSXERxucPc

Here's some more info:

https://news.ycombinator.com/item?id=14236973

How did you like Scratch, and how was it going from Scratch to JavaScript?

There's another visual programming language called "Snap!", which is inspired by and similar to Scratch, but has the full power of JavaScript and Scheme, everything's an object, and you can define your own blocks. Plus there are some amazing networking, speech and AI blocks, too! (It has a JavaScript block that makes it very easy to extend and plug in existing JavaScript code.)

I'm interested to know what you think of Snap!, from your perspective of going from Scratch to JavaScript!

https://snap.berkeley.edu

AI extensions of Snap! for the eCraft2Learn project:

https://ecraft2learn.github.io/ai/

>The eCraft2Learn project is developing a set of extensions to the Snap! programming language to enable children (and non-expert programmers) to build AI programs. You can use all the AI blocks after importing this file into Snap! or Snap4Arduino. Or you can see examples of using these blocks inside this Snap! project.

Here's more info:

https://news.ycombinator.com/item?id=17594403

That's pretty quick!

Do you have any plans for future projects? Maybe a simple place where you could chart your progress?

I think one of my favorite uses of cellular automata besides conway's game of life (if you are interested in it) is modeling simple fluid mechanics (water flowing from place to place) in games like dwarf fortress http://www.bay12games.com/dwarves/

> My dad showed me git

Cheater! :) Seriously though, great work. I started around your age (which I guess means I've been coding for half my life at this point.) Keep challenging yourself with new and interesting projects and you're going to learn a lot and have a lot of fun.

> My dad showed me git last week.

Anyone else miss learning this quickly?

In all seriousness, congrats. Keep at it. There is always something else to learn. It's the career that never stops giving.

Great that you start so early, I've did the same. For me it was a great way to gain confidence and build a skill which is very useful. I wouldn't be the same person now if I didn't program so early.

Seeing how things come to life that you've build with your own hands is a very empowering experience. Keep it up! :)

Looks great. I tried it and it runs fine. Nice syntax and convention.

Just a tip, you don'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`

Great work!

Thanks! You're right, I fixed it.
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.

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.

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.

3. The most valuable people in the industry are called "T"s. I.e. people with a little bit of knowledge/experience across broad range of topics (the horizontal part of the letter T), but who have deep knowledge/experience in one or a couple particular topics (the vertical shaft of the letter T).

4. Begin to develop the skill of taking feedback and accepting criticism. There'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'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/perspective may be different from yours. Sometimes that's a useful thing. Sometimes it's a distraction.

5. Dn'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.

6. Don't take yourself too seriously. Have some fun with it! Programming is super fun, so you should ask yourself regularly "am I still having fun?". If the answer is "No", maybe find something else interesting to focus on for a bit.

7. Broaden your perspective. Along the lines of #1 and #2, it's important to maintain a broad perspective and push yourself to keep expanding your perspective. This doesn'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.

8. Be social. I made the mistake of hiding in my room on a computer for much of my childhood, and it wasn't until high school that I really began to understand the value of social interaction and maintaining strong solid friendships. It's as important to spend time away from the computer as it is too keep practicing.

All the best. Good luck!!

9. Bookmark this page, so you can come back and see the wonderful advice that you got when you were 12. It will make more sense as you get older.
I'm 27, and learned this over over years, but still I needed to hear this again! And I'm sure I will need this advice again. Bookmarked :)
Would you please provide an example on how one proceed with T shaped learning and expertise?
That's a good question. I left that intentionally broad so as not to prescribe a certain type of learning system or self-education.

There's a lot of ways to learn anything, but I would say that the first step is pursuing a variety of subjects that you find interesting, and even some you think are boring. A lot of seemingly boring things I've found turn out to be quite fascinating when it comes down to it. (e.g. database design)

Over time, you will pick things up, and put them back down. You will return to some, and stay away from others, but eventually you will build a repertoire of knowledge and experience in a variety of different fields. I would also bet that at least one subject will interest you so much that you keep coming back and in which you will ultimately develop expertise.

Experimentation is the name of the game!

Thanks for replying, Giles!

I see just dabbling in whatever interests and experimenting with them takes one forward.

What you wrote is profoundly impactful.

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 aren't common knowledge among basement programmers: network configuration (VPCs, load balancing, CDNs, security), security/IAM, non-relational datastores, ML model development & training, and the list goes on and on and on (microservices & containers, devops, serverless, advanced logging/monitoring & problem solving, high availability, HPC/grid, blockchain, and oh so much more.

The point I'm trying to make is that you can become a T shaped programmer by continuing to study and learn various programming skills, but you may want to alternatively consider becoming broad in ways that expand your value beyond just coding.

A phrase I came up with that I like more than "T-shaped" is "molecular skillset". A chemist would probably laugh at me but I think of it as developing seemingly independent skills (molecules <--> skills, experience, knowledge...) that end up forming bonds with other skills, sometimes in surprising ways, that together prove really powerful and can bond up even further. "T" and other tree/tendril-ish shapes are then just special cases of different bond arrangements. You can acquire skills haphazardly (though as a serial dabbler I'd caution against actively pursuing the dabbler's path without a ton of introspection), you can also take the efficient road like a university sequence where most skills are visible and have unsurprising connections to the next skills. You might have to take some seemingly unrelated course too, but you can look at those optimistically as another potential source of surprising bonds. Duds are of course possible -- I have some useless things in my brain that I don't think will ever connect with anything useful, at best they might aid in social signaling one day. (A lot of education is just signaling to show you can talk about a lot of stuff...)

Trivial example: at some point around age 17 I installed Gentoo successfully and learned a lot about gnu/linux (and some bsd) in the process. Lots of little skills formed and connected, and they continue connecting with other things to this day. Got my initial hook on vim then. Saw how nicely colorized my terminal prompt was and that opened the door to many bash customizations. One of the skills I had to learn was to understand how hard drives worked (at least to the ability to successfully partition, format, and boot them -- I did accidentally wipe a windows xp partition the first time). Some years later (age 20?) I had accidentally rm'd a couple weeks of java work without having committed it yet. But prior knowledge of the system let me know the data was still there, and I was able to recover it by scanning the disk device partition directly for the bytes. (Ended up using "grope.tcl" referenced here http://wiki.yak.net/592 which was a lot more efficient than what I was making.)

That’s way too exciting !! Really fresh perspectives.

I once tried upgrading my Windows laptop while having very less space in C drive. Windows totally crashed. After that I used live bootable Ubuntu, but would still like to retrieve all of my windows data.

Do you know how can I do that?

+1 for not recommending build systems
This is not just good advice for a successful programming career, but if you can pull it off, pretty much any field that one is passionate about.

As a scientist, if one is a scientist and has abided these ideas, they'd ramp up the food-chain pretty quickly.

Far better than I could do at that age!

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).

Keep it up!

I made a colourful ASCII birthday cake in Pascal that beeped happy birthday at that age. Still one of my proudest programming moments.
writeln(chr(7)) ?

or something more (e.g. playing different frequencies to sound like the happy birthday song)?

Related, and good fun for kids of all ages (first did something like this on my earliest home computer [1]):

Play the piano on your computer with Python:

https://jugad2.blogspot.com/2013/04/play-piano-on-your-compu...

[1] Lissajous hippo, retrocomputing and the IBM PC Jr.:

https://jugad2.blogspot.com/2012/09/lissajous-hippo.html

Western classic music fans may find the comments on that post interesting - stuff about octaves and frequencies.

I was on my Atari 800XL making games at that age. I started hitting problems that I thought should be easy. Like, I wanted to draw circles. But the library was just pixels and lines ( when I got to assembly programming, suddenly lines became a problem too ). There was no googling the answers, but luckily I could go "Daaaad..", who was a physicist, and he happily introduced me to trig and I eventually learned to draw circles....slow drawing circles, but still, circles.
+1. Reading your answer made me think you were talking about me. Except I had a TI99/4A, and "Daaaad" was my real google. My circles were probably slower and more pixelated
I think what I love most is that he/she is using version control, and the version control of choice is Bitbucket!
At 12, I was writing 6809 and 68k asm, and cracking games.

The most impressive demos in the Atari scene were written when we all were around 15.

Because we had plenty of spare time and still lived at our parent's house. And because we loved programming.

Nowadays, kids are just not interested in computers any more, besides playing Fortnite and more generally, using apps or wasting time on Youtube and Instagram.

Trivial lines of code in Javascript are now supposed to be a wonderful achievement for a 12 year old kid. Sad.

I feel bad for all the other 12 year olds whose parents just saw this :)
or all the 16 year olds
Or all the 42 year olds, ahem, who are currently learning JS/Node/React. :-/
Speaking of which, I'm also learning Spanish. Liam, I'm from the UK where we only speak one language. The one thing I really, really wish I'd done is to have learned another language. I'm doing it now, but it's so much easier when you're young.

It doesn't even matter what it is – pick one you like the sound of. French, German, Italian, whatever. When you bump in to someone later in life and you hear them speaking another language and you can interact with them, there's no greater satisfaction.

/off topic

It's almost like a programming language is a language...
It's great to be writing code at 12 if you want to write code, and clearly this kid has a talent for it, but that doesn't detract from what all the other 12 year olds are doing. So long as they're happy and safe to do what they want to do it's all good. Growing up is not a competition.

Also, while it may seem great to learn early, I've worked with people who didn't write a line of code until they were in their 50s and they were far better at it after a few years than I am despite having 20 years more experience. Some people have a gift. Others have to really work at it. Sadly I'm in the second group. :)

What about those of us in the 3rd group - started late and have to work hard at it!
Any parent who thinks they have a place in determining what pursuits their adolescent child is interested in is in for a wakeup call...
Good work.

For a next step, I would suggest giving a try at breaking it up into multiple files using import/export statements (it doesn't need it but it's good practice), and using a bundler like Parcel to build the finished file.

    npm i --save-dev parcel-bundler
...then move your source JS files to a folder named src, and add to package.json...

    "scripts": {
      "prepare": "parcel --target node src/index.js"
      "start": " node dist/index.js"
    }
In your individual files, you do like...

    // file-1.js

    import somethingName, { whateverName } from './file-2'

    // file-2.js

    export function whateverName { ... }

    const somethingName = '...';
    export default somethingName;
...and then run...

    npm run prepare
    npm run start
(The prepare script is also a "magic word" that will auto-run anytime someone does 'npm install', so usually an end user won't have to manually run it.)

A bundler isn't strictly necessary if you plan to only run something in Node, but it lets you make a package that'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't actually in Node proper yet.

It's a program that fits in one screen and has 3 functions. No need for these trendy overcomplications.
The fact that it's dead simple is the point of the recommendation. It gives an opportunity to learn the tool with the bare minimum of moving parts involved.
I'd prefer that we unlearn many of these things instead.
Unfortunately, my stock of browser-maintainer mind control rays has run out, so until somebody scrounges one up we'll still need ways to make the web half of the JS equation at least vaguely maintainable.
That last thing a 12 year old needs is a complicated build toolchain.
Everybody needs a build toolchain eventually, and learning it early saves the eventual "this webpage has become a 5000-line JS file and it's incredibly unwieldy to maintain" hassle with a more complicated project.
Hell, I'm 50 and its the last thing I need.
How about we let the kid learn how to program (which will outlive your favorite bundler and file hierarchy anyway) first? It's a 100 line script, one of the mistakes I made learning how to program was trying to be like the adults and focusing on minutiae like code organization rather than good code.

EDIT: story time. I once tried to make a 2D game engine in my late teens, but I wanted to be like the adults and have a proper class hierarchy. Suffice to say, I never finished it. Come to find a few years later, now class oriented OOP is passé and I was wrong to waste that time on it.

Learning to code and get things working is more cool (and in the end, more profitable) than making your code fit the norms of the day, which won't last anyway.

My intent is less "code structure", and more "most of the pieces you need to make a Node project also work in the browser". Imports/exports and Parcel would get liamilan most of the way towards being able to do...

   if (window) {
     document.write(...)
   } else {
     console.log(..)
   }
...and have it just work, without having to write everything twice.
Of the things to learn when one is starting out, I would not put code modularisation and toolchains at the top of my list (especially for something so small).

Additionally, this runs in Node, so you don't need to compile the source files with `parcel`.

(comment deleted)
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:

https://beta.observablehq.com/@jrus/wolfram-cellular-automat...

Dang, that's a neat tool. It's different enough from a Node environment, though, including some of the necessary rewrites of stuff, that I wonder if a "more Node-y" sandbox would be more useful for this particular case. An example: https://codesandbox.io/s/r0kwk0o28p (I tweaked the rule number, column width, and output to print to the page, but otherwise it's the same as the original.)
Hi Jacob, I never got to thank you for doing the observableHQ notebook for my quasirandom sequencing. For your information, I have linked to it on many occasions which includes in my post "Unreasonable Effectiveness of Quasirandom Sequences" which is on front page of HN right now! :) https://news.ycombinator.com
Technically, you shouldn't be using this site ;)

> If you are under 13 years of age, you are not authorized to register to use the Site.

But I applaud you for getting into programming this early.

(comment deleted)
My assumption was that this was inserted as the generic response to having to deal with COPPA. Not sure if you're collecting information that would be afoul of that law.
One of the few times when regulations like this actually hurt more than help.
When I was 12 I ignored this on pretty much any website I signed up for. Words do little to stop a determined 12 year old.
On the internet, nobody knows your a dog.

Nice work dude!

It's amazing that at the same age Steven Wolfram himself had written his first 100 page book "concise directory of physics) and at just one year older wrote his first book on quantum physics.
From all the amazing things Mr. Wolfram has done at such a young age almost makes him the Chuck Norris of science.
Catching the disease of cellular automata isn’t a good thing. Fredkin was also affected. This young person has many years to do useful things.
It's really not all that unusual. History is littered with amazing minds that accomplished tremendous things well before adulthood. The modern fiction that humans are useless until adulthood is one we have to construct by force, through active neglect of education, denigration of intellectual pursuits ('Go outside! Get a life! Do anything else but read or sit and think!'), and adamant insistence that it is normal to be ignorant and incapable until adulthood. Pascal recognized his triangle as a youth, Gauss was similarly known for early feats, etc. Those are just accidents of history, mostly, that they are remembered. The actual number of fertile and productive minds is doubtlessly orders of magnitude higher. It's only through diligent refusal to believe, or to tolerate the notion that maybe we should have expected a bit more of ourselves in our own youth, that we can keep up seeing intellectual achievements of the young as an unusual occurrence.
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???
Trust me, there can be downsides to starting early. In my case, I virtually skipped having social interactions not on the internet until I was around 20 or so. Not everyone will have this kind of affliction, but you can't have it all - you gotta choose what's important to you. I hope this doesn't come off as being too negative, I mostly say this because I think you should try to appreciate what you did learn rather than lamenting about not being able to start with coding super early.

...that being said, this is way cleaner than any code I'd written at 12 I'm pretty sure.

Oh definitely I agree. Gotta find that middle path.
> I virtually skipped having social interactions

That was me, too. It was a trade-off for me. I was reading Hawking in primary school and there was no one to talk to, so I was feeling lonely.

Programming was my lifesaving straw, but I don't wish any kid the kind of isolation that I've felt in my youth. I had to learn many of the social stuff later in life so it evens out IMO.

With that said, it can also have the opposite effect. Success in online interactions at such an age gave me the confidence I needed to be successful in irl interactions.
I like how the array named 'map' reflects our original use of this word, rather than the special meaning which it has acquired to programmers.

In Javascript and other languages 'map' has become a kind of "functional operation" so we cant call things 'map' anymore (in public). We have to say 'space' or 'state' or 'grid' or something... but I do still think 'map' was good.

Congratulations on a very efficient and readable project. Bravo !

Programmers got it from mathematicians. I had the impression it was a fairly long standing use of the word.
Mathematicians got it directly from cartography. A “map” “maps” points from one set of coordinates to another, for example when you want to plot latitude and longitude on a flat paper.
I expect ideas of mapping functions are only a couple of hundred years old at most, and really quite obscure to most people who are just familiar with the concept of 'maps' and 'mapping' things 'out'.

In functional programming I understand map as just a clone and convert operation. I noticed C++ has a 'map' data structure which is most suitable for associating references. A C++ map is not suitable for storing positions in space.

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 using loops:

const oldArr = [...arr];

Also arrays are still mutable even if you assign them to const variables.

I’d offer more help but I’m on mobile. Sorry for the poor formatting. Hope this helps anyway. Good luck!

Though, keep in mind that some of this stuff (most notably the [...arr] syntax) won't work in old browsers if you make a web project (IE 11 is a big offender here). See https://caniuse.com/ for a useful source of info on what will work with what for stuff like that.

If you do web stuff (and you don't want to just say "no IE 11" - some people, and even some big companies, do that!), usually the easiest way to handle stuff like that is to use the newest syntax you're comfortable with, plus a tool like Babel that will produce a "time travel" version with older syntax that will work in all browsers.

This project explicitly says Node. But in any case, these days I generally recommend using Babel to transpile the newer JS to browser friendly JS as the productivity and readability improvements in newer versions of JS are worth the effort to me to set up the babel build step.
> This project explicitly says Node.

While that's true, future projects are a lot easier if one doesn't have to keep re-referencing "what works in Node" vs "what works on the web".

current projects are a lot easier if you can use modern syntax that will eventually be supported in future projects, and which can be transpiled in either way
Good tips if you want your code to fail randomly on older devices.
Older devices running node?
Surprisingly there are some embedded developers who use Node. I would assume those devices have a trimmed version of the Node stdlib.
I'm sure when he ports it to Espruino he can handle Babel.
The code would fail to run on older devices without transpiling wnyway.
Not even businesses doesn't (and shouldn't) care for older devices when it doesn't make economic sense -- even less so a fun learning project.
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.
I second this. Knowing why something is better to use is most likely learned through doing it a worse way first.
I third this. Speaking from personal experience. I sometimes try to implement the logic of some library or algorithm myself, even if I know there is well-known or canned solution for it. For the same reason as you and your parent comment said.

Interestingly, some people (typically newbies who are looking for rewards without commensurate effort. but others too) do not think that way, and even sometimes don't like it if such suggestions are made. I once made such a suggestion to a poster (an obvious newb) on comp.lang.python. He asked how to do some small task in Python. I suggested that he may learn more if he tried it on his own first. He misunderstood the intention behind the advice, and made some comment to the effect that my idea was not helpful, or something like that. Another regular pitched in and pointed out that my comment was meant in the spirit of helping him learn better, because a) if you try it yourself first and do get a solution, you just got better at something, and it will boost your confidence, and b) even if you do not get a solution, you will learn that the thing is not as easy or trivial as you thought (or why were you asking in the first place, except if wanting others to do your work for you) (which would happen if you just blindly used some library to do it). And will gain a new respect for the depth of your profession and all that it entails.

Related: How To Ask Questions The Smart Way:

http://www.catb.org/esr/faqs/smart-questions.html

It's by Eric Raymond, author of The Cathedral and the Bazaar and The Art of Unix Programming.

There are many interesting points in that article, e.g.:

http://www.catb.org/esr/faqs/smart-questions.html#noprivate

Seen people ask for private replies. IMO some of them do it because either a) they don't want to be seen as not knowing the thing if it was obvious, or b) not wanting others (likely their peers) to get the answer too. Both not good.

>...sometimes don't like it if such suggestions are made

I'll admit to occasionally being frustrated by comments like this. It's important to remember that not everyone is looking to learn. Sometimes, they just need to get something done ASAP.

It's a bit idealistic to assume that everyone has time to learn the canned solution. The real world doesn't always allow for that.

Sure, but it's still a valid advice that might be helpful to others.
True. I did not mean it as an absolute statement. I did say above:

>I sometimes try to implement

It's each person's call, on a case-by-case basis. Had just shared my view with that newb, thinking it might help him.

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.
And yet, we also have nearly-infinite number of (reinvented) wheels...

Humans are the worst

use String#padEnd/padStart instead of your zeroFill
Congratulations!

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 videos. I like The Coding Train, Carykh, and Code Bullet, and I get a lot of my ideas from their projects.

> there are a lot of projects that I don't finish...

You and me both. :)

Startup Idea: Start a slack/discord group for aspiring students between the ages of [pick your age range, say (8-18)] and start a mentoring/support group with these like-minds...

You'll learn, build relationships and some of you will go off and found companies together.

Starting a Slack group for students is a good idea, but decidedly not a startup idea.
What about a saas to support the companies providing groups for slack.
I've considered building a "coding buddies" site. Something that's been lacking about the whole Codecademy/Hacker Rank/etc sites is the lack of intrinsic motivation. An actual person with whom you can work could potentially provide that.
Yeah thats what I was inferring... Basically - start a slack, find a bunch of people like him - pick a project to build together that suits their need (coding buddies) and build the tool.

Kind of like when I was trying blacksmithing, the teacher makes you make your tools first.

(comment deleted)
I'm 21 but I wish something like this existed when I was younger!
I'm 47. There were computer camps and clubs when I was a kid. They probably took a downturn, though, as computing went mainstream and turned into consumption of video games and, later, online socializing.

Maybe you were either too late, or too early, depending on perspective. :)

38 here. I was learning Turbo Pascal in around 96. I'm sure there was a lively community around it, but it would have been on IRC and usenet, which was still a little daunting to me. My primary resource was the SWAG archives, and I honestly can't remember if it was a bunch of floppy disks or a website. Either way, I remember many hours lost to running various random bits of Pascal and hacking them together to make what I wanted. Which is pretty much the same way I code today.
I wish I was 21. Or 31 for that matter.
I am 24, and was programming when I was 12. I remember spending days trying to get Visual Studio to download. I began working with Visual Basic Macros in Word. Although it wasn't very well understood in the schools around me, I found the comfort of those online willing to teach, and help others like it seems he is being shown here.

The mentality of those taking boot camps, and the mentality I had when I started coding are vastly different, but I can see the use.

sine and cosine last year? Now I want to know what your parents are feeding you!!! ;)
(comment deleted)
I also picked up sine and cosine at around that age; it was thanks to programming.

Various example BASIC programs (e.g. Lissajous curve and circle plotters and such) used those functions and from their behavior I kind of picked up the relationship to both undulation and the circle. I found out about the arctangent function, and from that I realized that it could be used for 3D projection. I made a proof-of-concept program that mapped some connected points in 3D (boxes and whatnot) to 2D by calculating the visual angles using arctangents: i.e. I plotted the angle between the line of sight and each point, rather than a simple planar projection. It resulted in the objects appearing in a very nice "fish eye" perspective on the screen, which was very pleasing. From all that I learned about radians also and how there are "two pi" of them in a circle, since the functions accepted radians and not degrees.

You know how they say that necessity is the mother of invention; it's also the mother of learning trigonometric functions and whatever else.

Much better motivator than math classes in school too
Similar age for sin/cos. I wanted to move a game object in a circle that I used to develop amateur content for. I remember being wowed by light displays some scripters put together at the time (there was no particle system at the time).

By the time it came around, I was disappointed to learn about all the "triangle stuff". I want quite there enough to make the link between right angle triangles and a circle but it made that topic so much easier to connect.

Thanks to programming and the thought patterns it drums into you, I was able to do my maths course work in a few pages (far less than anyone else) but still achieve high marks. I remember one top performer in my class complained to my teacher because of how little I'd produced! The teacher said "doesn't matter - he used an approach that let him do that".

I learned how to use sine and cosine for drawing circles when I was probably 9 or 10. It was years before I found out what they actually mean and how they work. I didn't even know what the curves looked like.
I've got a 10 year old who's been making a lot of stuff in Scratch since he was 6. I've been trying to think of how to phase him over to less limited languages and wasn't aware of blocklike.js, so thank you for that idea.

Having a lot of projects that you don't finish is completely normal, so don't worry about that.

>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.

Is this serious? I started programming around 9 or 10 on a Commodore 64. I would go to the local library to get programming books for it. Now you can hit F12 in your browser and get a powerful console into JS. JS is fine, encourage the thirst for knowledge.
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.
JS was my second language (around the same age as he is, which is more than 15 years ago) and it is still my favourite one. You give zero arguments but I won't make the same mistake:

- devtools are unmatched for browser development (and getting better for node)

- absolutely best language for prototyping (dyn. typing, monkey-patching, eval, and a lot of other "evil" things you usually don't need in further phases but it's really great to have them for this exploratory phase)

- I respect that some people prefer static typing and code-completion but I prefer writing tests and having few well-known libraries for which I don't need completion at all

- no threads, no mutexes, no locks

- object literal, rest-spread, destructuring, classes are just ordinary (and mutable) objects, etc...

If you think people are doing JS just because it's the only language in the browser (not true anymore) you should seriously reconsider. There were to-js compilers before and it was always awful (remember gwt? dart?)

Of course, it depends on use-case, JS is not the best language for everything.

Transpilation certainly has been important, but in no way is that the only or even the most important advance. The most significant advances are the massive changes in architecture that have turned it into a modern, fully-featured language. You can use most of those in all modern browsers right now. It might not be the best language, and isn't a great choice for a first language to learn, but it is a good one to learn next.
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 point when the average user downloads and installs GBs of data just to play the latest game hype like Fortnite.

The only people who mind installing stuff are predominately web devs. 99.9% of users out there are fine with it for more than 6 decades now and that wont be changing any time soon.

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/

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.
Sanitize your data and you will be fine. Need more static checks? use flow or typescript, but most of the time they are irrelevant. Nice attempt at disguising the usual bs the-code-you-will-never-see-in-prod complaints with that equality table.

I'm sorry you are butthurt over your job, don't try to nitpick on minor things to dissuade others from enjoying the unparalleled power that comes with JS and its ecosystem.

This kid is practicing calculus at 12 years old. He will be able to handle a package manager.
It's still a waste of his time to deal with it. The brain has only so many ultra-neuroplastic years, why burn them on dicking around with npm when they could be leveraged to focus on more universal concepts?
because "full-stack"

JS is the New York of languages: dirty and gross and hella expensive, but if you can make it there, you can make it anywhere.

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

The only thing you need to learn programming with JS is a text editor and some rudimentary HTML knowledge.

Everything else is unnecessary, at least as far as the programming language itself is concerned.

You need none of those things to get started with JS development

It’s still perfectly possible to just create a html document, shove in a script tag, and start developing

And if you want to use packages from the npm ecosystem you can easily use https://unpkg.com/

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.

Us old people tend to forget things.

Also, if you use JSDoc a lot of modern editors can use that to automatically provide type hinting, documentation references on mouseover, etc.
Comments in a twelve-year-old's code? For whom? Seven-year-olds? (I'm serious.)
How about for a 32 year old who is just learning JavaScript and comes across this repo? Age has nothing to do with it.
Why not learn good programming practices at an early age?
Perhaps for himself when he's thirteen or fourteen and wants to refactor
You are amazing, keep learning more. :)