Live data from Hacker News

John Resig: JavaScript as a First Language

ejohn.org

131–140 of 228 posts

Re: John Resig: JavaScript as a First Language

#131

I'm a fairly experienced programmer and JS still drives me up the wall. The implicit casting and inconsistent operator overloads have led to many unhappy visits to Stack Overflow to see just WTF my browser is doing. I can't imagine the experience being any better for newbie programmers! Even simple things, like bitwise operators, are basically broken unless you take care to ensure that your variables are coerced to w…

Python seems to me like an infinitely better choice. Every language has its warts but bringing up a new generation on a language that even the author admits was a quick and dirty hack takes "worse is better" cynicism way too far.

Re: John Resig: JavaScript as a First Language

#132

Earlier quoted context omitted.

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

It's 2011. We love significant whitespace now, get on with the times...

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 to use a language with an inconvenience than one which is more likely to leave you stuck.

You, I and others used to programming with insignificant whitespace have developed and eye for detail and can rapidly spot a whitespace but. The general population with no programming experience can't consistently space most of the documents in their life, but they can typically place periods correctly.

Re: John Resig: JavaScript as a First Language

#133
post #46

Earlier quoted context omitted.

Also, as stated by John, JSlint will be used. That by itself avoid the big majority of JS' gotchas. And IMO, C++ has way more gotchas than Javascript and that doesn't stop universities to teach it as first language. In fact, I think the first language is not just about giving a strong foundation but also give students the chance to find a good internship. So, with that logic, even though I enjoy hacking with Scheme,…

Well, I wanted to know what IDE JSLint was an expansion for, so I did some poking around... it's an online tool. Meh #1. Next up I thought I would take a snippet from the linked stackoverflow discussion and see what JSLint made of it: 127.0.0.1.toInt(); And... it complained So I did this: var = function() { 127.0.0.1.toInt(); } And it complained (yes, there's a typo) var foo = function() { 127.0.0.1.toInt(); } And...…

Whitespace can be a huge gotcha for novice programmers. Hard spaces? Soft spaces? New lines?

Re: John Resig: JavaScript as a First Language

#134

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

[deleted]

Re: John Resig: JavaScript as a First Language

#135
post #46

Earlier quoted context omitted.

Also, as stated by John, JSlint will be used. That by itself avoid the big majority of JS' gotchas. And IMO, C++ has way more gotchas than Javascript and that doesn't stop universities to teach it as first language. In fact, I think the first language is not just about giving a strong foundation but also give students the chance to find a good internship. So, with that logic, even though I enjoy hacking with Scheme,…

Well, I wanted to know what IDE JSLint was an expansion for, so I did some poking around... it's an online tool. Meh #1. Next up I thought I would take a snippet from the linked stackoverflow discussion and see what JSLint made of it: 127.0.0.1.toInt(); And... it complained So I did this: var = function() { 127.0.0.1.toInt(); } And it complained (yes, there's a typo) var foo = function() { 127.0.0.1.toInt(); } And...…

JSLint is readily available at the command line, and is very easy to plug in to your text editor's build system.

There is also the somewhat friendlier JSHint as a reasonable alternative: http://www.jshint.com/

Re: John Resig: JavaScript as a First Language

#136

Javascript is an absolutely horrible language to use for such purposes. There are far too many gotchas. See the following for numerous examples: http://stackoverflow.com/questions/1995113/strangest-languag...

I suspect Mr. Resig is familiar with the potential gotchas, and maybe even has his reasons for still believing it's still worthwhile. For my own part, as someone who regularly taught high school seniors (and other non-programmers) various programming languages (Pascal, Perl, Prolog, JavaScript, and Java) over a good chunk of the 1990s, I have to say that JavaScript worked out pretty well, possibly even the best of th…

I can see the advantages of JavaScript over Pascal, Perl, Prolog, and Java. Did you ever try Python? What are your thoughts on Logo, Karel, etc.?

Re: John Resig: JavaScript as a First Language

#137

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

I don't understand the (anti) hype about type coercion and the '==' operator. I get a faintly cargo-culty vibe from people when they talk about '===' vs '==', since the examples are usually very strange things that I never see in production. I'm not an expert in JavaScript but I've written a fair amount and a couple largish programs and I've never been bitten by a type-coercion bug involving '=='. The weird subtle bu…

I spent a lot of time trying to track down bug in a system once (in php) that was caused by this. I don't remember the exact problem but basically it did something like "if(x == 5)" which is true for both 5 and "5" - but later in the code it was important that the value was actually 5 and not "5".

But I think the main thing is that for people beginning programming it's better to have less flexibility. In most production system it might not matter that 5=="5" but it's important for beginners to understand how different types work. And it helps give a better insight into how if statements, and boolean logic in general, work.

Re: John Resig: JavaScript as a First Language

#138
post #29
post #4

tl;dr - they picked JS due to its "ubiquity, desirability in the larger workforce, lack of prior installation requirements, and ability to create something that's easy to share with friends" I find that explanation disturbing. Why not start from a language that teaches the basics of the common programming paradigms, such as OOP (Java) or FP (Scheme)?

> Why not start from a language that teaches the basics of the common programming paradigms, such as OOP (Java) or FP (Scheme)? Because that stuff is boring and it drives away a bunch of people who might really get in to programming if there wasn't a huge gap between "just starting" and "doing anything remotely cool". I for one would not have become a developer if my first experience with programming was a typical "C…

Then the problem is the course, not the language. Logo and Scheme are both lisp derivatives. Logo let people make things that were cool. There's no reason you couldn't do the same with scheme, but just giving them some higher order functions early on that display graphics. Later on people can decompose those functions.

The beauty of scheme is that it's turtles all the way down. If you want to see how something works, it's easier to explore.

Re: John Resig: JavaScript as a First Language

#139

I'm a fairly experienced programmer and JS still drives me up the wall. The implicit casting and inconsistent operator overloads have led to many unhappy visits to Stack Overflow to see just WTF my browser is doing. I can't imagine the experience being any better for newbie programmers! Even simple things, like bitwise operators, are basically broken unless you take care to ensure that your variables are coerced to w…

Python seems to me like an infinitely better choice. Every language has its warts but bringing up a new generation on a language that even the author admits was a quick and dirty hack takes "worse is better" cynicism way too far.

I like Python too, and the current CS curriculum on Khan is mostly, if not completely, based on Python.
Post reply on HN