Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What do you think about teaching JavaScript as the first programming language rather than Python? I know that some think JavaScript is a better choice [1], because it's so much easier to produce a real application as opposed to a command-line toy. But the opposing argument would be that JS has so many flaws, or more charitably, it's such a quirky language. Also, any opinions about Khan Academy's platform and lessons for learning to program with JavaScript [2]?

I'm not a parent, but my friend's 10-year-old son has asked me to teach him to program.

[1]: http://prog21.dadgum.com/203.html

[2]: https://www.khanacademy.org/computing/computer-programming



As a former teacher, who ran a programming club at a middle school and taught an advanced 8th-grade math class included programming, I have some perspective on this. I would say, be wary of "fundamentals" and "doing things the right way." Teaching a 10 yo something optional needs to be fun, or else it won't happen.

The author of this article nails it: there's nothing quite as motivating as adding "Poop" to the title of a real web page. Also, you can Inspect Element and get what is effectively an IDE. Is JavaScript the best language? No, it's inconsistent and confusing. But, so is English, and a lot of people learn English first - because it is practical to do so.

Another option that can be useful are Google Sheets. If they are a certain type of kid, they might like logging all of their toys in a spreadsheet and finding the total of the toys and making charts. Of course, most kids will find this boring... but you can also use Google Scripts to do something like scrape a subreddit and store it in Drive [1], which could be fun.

However, why not start with Scratch, or Snap! [2]? They are powerful enough (especially Snap!, I think you can define new data types in it...) and so much less intimidating.

[1] http://ctrlq.org/code/19600-reddit-scraper-script [2] http://snap.berkeley.edu/


> Teaching a 10 yo something optional needs to be fun, or else it won't happen.

That matches my intuition. But the word "fun" brought back to my mind this epigram by Alan Perlis:

> It goes against the grain of modern education to teach children to program. What fun is there in making plans, acquiring discipline in organizing thoughts, devoting attention to detail and learning to be self-critical?

Unless I have completely misunderstood this epigram, I think the point is that programming, when done well, is not fun; it's work. So maybe if we try to make programming fun so we can teach it to a child, we're setting bad expectations for what it will be like if they pursue it seriously.

So I guess that means that when teaching programming to someone of any age, we do need to focus on fundamentals and the things that Perlis mentions in that epigram. Then, if a 10-year-old kid loses interest, we should just let it go.

Makes me wonder if I and other self-taught programmers of my generation (I was born in 1980) built our careers on a bad foundation. I started learning to program in BASIC on my family's home computer when I was 8 years old, because when just dabbling in BASIC, it was fun. Even tinkering with assembly language was fun. But the important thing to note is that as far as I can recall, I produced only one truly worthwhile program as a pre-teen, and that was one that a relative asked me to write. And that was a serious project, not a diversion (AFAIK, the latter is the definition of fun, as is apparent from some languages like Spanish).

As for Perlis's jab at "modern education", I suppose the take-away is that we need to teach kids early that life isn't fun, rather than trying to make everything fun for them.


"because its like English": best argument for learning javascript I've ever heard.


What I find makes teaching programming in JS challenging is that, by its very nature, there is a lack of a single canonical resource that you can go through to build out your understanding from start to finish.

This isn't to say that such resources don't exist, but the fact that Javascript is the language of the web will simply make it impossibly difficult to follow a nice coherent pattern and you/the child will instead inevitably slowly drift to other things, and the risk is moving onto other concepts before the necessary scaffolding is in place and before they have a firm grasp of basic programming principles. Since the "web" is right there, it will be hard to fight the urge to start to do "engineering" while the focus should be on basic cs and programming concepts.

My advice (former school administrator) therefore is to teach programming to a kid using a canonical resource that they can use as a bible, but one also that will give them the freedom to build interesting things that they can share with others. I think Matthias Felleisen's HTDP is a fantastic book. You simply can't beat it when it comes to talking about patterns, design recipes, and overall how to test and think about an algorithm. And while the syntax may be challenging at first, functional programming and LISP in general actually offers less of a mental leap for kids who are used to algebraic expressions and function composition.

If this is a gifted 10-yr old, HTDP with some adult guidance will offer you the best bang for your buck long term. Some of the projects at the end even involve networked games, so there will be plenty there to motivate a hungry youngster.


