by MarcScott · 12y ago · 0 comments
My main reason for the switch is to overcome the "What's the point of this?" questions that I used to receive. With JavaScript the kids instantly see a result on a platform they're familiar with - a browser. window.alert() is instantly recognisable to them and seems far more relevant than print"" where the output is only visible in a terminal or IDE.
Eg. > [2,1,3,10,6, 200].sort()
[1, 10, 2, 200, 3, 6]
is both unexpected, and is just one of many landmines that can completely derail beginners.
C was hard for some kids to grasp in my high school class, but I didn't struggle with it, and it certainly taught me rigor and attention to detail. Ruby (on and off Rails) helped me build things without getting bogged down in syntax; the LOC-to-output ratio was quite gratifying. Only later did I progress to writing non-trivial Javascript.
While it's an incredibly powerful language (when I hear people describe the "enlightenment" of developing in Lisp, I'm often reminded of JS), it has a lot of warts that, as you rightly stated, can throw beginners for a loop. I imagine that if I had encountered the example you described above at the beginning of my career, I would have decided that Javascript is for the birds and resolved to just write C/C++ for the rest of my life.
One option to make js a little easier to start with is to install a CoffeeScript plugin. Not sure if it's a good idea, but it's an option.
Also, one nice side-effect of getting them started on javascript is that learning another language (ruby or python, perhaps), is a wonderful next step because suddenly you're using a much 'friendlier' language! Whereas if you start with that, having to deal with js can be frustrating.
http://marcscott.github.io/7-WD-JS/
I'm sure there are better offerings out there though.
For an undergraduate level course I would prefer teaching Scheme or C in an introductory class.