Live data from Hacker News

John Resig: JavaScript as a First Language

ejohn.org

71–80 of 228 posts

Re: John Resig: JavaScript as a First Language

#71
I am so looking forward to a huge army of newly-trained programmers who view prototype-based inheritance as the default and classical inheritance as weird.

Similarly, I look forward to a whole set of various modules and libraries to graft prototype-based inheritance onto existing languages like Ruby...

cackle

Re: John Resig: JavaScript as a First Language

#72
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)?

As every PHP programmer knows today, and all of us Applesoft BASIC and Apple Pascal programmers knew when we were beginners, OOP and FP are unnecessary stumbling blocks between a new programmer and a very large class of fun computer programs.

Re: John Resig: JavaScript as a First Language

#73

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

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 the same thing in JS is far more boilerplate and much harder to explain why you have to fight the language to accomplish something as simple as a class.

Sure, you probably shouldn't learn CS without at least a general understanding of JS, but I definitely think that CS is the next logical step for the second semester.

Re: John Resig: JavaScript as a First Language

#74
post #49

Earlier quoted context omitted.

One might say the same about the English language, yet it is taught in classrooms all across the United States, despite the fact that the U.S. has no codified national language. English is the de facto national language, but nothing more. So why Javascript as a first language? Probably the best argument is that it has the widest reach of any programming language in use today because Javascript will run in any web bro…

The fact that something is popular doesn't make it necessarily good, so your best argument is no argument at all. Same as with English - no connection whatsoever to a programming language, it's a bad parallel.

I think the argument is more along the lines of "javascript is ubiquitous, therefore learning javascript is likely to be useful (despite drawbacks created by its idiosyncrasies)."

Re: John Resig: JavaScript as a First Language

#75

All decent suggestions. I quibble with this, though: // Don't do this: function getData() { } // Do this instead: var getData = function() { }; The assignment is righteous, but by omitting the function’s name, you make stack traces more difficult to follow. Better this instead: var getData = function getData() { };

I definitely agree with your point about stack traces - I've used var x = function(){} for some projects, but have found in practice that named functions are very much worthwhile when dealing with stack traces?

What's the benefit of var x = function x(){}? Is it just illustration that functions can be assigned to variables?

Re: John Resig: JavaScript as a First Language

#76
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 whole numbers, because all numerics are f%!#^&ing floating point numbers...

Given that the language is such a mess, I think it would induce a new programmer to compartmentalize their JS learnings as a bunch of special case hacks instead of discovering broad language principles that are applied consistently across the language.

Re: John Resig: JavaScript as a First Language

#77

Earlier quoted context omitted.

If widest reach is your criteria, Java and C would also be equally good choices. Unless the web browser is special in some particular way that makes it 'more worthy' than other execution environments?

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.

Re: John Resig: JavaScript as a First Language

#78

Earlier quoted context omitted.

I struggle with this mindset. It probably makes sense for Khan Academy, but this industry (software development) needs fewer people who refuse to learn anything unless all obstacles are removed and the information is spoon fed.

I find your statement to be amusing considering a lot of the anti-JS comments on this thread are about how unwieldy it is as a language. Of course, your critique and those complaints are two different things. You are criticizing that people are too coddled about having an accessible environment to program in. The complaints are that JS is too unfriendly and muddled, and so does not coddle beginners enough!

Installing the required tools to use a programming language is a very different kind of challenge than learning the ins and outs of a programming language with lots of gotchas.

When you work as a software engineer, you're expected to be able to install and operate just about any programming environment out there, so you might as well get used to it. Installing any of the big popular programming environments is pretty trivial, Eclipse, Visual studio, Racket scheme, Ubuntu and even the Haskell platform all come with a graphical installer and a comprehensive manual. Learning a new skill is not needed.

Now learning JavaScript wtf's is something entirely different. Stumbling upon one of these issues mentioned in the article while trying to learn to code is very difficult and disheartening.

Re: John Resig: JavaScript as a First Language

#79
post #30

Earlier quoted context omitted.

I have to agree. BASIC is a far better option. It will obviously never be used for anything, but it will teach the student basic concepts like output, input, variables, etc. These are not simple concepts for somebody starting from zero!

But, but, but, Dijkstra ! In all honestly, I started out learning BASIC on Apple IIe's, and have managed to become an okay programmer. I would support it as a learning language. That said, I don't know that BASIC's syntax is that much easier for beginners than javascript. I mean, there's no braces or semicolons, but a lot of the control structures are basically the same.

Dijkstra could be an asshat sometimes. BASIC is great because it teaches you that a computer can be made to do neat things by following a series of tiny instructions. It gives you that without you having to understand lexical scope, which is, I think, pretty hard to grasp for new users.

Sure, every user will outgrow it, but that's fine. Tricycles are a shitty way to drive to work, but that doesn't mean you should just put your toddler behind the wheel of your car and let him go.

Re: John Resig: JavaScript as a First Language

#80
Yeah, JavaScript will break their impressionable young minds. But you know what? Programming in general will break their minds. Programming is fucked up from any perspective. If they learn a good language first, they will go crazy trying to figure out why nobody is using it. Might as well teach them a language that lets them get stuff done in the real world, while preparing them for the ugliness ahead. They can learn the good language later.
Post reply on HN