JS is great for that purpose. It's very easy to make animations and other fun effects in the DOM or build an extension on top of their favorite site. Once invested they might start research and discover CS fundamentals. Immediately throwing them at typescript without understanding JS could lead to frustration/confusion.
They also might learn an appreciation for things like type safety by not having them. For that reason dynamic languages like Ruby /Python are great. They can execute an idea faster, and if they get frustrated by those types of issues then introducing them to those other languages. Kotlin is cool, but it makes a lot more sense if you have had to deal with null pointer errors before.
> Immediately throwing them at typescript without understanding JS could lead to frustration/confusion.
I don't understand why you think this would be the case. They could write plain JavaScript in a .ts file and get better error messages. There's no downside.
It's also frustrating to constantly have to check docs for JS libs instead of using autocomplete. A good static type system makes coding much faster and require less memorization of things like parameter order or return types in libraries.
Strictness with good error messages is much better for beginners. That's why I use the strictest possible language in professional work: if the compiler can do a bunch of work for you, why not let it?
Strictness is like bumper lanes or training wheels.
As someone who started with JS, I feel like this is a valid point, but also ... not really a big hurdle to overcome later down the line.
It's one of those things that is really apparent when comparing languages, but I'm not sure matters as far as learning goes. No doubt someone has run into someone who can't do anything outside JS, but I'm not sure that is all that common.
I feel like if you're at all capable, it's almost no hurdle, and the benefits of being easy to start, can do some front and back end work, are pretty big.
Thank you for including this in your comment. So many people are trying to force programming down kids' throats when the child may not even have an interest in it.
Programming is the future! Everyone needs to know how to code! Nearly everyone can write some piece of code for use in their every day life to make it easier! I disagree. Code is good for kids who have an interest in it, because after so many months of not doing it, the kids that didn't refresh the knowledge will be nearly at square one.
As far as language choice goes, I’ve tried to teach my son Python and a couple other languages, but he’s not that interested. He’s choosing JS and is self-motivated to learn because he can share his creations with his friends super easily, and because he can edit JS files directly on his website that doesn’t need to run a back-end. That’s not really built-in to any other language. TypeScript is closest, of course, but for a kid the prerequisite of learning npm and a transpiler and installing them on a server are huge hurdles.
Personally, having worked in Python, C++, and JavaScript professionally for a couple decades, I’m not in the least bit worried about my son learning JavaScript and being able to use what he learns in other contexts, not even a little. All languages have oddities, and IMO JS doesn’t have more than any other language, they’re just different. JS is really great for asynchronous thinking and quick to prototype interactive web pages and games.
This by far beats the maze games I would program in basic back in the 80s.
Programming to make their homework easier? Great.
Programming a game they can show their friends, that lets them compete to get a high score? Great.
Programming some interesting scripts into minecraft? Great.
Programming to learn to how to reorder a red black tree? ="programming is boring"
That said, Ruby and JS are not great languages for teaching fundamentals. They (especially JS) have a lot of weird design decisions that don't translate to other languages and don't map neatly onto problem spaces.
If you insist on JS, start with TypeScript at least. But maybe D, Kotlin, Go, or Dart would be better to teach general concepts.
Python would be a good add-on because they could actually use it to write quick utility scripts and, eventually, data analysis.
Instead of linear programming exercises, it may be easier to find problems they find interesting and help them Google their way through solving them. Maybe they have some tedious homework they could learn to automate.
The problem you'll find is that kids don't do much work, so programming (i.e. making a computer do work for you) isn't necessarily that exciting yet.