Live data from Hacker News

John Resig: JavaScript as a First Language

ejohn.org

191–200 of 228 posts

Re: John Resig: JavaScript as a First Language

#191

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 (…

And made the mistake of making whitespace significant thereby driving off people in droves.

[deleted]

Re: John Resig: JavaScript as a First Language

#192

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 (…

Javascript in a simple way.

http://img856.imageshack.us/img856/306/javascriptinasimplewa...

Re: John Resig: JavaScript as a First Language

#194

Earlier quoted context omitted.

Assume you've never programmed before. Would you want to debug a program that has a significant whitespace bug? It's much easier for the average person to spot an unbalanced parenthesis that an incorrectly sized whitespace. Getting stuck and being frustrated hurts motivation a lot. Now curly brackets and syntax may be seen by a person as an irritation or inconvenience compared to whitespace, but I'd say it's better t…

"""Assume you've never programmed before. Would you want to debug a program that has a significant whitespace bug? It's much easier for the average person to spot an unbalanced parenthesis that an incorrectly sized whitespace.""" I'd argue that for a beginner it's equally difficult. And how about this equally difficult to spot classic bug: if (f==x) do_something() and_also_do_this() //oops! a language with significan…

Why is this hard to catch? Format your code and the incorrect indentation goes away. A beginner should be taught to run the formatter to keep the code neat.

Re: John Resig: JavaScript as a First Language

#195

Earlier quoted context omitted.

You're mistaken if you don't think a shit ton of people dislike Python exactly because of significant white space as well as it being the source of a great many bugs. As for Smalltalk, yes, they do like them, since faking them by passing literal hashes is a common pattern.

"""You're mistaken if you don't think a shit ton of people dislike Python exactly because of significant white space""" Those people don't use Python anyway. There are a shit ton of people disliking anything you can think of. I don't know of many people that tried actually USING Python and still dislike the use of whitespace. I also don't think the "whitespace haters" are intelligent about it or have any basis. For o…

The issues around significant white space are well known and well blogged about, I'm not going to re-argue them here; google it you must, it's an old argument. If it doesn't bother you, so be it, but you're not going to sell me on it because it's crap; I can't stand Python.

If you don't think it has ever caused bugs, then you aren't thinking very hard or you've not looked into the opposing point of view at all. In any case, I'm done discussing it with you.

Re: John Resig: JavaScript as a First Language

#197
post #155

Earlier quoted context omitted.

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.

[deleted]

Re: John Resig: JavaScript as a First Language

#198

Earlier quoted context omitted.

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.

Ok, I see your point. But perhaps one can learn Computer Science much more efficiently after already knowing how to program? It doesn't seem likely that you'll be very open to learning data structure design and asymptotic complexity when you're still wrestling with for loop syntax, the difference between assignment and reference, what the hell recursion is, etc. You have to learn to walk before you can learn to run, and while jumping in the deep end may work for some, I'd guess most would find a more programmer-friendly introductory language a quicker path to comprehending basic CS concepts and would subsequently be in a much stronger position to tackle C.

Re: John Resig: JavaScript as a First Language

#199
post #99
post #34

I want to take this further still. Most JavaScript programmers already use a subset of the language and I believe that there is quite a broad union of those subsets that should resonate with the majority of us. Excluding certain parts of the language will lead to more robust code that is easier to reason about (and more fun to write), I claim. My attempt to formalize it is called "restrict mode for JavaScript" http:/…

I think Resig means to use JSLint throughout, which does something similar. Additionally, browsers already support "use strict" which is also a restricted mode. In short, plenty of people share your views on the matter (me included). The whole thesis of JavaScript: The Good Parts was basically that, and the book is one of the best on the language.

The major difference is that JSLint as well as "the good parts" focus on a subset that can be verified statically (before running the program) while restrict mode sanitizes operator semantics that must be verified dynamically (when running the program). I like the few changes strict mode did except for one thing that breaks compatibility in an unfortunate way (this is bound to the primitive, not the boxed number). But we should take all this much further.

More important than anything I'd like us to start talking about sane subsets of JS more, and stop limiting ourselves to what one author considers "good" because quite frankly, _that_ subsets still contains a whole lot of awful stuff.

Re: John Resig: JavaScript as a First Language

#200

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 (…

And made the mistake of making whitespace significant thereby driving off people in droves.

In the (vain) hope of arresting the whitespace flamewars:

http://c2.com/cgi/wiki?SyntacticallySignificantWhitespaceCon...

Post reply on HN