Thanks for sharing your perspective and advice. What do you think of Pyret (http://www.pyret.org/) and the accompanying textbook (http://papl.cs.brown.edu/2015/)? That should meet your criterion of a canonical book to work through. And that book is written by one of the authors of HTDP. But Pyret has a more conventional syntax and runs in the browser.


Ashamed to admit I don't have any familiarity with it! I can vouch for other content of Shriram's that I came across, most notably some of his labs for his CS class at Brown -- they are absolutely awesome. So, I've got a feeling this is a prob. also an excellent book.

EDIT: I forgot to add this: I mentioned that the syntax is challenging to kids at first BECAUSE there are so few rules, there is quite a bit they have to keep in their head as they write even very simple programs. You have to very quickly internalize the idea of function composition or else you are stuck, and that may be challenging for a young child at the beginning. But, at the same time, I think this is also a huge STRENGTH of the syntax. If he/she isn't getting this, it is pretty obvious and you simply cannot go anywhere until this happens, which isn't necessarily a bad thing. And, once they grasp this concept, then it is actually extremely easy because there aren't really any other syntactical rules to memorize and keep in order! This did require a lot of focus of kids, but I think there was something reassuring in the fact that they felt confident they understood all of the necessary principles of how the language was working, and that if they experienced issues, it was either in their own logic or in chasing some rogue parens. YMMV


What makes a canonical approach ideal? In my experience, there are few jobs worth having that provide a bible. I can see that a bible would be a convenient teaching aid, but it misses a great opportunity to teach research skills as well as critical thinking and discretion. Please let me know if I'm way off base.


The most valuable thing you could give a young learner is a solid foundation upon which to scaffold future learning. You are absolutely correct in saying that research skills and discretion are hugely important and valuable. However, someone who hasn't yet build a solid foundation of understanding will have a VERY hard time assimilating content he researches into a coherent mental model of how everything fits together.

Therefore, my advice to begin with a single canonical resource is that this increases the likelihood that someone's introduction to this stuff will be coherent and well-reasoned, and will introduce him/her to solid fundamentals. As someone who has been involved with teaching kids and coding, it is unfortunately very much the norm that "coding" classes devolve quickly into copy and paste exercises, and the reason for that is that is that kids' gap in understanding ends up simply being replaced by pattern-matching.

With programming, you have so many competing motivations/factors -- what you want to build, what you are learning, why you are building/learning, etc. -- that it becomes quite challenging to juggle everything coherently. I've always favored a single canonical resource to start because, more than anything, it is a way to drown out that noise. If you pick a good book, there is a rationale behind the order topics are introduced and there is reason to the increasing complexity and difficulty of the exercises presented in the book. If you hop around doing different things, you massively increase the chance that there is some basic concept you won't learn and that you will start creating an improper mental model of how things work. And, without this canonical resource, you may have a really hard time seeing that the reason you are struggling is because you lack some basic understanding.

So, I agree with you that there are no jobs worth having where a "bible" is provided; but I think that a learner -- and especially a novice learner -- greatly benefits from a resource like that to ensure that they have solid fundamentals onto which they can then graft other knowledge they seek out themselves.


Thanks for the thoughtful response. I think I see where you are coming from now. Now that I think about it, I even have some personal experience with the benefits of canonical learning.

I was a copy and paste web-developer for a while and it got me by but just barely. At some point, I discovered Michael Hartl's Rails tutorial. Rails was pretty foreign to me compared to the basic HTML/JavaScript stuff I was doing but I found it interesting and gave me the opportunity to learn web development from first principles.

Learning Rails in that environment made me a much more thoughtful and deliberate developer. All my applications since, even though they aren't in Rails, have benefited from that experience.

I have had personal experience with being commissioned to write a comprehensive resource for work. It is really a futile task in a lot of cases. Things change so quickly that they are different before, during, and after the writing and editing process. This does allow for the room for the learner to fill in the gaps and develop critical thinking and discretionary skills.

I think I was seeing this as too black and white when there are many shades of gray.

Once again, thanks for the education.


IMO (and I dislike JS) it doesn't really matter. If the kid is really interested, they will go out of their way to learn new languages eventually.


This may sound strange, but maybe even Visual Basic or C#?

It allows you to easily create GUI applications and I assume thats what's interesting. Switching to other languages is easy enough, but capturing interest is key.


I would never inflict JS on a kid I liked


Is that just knee-jerk dislike of JS? If so, that's nothing new. Haters gonna hate.

Or are there specific language misfeatures that you think get in the way of learning?


I think JavaScript is a perfect entry point in a way that Python doesn't seem to even try to be. Sure there are warts and syntax problems and it's a little weird but beginners for the most part won't even run into that. But for that one small, minor downside, all of the upsides far outweigh it. It's used everywhere (almost literally) so it will always be relevant. It's super trivial to get something to print graphics on a screen, where Python graphical frameworks are scattered, outdated, or limited in functionality. Compare PyGame to Phaser and you'll see what I mean.

JavaScript is the right way. Python is right for a budding computer scientist who won't care that they're limited to a terminal for months while they learn. Javascript is right for everyone else who wants to see some immediate and modern progress while they're learning.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: