Shared publicly  - 
 
Teaching Javascript as a first language.

Funny how at first sight this seems crazy, but after just a few seconds of balanced thought actually makes sense. Isn't JavaScript a weird language with a lot of warts? Yes, but isn't any other language too? When teaching it, you're free to show some parts and hide others.

What really "sells" for JS is that it's probably the only language currently with which you can start to write interesting programs with graphics (go HTML5 canvas) without actually installing anything (*). For Python you'd minimum need to install Python itself plus some kind of graphic library such as PyQt or maybe Pygame.

With JS it's also by far the easiest to share your program with others instantly via the internet, without needing to email it around and expect others to install the same environment.

(*) Assuming you have a fairly modern browser.

P.S. This is what I did to learn some JS & canvas a couple of years ago: http://apps.thegreenplace.net/colorful_lines/ - I love this game :)
JavaScript as a First Language. At Khan Academy we've been investigating teaching Computer Science to students in some new and interesting ways. The most interesting aspect of which is that we&#39...
5
Senthil Kumaran's profile photoEli Bendersky's profile photoTal Cohen's profile photoReid Kleckner's profile photo
11 comments
 
It certainly makes more sense than teaching C++ as first language. (remember סי פלוס פלוס כשפת אם, which at some stage included an MFC chapter...)
 
You need to install a browser to use javascript and then learn concepts such as dom and html. You don't need pygame or pyqt to learn python - I think this is actually harmful as it introduces needless complexity. Also importing python moral values early in the developer's life I'm sure will yield a lot more benefits later.
 
+Elazar Leibovich I don't remember, actually. I have a strange feeling of nausea overwhelming me every time I approach a Hebrew book on programming ;-)

+Alex Plugaru Well, if you're learning programming through Khan Academy, you already have a browser installed (seriously, are you familiar with many technically inclined people who don't have browsers on their computers?), and a JS-capabale one at that.

For basic JS learning you certainly don't need to understand HTML, DOM or CSS. The example of canvas vs. PyQt or Pygame was simply to emphasize that a graphical environment is useful for teachnig since it's a fun ground to learn programming with (i.e. writing a simple game)
 
I think it's a very appropriate idea. You get very strong output facilities -- images, text in colors/sizes/fonts with very little "price" to pay. If the target audience is children, this is much more attractive than command-line programming.
 
+Eli Bendersky I disagree. You need to have a <script .. somewhere in your index.html - immediate questions: what is a tag, what is html? Before you start to explain how to run javascript you need to explain that javascript runs with a context. Explain that javascript is the scripting language of the browser and has attached a thing which is called DOM. You can't get around this. IMO it's a bad choice for a first language. Too many concepts to grasp.
 
+Alex Plugaru when you teach something, it's very important to just leave some things unexplained. Otherwise you'll quickly end up teaching quantum physics to make your students understand why computers work at all. A basic HTML template that contains a simple canvas is one thing that can definitely be "left for later", focusing on the JS programming first.
 
I might actually disagree. While it can be touted as a good language for beginners given readily available interpreter on most browsers. Teaching it it as language can inculcate incomplete software design ideas. C let's one go close to the machine. C++ shows that there is greater world with lots of ideas. Python is simple and easy and makes complex things possible. js is gaining a lot of a favor with new frameworks and for all practical purposes these days people mean jquery when they are using it for any big task.
 
+Senthil Kumaran C++ shows that making a language both expressive and efficient is freaking hard, which is an important lesson, but I wouldn't say it's needed right at the start.

Also, AFAIU (which admittedly isn't much) jQuery & friends are tuned at simplifying the web-interface parts of JS. The core language doesn't need any libraries to be useful.

Yes, the language is a bit problematic from a design point of view. But the ugly parts can be hidden in the beginning, and I also like Resig's ideas to use some linting tool from day 1 to ensure good programming practices.
 
There's nothing wrong with teaching (basic) HTML first. Gives a good understanding of how code has to be exact (you forget a ">" in a tag and everything goes thataway, for example). Then, to make the HTML useful for JS output, all you need is to introduce IDs and getElementById, followed by either setting attributes or assigning to innerHTML. No need for any knowledge of DOM beyond that (for basic, useful programs for beginners).
 
Been said, but +1 for taking the webdev route into programming and CS. My friends who learned C++ had to email us executables to show us their latest program, while all I had to do was send a link, and I eventually transitioned into PHP and made the whole thing social.
Add a comment...