7 ms·
JavaScript at Khan Academy
- TeeWEE 15y agoMost. Stupid. Idea. Ever. JavaScript is a language that misses a lot of important CS and the most important of all is language build in modules. Apart from that you should start with either a fully functional language or a fully imperative OO language. These are theoratical distinct language classes. And JavaScript is in the middle, you will confuse people. At my university they started with Java.. also not the best choice. However OOP is very important and just neglecting that initially is not a good idea. From a theoretical point of view, javascript is not the best language to start with. In fact as a language, its quite inferior to other function-imperative language such as Python.
- dpearson 15y agoI would disagree in this case. The mere fact that a JS engine is present in any browser alone makes it compelling for those that have never programmed before. There really is no setup, and the OS becomes (to a degree) irrelevant. Further, javascript is an easy language to prototype in, and, at the basic level, easy enough to teach and write.
- untog 15y agoI think you're both coming from different directions, here. For Computer Science, it's a bad choice. For Computer Doing, it's a good choice. Not passing judgement either way, but I doubt you're ever going to agree with each other on this basis...
- judofyr 15y ago> There really is no setup Except for creating an HTML-file and understanding how all that works. > and the OS becomes (to a degree) irrelevant. This is pretty much true for any language as long as you don't use platform-specific features (fork). > Further, javascript is an easy language to prototype in, and, at the basic level, easy enough to teach and write. "Easy language to prototype in"? Both Python and Ruby are equally "easy", but comes with even more batteries included. They also have a consistent object model, as opposed to JavaScript's prototype-inheritance-is-cool-but-let's-mix-in-constructors-from-classical-OOP. There's pretty much nothing like JavaScript's prototypes in any other languages (Self/Io works quite differently), and I don't really see any gain in teaching that to students early on.
- dpearson 15y agoMy comparison on setup was mostly in comparison to the effort in setting up a toolchain or an interpreter, in a situation like this where you have to support users on different OSes/hardware without spending valuable teaching time on it. I do have to agree with you about the ugly mix of inheritance models, but for the initial teaching phase, you could largely ignore that before moving on to a different language to teach either true OOP or functional programming.
- benihana 15y ago>Except for creating an HTML-file and understanding how all that works. Using chrome? Hit [ctrl+shift+j|cmd+option+j] and you can write JavaScript without any HTML necessary. Other browsers have similar consoles that need no HTML to write JavaScript.
- judofyr 15y agoRight. Let's teach programming in an environment that we never use to create full projects. REPLs are fine to experiment with, but it's important to learn how you would write "real" code. Dumbing down this essential concept is just silly.
- simonw 15y agoCompletely disagree - I write most of my production code in a REPL (either JavaScript or Python), and only save it to a file once I know it's going to work.
- judofyr 15y agoI'm not against using REPL, but it's not viable to solely write in REPLs, therefore we need to teach "how to run things in files" and then we're back at crappy HTML-files.
- syaz1 15y agoI don't see anybody saying one need to use REPLs only. What's nice with JS is you have the option to open browser's JS console and try stuff there. You don't need to. But you can. All modern browsers has JS console. That's dev environment setup freely for you. And if you use FF, enhancing that env with Firebug is just a few clicks away. WIth the rise of web apps nowadays, this is actually a very good move.
- tdicola 15y agoAs someone with a traditional CS background who's learning JavaScript & HTML5 right now, I have to agree that learning JS in the context of a web browser feels like a poor choice for beginners. There are way too many gotchas, hangups, incompatibilities, etc. with browsers and a big domain of knowledge to learn with the DOM. That said, I think if you teach JS in the context of Node.js with liberal use of quality npm packages like mocha for unit testing, etc. it could be a fantastic environment for beginners and ease a lot of frustration. Just having a REPL is reason enough to use Node for beginners.
- yonran 15y agoI disagree. The obvious benefits of Javascript in the browser are that it is distributed universally, can be deployed to others easily, and has a reasonably powerful API (but not powerful enough to shoot your foot). I think the ease of applying the code to real projects can provide an extra amount of motivation to a lot of people who may have no interest in learning either some toy playground or the console. Remember, the introductory programming class is all about teaching students to talk to their computers in a methoidcal, step-by-step fashion. It's not about the finer points of language design.
- judofyr 15y ago> The obvious benefits of Javascript in the browser are that it is distributed universally Pretty much any open-source language is available on all platforms. Besides, you still need to setup an editor, so it's not like you can skip the whole "install software"-step. > can be deployed to others easily In the beginning this doesn't actually matter too much. Beginners are usually aware that they're not creating something that all their friends are going to use, and it's often better to show it to them face-to-face so you can explain things. Sharing code with other students on the other hand is very useful, but JavaScript isn't any different here ("look at my .html" vs "look at my .py"). > a reasonably powerful API (but not powerful enough to shoot your foot) JavaScript has few built-in libraries, and the DOM API is very HTML-specific and a horrible mess. I don't quite see how these APIs make the students become better programmers; just understand the quirks of HTML more detailed.
- cm127 15y ago1. I'm a little confused why you would object to JavaScript as a first language. You're using it to teach very basic concepts like variables and conditionals. Who cares about polymorphism at that stage? 2. Creating a Web App to follow programming concepts is something John Resig knows how to do. Check out his Advanced JavaScript page for examples: http://ejohn.org/apps/learn/ http://ejohn.org/apps/learn/ 3. No installation needed. No one has to have permissions to install or modify software or the OS. That's a huge hurdle. If you're at a public library or borrowing your brother's computer, you don't have to worry about permissions, settings, downloads, etc. You're already setup to start with just learning. Obviously, to become a better programmer you have to learn some more languages, but JavaScript is not going anywhere anytime soon. In fact, there is a higher demand for JavaScript programmers than ever. Why not learn it?
- lars 15y agoIf your argument is that Javascript isn't object oriented, you don't know Javascript. It is very much object oriented, it just uses prototypical rather than classical inheritance. If your argument is that a choice should be made between teaching objects and teaching functional programming, I disagree completely. They are complimentary models of programming that are not in conflict. See the paper "Open, extensible object models" [1] for an example of how the object/lambda combination can be extremely powerful. Considering that, JS lambdas are far more powerful than those in Python (they can have multiple lines, for one). Javascript certainly has design flaws, but it seems like a great fit for teaching programming, in that it is a small language that covers a large number of important programming language concepts. [1] http://piumarta.com/software/cola/objmodel2.pdf http://piumarta.com/software/cola/objmodel2.pdf
- TeeWEE 15y agoJavaScript has prototypical inheritance yes. But if you want to start OO with a prototypical implementation you make it even more difficult for students. Doing proper inheritance, interfaces is more difficult with prototypical inheritance than with "normal" OO. I have too agree some libs make it easier. But that fact that JS needs these libs in the first place is a proof of the fact that prototypical inheritance is not easy to work with. I was talking about functional vs imperative programming. They are not in conflict. But there is a theoretical difference between both of them. And CS is initially about theory in my opinion. Learning turing-completeness, lambada-calculus and logic is more important. Thats why pure language are better at university. About JS lambdas and python... thats just plainly not true. and btw: JS doesnt even have list comprehension! Your last point: JS has a lot of concepts. And that is the main reason NOT to use it, as it will confuse students. But i agree, this point is debatable. It just doesnt feel right.
- tikhonj 15y agoI think the opposite is true--you should start out with as multi-paradigm language as possible, to cover the paradigms in one setting. (If I didn't think this, I would suggest Haskell!) This is why I think Scheme is a great language to start with: it is both a good imperative and a good functional programming language (and it's easy to reuse the syntax for a logical programming language too!). On top of this, it is much simpler than JavaScript or Python--you can learn the syntax in one or two sessions. Coincidentally, Python may be a fine imperative language, but its support for functional programming is pretty pathetic.
- artsrc 15y agoFrom a theoretical point of view what matters is engaged students and inspiring teachers. I would absolutely love to have a talented and passionate teacher, working with a energetic students who love exploring what is possible. Another thing that is important is that it is simple to get quick feedback without time wasting compilation and re-running. You can do amazing things with JavaScript, and some of them you won't do in Python. I agree that modules are important. They are so important I don't think that entirely built in module systems are good enough. You need to be able to bind to private modules, and load and unload modules like OSGI. You need to be able to configure and have multiple instances of modules, like with Spring. It is remarkably natural and simple to create really powerful module constructs in JavaScript. It is really easy to implement a good OO design in JavaScript. I find Python really nice too. Haskell is interesting. I am sure Java is worse than C# in many ways, and better in very few, but even Java has some things I miss.
- egiva 15y agoIf the goal is to learn JavaScript as a first language, maybe it's better to first learn it on Codecademy. Otherwise I really use Khan Academy for everything. Also, JS is not a good first language for anyone. Never.
- deleted 15y ago[deleted]
- brown9-2 15y agoThe prospect of teaching the JavaScript language as a first language is actually really exciting. Teaching prototypal inheritance to experienced classical-inheritance-using developers is normally rather frustrating (and results in many libraries springing up attempting to replicate the classical style of inheritance in JavaScript, which is a whole realm of weirdness in-and-of itself). Teaching prototypal inheritance to someone who has never seen any form of inheritance before will decidedly be an easier task. But does this result in a better outcome for the student? How many other commonly used programming languages use prototypal inheritance?
- SeanLuke 15y agoIn answer to your first question. Prototypes are a much much simpler concept than classes and instances. In prototypes, you create an object X which is "just like object Y but with the following differences". No class declarations, no instantiation, no constructors -- just factory functions. Prototypes are also easily understood by people who have grasped the concept of dictionaries. No need to explain why you have dictionaries and also have classes. Prototypes also have some niceties. They are very memory compact, unlike classes and instances. They are elegantly dynamic -- you can add and delete methods and variables, and even change who your prototype is at runtime. Methods in prototypes are very similar to functions, so you don't have to explain the distinctions there. I think the main problem is that Javascript is such a screwed up language that it has soured people forever on prototype OO and no amount of semantic elegance will fix that. In answer to your second question, here's the list of languages I know of. Only two are "mainstream", but in a field (CS) where quality is all too often inversely related to popularity, I'm not sure if that's a helpful metric. 1. Self 2. NewtonScript 3. Lua (via metamethods) 4. io 5. IIRC Python implements OO with something approximating prototypes internally but covers them with a class-based sheen when presented to the developer.
- tantalor 15y agoIIRC Python implements OO with something approximating prototypes internally but covers them with a class-based sheen when presented to the developer. One notable difference is that `foo.method` is bound to `foo` in python, but unbound in JavaScript. This leads to lots of `foo.method.bind(foo)` because the former didn't DWIM.
- fady 15y agoawesome. looking forward to this, which is coming from someone without any formal education on programming. it will be good to see the difference between understanding the principles via video, vs reading it in a book.
- ejenkinsiii 15y agoyes, Khan going in the direction of programming languages seems abstract I've been waiting for him to take the math video's and organize them in groups of specific studies say for instance all math related to algorithmic studies, specific engineering studies grouped all together like a course this seems like it would be productive to the user instead it seems as though he's beginning to jump on what's popular and add it to the site
- hkolek 15y agoI agree. Their exercise framework can really use much improvement and there are a ton of subjects that don't even have any exercises yet. I would like them to concentrate on math and physics for now and work on really making awesome content and exercises. They should leave the CS and programming stuff for Coursera, Udacity etc. and focus on what they are good at (which programming is not imho).
- iandanforth 15y agoJS is a terrible way to teach CS and it's a terrible first language to learn programming. CS requires a deeper understanding that JS gloses over (obviously) and programming in general can be more easily learned in either a cleaner (python) or more rigorous (java) language. I'm only a few years into my programming career and vividly remember trying dozens of tutorials in half a dozen languages before deciding on really learning through Python. If I were to rank languages to start with they would look like this: Goal: Learn to Program Python, Ruby, Java, PHP - yes, really, JS Goal: Learn CS Java, C, Assembly, C++
- yajoe 15y agoI haven't seen a comment espousing the differences between languages since my early days on /. It's refreshing to see such passion, but I feel compelled to offer some advice: languages are just "tools." No one tool is better than another for all situations. JS seems like a reasonable place to start new programmers. Like anything in software, it has its tradeoffs. Some thoughts: * While the new programmer won't learn about call stacks or different parts of memory (considered essential when I learned to code), the programmer will learn to solve problems using control structures, method calls, recursion, and iteration. These are fundamental skills I see re-used in almost every language. Are there other awesome skills like functional programming I wish they would learn? Sure, but you have to start somewhere, and I support starting at if-else-then logic. * Writing JavaScript is easy. No command line. No installing software. No compiling. No IDE. Just open your Web Console in Firefox or JavaScript Console in Chrome. Seriously, if you are teaching the masses on the internet, what better way than use the very tool they used to view your website? * Writing JavaScript is in fashion. From Node.JS to last week's Tower.JS, JQuery, JSON, or the "new" HTML5 rage: JavaScript is popular. What better way to be relevant than teach what the industry is using? I support teaching popular things to introduce people to our industry. [edited: /. not ./ derp!]
- cmubruin 15y agoagreed!
- khyryk 15y ago
- hello_moto 15y agoSomehow I find that teaching QBasic for a person who has zero programming language might be better than any other programming languages with Python as the other candidate.
- cmubruin 15y agoI actually think that this is an interesting way to get people into programming. I don't think Javascript is sufficient for many applications, but it does serve a great purpose. A lot of youth in the United States today aren't flocking to programming. We need more. And yet it's strange because programming as an industry is what afford young people the most opportunities. When was the last time you saw a major non programming company have core contributors < 30 years old? < 25 years old? JS as a language, TextPad as an editor, and a Browser as a runtime environment is a far less intimidating barrier for students. People can see the results in a medium that's familiar to them (a browser). It's also free and readily available. No installs, no environment paths. nothing to discourage them. In conjuction with HTML, they can see how JS/programming changes what they're viewing. It will help bridge a lot of people's thoughts into "oh, wow, I can actually do this and it has a tangible effect". When growing up I was wondering how the hell a printout to a console would have any benefit to me. Yet, that's how I was taught (in C, C++) It's also been difficult recently to find frontend engineers. Colleges don't train for this - it's all algorithms and abstract concepts that are great for backend developers. That's why there are so many more backend engineers out there than front end engineers. The FE side is under represented. There are some arguments that this is a terrible first language because it's not as rigid as the others. But honestly if you can't learn a language and then apply the concepts and learn new ones to pick up new languages, you probably shouldn't be tackling those tougher languages in the first place. With HTML5 apps coming down the pipeline, people WILL need to know JS and we as a technical industry will need to accept that they too are part of the product/output of science/tech/web/mobile. Some people won't be diving in more beyond that, but if they do, they at least have a foundation to build off of as they get into more robust languages. JS gets people in the door, and it's not going to preclude others from picking up other first languages. It's a solid step for bringing more people into the fold. It's not going to be the best for theory, but there are places and time for that.
- evanmoran 15y agoNo CoffeeScript? =)
- mistercow 15y agoCoffeeScript is great, but it's pretty important to understand JS in order to use it.
- oscilloscope 15y agoI'm working on a CoffeeScript learning environment: http://fleetinbeing.net/beans/ http://fleetinbeing.net/beans/ Still needs a decent JSON viewer before I start on the tutorials. It's a problem that once code is evaluated, it turns into Javascript. JS2Coffee isn't a satisfactory solution. I suspect teaching some Javascript, especially stuff from Crockford's The Good Parts, will be necessary. The advantage of course is it can be compiled and run natively in a browser. The syntax is simpler, but there are corner cases. Though plain javascript also has corner cases CoffeeScript doesn't have, and js syntax is more intimidating.
- vasco 15y agoWith Javascript being the mess that it is I doubt it would be a good starting language, it has too much idiosyncrasies. Most of the post seemed to be excusing Javascript's faults and trying to convince me that I have a problem with said faults because I've been exposed to "better" programming languages. No shit. To be fair, Javascript is the easiest language to teach through a website, but that's it. The goal shouldn't be to make the teacher's life easy rather then providing the right tools for the student.
- rictic 15y agoDon't underestimate the power of the web though. For a new student/user, there's a big difference between step 1 being "click this link" rather than "follow this intimidating installation process". Javascript is not ideal, but it's quite good, and it's there, already running in a sandbox on the student's machine.
- kung-fu-master 15y agoAs CS teacher I'm agree with others that JS is terrible choice as first language. Python is much better. Also Pascal is good option here. Even Java better than JS. What is their goal. It seems that John Resig only wants to teach his favorite language/tool JS. Main goal must be to teach fundamental CS concepts, programming basics, algorithms and data structures. Language choice is must to be appropriate to that goals. He talks about teaching prototypal inheritance, is he serious? For those how have not any prior programming experience. It seems, that he has no any prior pedagogical experience. Why that guy make such decisions and why Khan academy can't hire more experienced CS teacher. Yes, I know, he is great guy who wrotes jQuery, but pedagogy and JS programming is two very different areas.
- tikhonj 15y agoI think Java is a much worse choice--it's less elegant, more complicated and requires treating more concepts as magic. (You can't even write "Hello, World" without a class and a static method!) I think Python is a worse choice because it's also more complicated and less elegant than JavaScript (and it has its own share of pitfalls), but that seems to be a minority opinion around here. Prototypal inheritance is much simpler than classical inheritance--you don't even have to introduce the idea of a class. I think it would be easier to teach prototypal inheritance rather than classical inheritance to people with no programming experience. The last two paragraphs of your post seem to mostly be an ad hominem.
- kung-fu-master 15y agoOk, maybe Java on some cases worse choice over JS. But Java has one preeminence over JS. With Java we can teach more advantage level of software construction. It's construction of medium/large systems. Programming in big. Using classical OOP, interfaces and specification in achieving modularity and decoupling. JS was built for small scripts on web pages. I think Python is a worse choice because it's also more complicated and less elegant than JavaScript (and it has its own share of pitfalls), but that seems to be a minority opinion around here. You wrong, Python is much elegant than JS. Starting from syntax which was derived from C/C++ like languages. With a lot of bugs and confusing behaviors (some of was mentioned by Resig itself). Code in Python is very clear and looks like pseudo-code. It's very easy to read and very easy to start writing in it. JS - specialized language for Web. Python - general purpose language. Prototypal inheritance is much simpler than classical inheritance--you don't even have to introduce the idea of a class. I think it would be easier to teach prototypal inheritance rather than classical inheritance to people with no programming experience. There should be no inheritance for beginners. It's not even core CS concept. No classes, no OOP in any kind of it (prototypal, classical). I think with this approach we will get not CS professionals. We will get JS script kiddies.
- elangoc 15y agoI'll go out on a limb to disagree with most of the comments here and say that I think JS seems like it could be very effective. The Stanford CS101 course page has already implemented decently well: http://www.stanford.edu/class/cs101/ http://www.stanford.edu/class/cs101/ The language you learn doesn't have to be the language you end up using, or using to learn CS. It just has to get you off the ground. So many people get turned off from a subject when they "don't get it" at first, so really, the challenge is providing the least painful intro to programming. Personally, my first languages were Logo and Pascal, and since I almost wrote off programming before Pascal as being too hard, I'm glad I saw C++/Java only afterwards. One thing that enamors me about the JS approach is that it reminds me a little of Logo -- not only are the results are very immediate, but the visual output gives us a constant second avenue of insight into what we're doing. I'm sure many have seen Bret Victor's talk "Inventing on Principle" (http://vimeo.com/36579366 http://vimeo.com/36579366), and he underscores the benefits of direct feedback to what we're doing. I have a friend taking CS10 at Berkeley this semester, and the Scratch-based environment also seems equally cool. That being said, I don't use JS much (haven't really touched in it 10 years), but I believe it when people say it's (still) horribly irregular. In that regard, it might be on par with some other scripting languages (e.g., Ruby). So the distinction to be made here is that JS might be easy, but (as we can see) not simple. As people who program seriously, we need simplicity in a language in order to build up large apps that we can easily reason about and don't bite us in every corner. (Note: simplicity in a language doesn't necessarily mean it's going to be easy at first.) But I wonder if we've been so used to programming that we forget how it can be hard to learn at first, and we're just ruling out the easy approach, which would exclude just what some newbies need.
- tikhonj 15y agoSimplicity in a language is great. JavaScript is actually a very simple language modulo a small set of irregularities. Most of these irregularities go away with "use strict", which is basically the modern version of JavaScript anyhow. (And even more improvements are in the pipeline with future versions, which you are free to use for projects outside the browser!) While there are several reasons why I would not choose JavaScript first for "serious" programming (although it's pretty high on the list), these reasons are shared by most of the other popular languages like Python, Java and C++. (I also think all three of these languages are more complex than JavaScript.) If people who programmed "seriously" actually cared about simplicity and reasoning about code, we'd see much more Haskell in the wild. But instead we see the three unfortunate languages I listed above: Python, Java and C++. (Rounded out with mostly similar languages.)
- oscilloscope 15y agoEloquent JavaScript is a great introductory programming text. You should consider using it in a course. It's available under the Creative Commons Attribution license: http://eloquentjavascript.net/ http://eloquentjavascript.net/
- bobbles 15y agoWould it be possible to build a course around http://www.openwebdevice.com/ http://www.openwebdevice.com/ ? (I assume that a lot of the knowledge would overlap)
- halayli 15y agoI'd use a language that at least got the very basics right (ex: ===, ==, etc..) to lessen the confusion for new comers.
- muyuu 15y agoIs the canvas editor/exercise generator available somewhere as a package? I saw the github code but couldn't find out how that was supposed to run in a portable environment.