Live data from Hacker News

John Resig: JavaScript as a First Language

ejohn.org

161–170 of 228 posts

Re: John Resig: JavaScript as a First Language

#161

Here is my blog article I wrote on this travesty. (Available here: http://blogkinnetic.blogspot.com/2011/12/on-civic-decay-of-u... ) I am not a pugilist for the sake of it, but when I see abominations like this, well, somebody has to take a stand for whatever real programmers are actually left out there. :-) =================================================== When I saw the above article I could only be reminded of H…

Your comment is heavy with comparisons that don't really apply while still not making much of a point. Javascript isn't as low level as other languages but HTML is no more the next step than XML is the next rung down from java.

If you hadn't linked the blog post in your comment I would have thought tl;dr but since you did I tried to wade through all the flowerly language. Your whole post can be summed up as "People who learn javascript first will never learn CS fundamentals" which is unfair and untrue.

Re: John Resig: JavaScript as a First Language

#162

Earlier quoted context omitted.

These are all reasons why I've adopted CoffeeScript over JS. Sure, you can accomplish the same exact things in JS, but they are far more natural with CS and with far less typing. Less typing is less chance for mistakes and bugs and makes an easier learning experience. One other line item is the encapsulation of classes in CS. Doing that in CS is natural and easy to explain to a first year programmer. Accomplishing th…

Seeing as how one of the arguments for teaching JavaScript first is that it lets you teach about prototypical inheritance before the students get used to class-based inheritance, the complexity of simulating a class in JavaScript is probably not the best objection to using it instead of CoffeeScript. If you teach them CoffeeScript, then you will teach them class-based inheritance just like everywhere else, and miss o…

Personally, I treat the `class` keyword as a useful (and powerful) macro for constructing prototypes.

I imagine if someone thought they were building a 'real' class-based program for too long, they'd be in for a few surprises later on.

Re: John Resig: JavaScript as a First Language

#164

wat. This is like teaching postscript as a first language. almost literally.

this was downvoted. Let me make the analogy clear. Javascript is sent by a server to a rendering engine (your web browser), usually a part of displaying a page, though of course also as part of interacting with it. Postscript is sent by a (print) server to a rendering engine (in a printer), as part of typseting a page. It is a Turing-complete programming language, but that's no guarantee it won't make your eyes bleed…

because none of those languages can be compiled and run instantly with any web browser, anywhere on the planet. you can write some javascript and run it right now, without even opening text editor. javascript:alert('hello world') in your address bar. It's that simple. Alerting hello world is not much of a first program, but i'm just illustrating how dead simple it is to get someone to write a line of javascript and see results.

Most beginners these days aren't really interested in your 'robust and scalable applications'. That is not where beginners need to start. At least if they start with javascript, they can see some value in continuing to learn programming. If that brings them to 'robust and scalable applications' then they'll migrate away from javascript if need be. But to say that javascript is far down on the list of first languages is just an asinine reaction that shows you don't really comprehend the problem of getting people to learn to program.

Re: John Resig: JavaScript as a First Language

#165

Earlier quoted context omitted.

Everyone already has a browser, which includes a profiler, debugger, REPL etc. Not everyone has a c compiler or JDK, or wants the hassle of having to set them up just to start learning.

This is an eminently solvable problem. There are excellent open source IDEs and toolchains available that can be repackaged in any way, shape, or form. Double click an installer, and boom - everything's set up. Barrier to entry is a moot point.

Almost everything comes with installer these days, yet some refused to install better, secure browsers since they already have IE by default.

Barrier of entry is a problem.

Re: John Resig: JavaScript as a First Language

#166

Earlier quoted context omitted.

You're looking at the wrong side of it. The subtraction does behave in a perfectly logical manner. The problem is that, given the the behavior of the subtraction operator, the addition operator's actions are illogical. Specifically, I'd argue it's perverse because it breaks commutativity: '5' + 3 - 3 != '5' - 3 + 3 The logical approach would be to only assume that '+' is a string concatenation if both operands are st…

That would be ridiculous because then what would 'hello' + 1 equal? Everyone would expect it to equal 'hello1'.

I would expect 'hello' + 1 to throw an exception. I would similarly expect '5' - 3 to throw an exception. Why? Because you can't add a string to an integer, and nor can you subtract an integer from a string. Doing anything else is arbitrary and unpredictable, IMO, leading to subtle type errors. You want to find type errors early as possible, rather than letting bogus values flow through the program.

I think Javascript is broken here, and Python has it right.

Re: John Resig: JavaScript as a First Language

#168
post #155

For the interested (and with the caveat that I definitely would not suggest it for the Khan Academy's purposes), CoffeeScript does try to address all of the issues that John raises in his post. Type Coercion: There is no `==` in CoffeeScript. You usually write `if x is y` in order to be particularly clear, but if you're in the mode of most other scripting languages, and you write `if x == y`, it will compile to `if (…

CoffeeScript is a subset of JavaScript with bindings to an alternate syntax (CoffeeScript). John's suggestion is an enforced subset of JavaScript, with the advantage that (some) JavaScript in the wild is understandable; error messages are in terms of the source language (very helpful, more so for beginners); and yields a skill with greater marketability (so far). Why not use the same subset as CoffeeScript? In some c…

You totally could; that would be "good" JavaScript. No problem with that.

Some of us like a cleaner, poetic syntax with significant whitespace and a few useful macros; we like CoffeeScript.

Re: John Resig: JavaScript as a First Language

#169

If you want to teach computer science to people then a good first language for them to learn is C, because it will help them think about and understand what the computer is actually doing.

That's an argument for learning C, but not for learning C as a first language. Studying assembler or chip design or even particle physics will also help you understand what the computer is 'actually doing', but it doesn't mean that's the best place to start learning how to program.

I didn't claim that C was the best language for learning how to program.

John Resig's article above is about "teaching Computer Science" rather than teaching students how to program. These are very different things.

That's why I recommended C - because it is very much a language that will teach the theory about how computers work.

I agree that there are other languages better suited for learning how to program.

Re: John Resig: JavaScript as a First Language

#170

Earlier quoted context omitted.

With a standard prompt, you can see the previous output from the program and user input. But a popup window has no context, no history. Of course that's just my opinion. If it could help teach kids good programming skills then it should be used used.

Chrome, Firefox and Safari all have built in REPLs

REPL is not the same as standard streams (STDIN, STDOUT).

You can build a REPL with standard streams, but you can't use a REPL like the WebKit console as standard streams. Where is your STDIN?

Post reply on HN