Live data from Hacker News

John Resig: JavaScript as a First Language

ejohn.org

121–130 of 228 posts

Re: John Resig: JavaScript as a First Language

#122

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.

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.

Once someone has decided that they absolutely want to learn everything there is to know about programming and have decided that they love it, yes, there's no point in spoon feeding. But so many of us stumble into what later ends up being our career or passion, and so our first encounter with any type of activity is almost always "hey, let's see if this is something for me." As a society, we need more programmers and scientists and mathematicians, so best make sure that we make that first impression a good one.

Re: John Resig: JavaScript as a First Language

#123

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

Unfortunately I think that class-based inheritence is more general in concept. That is, people who understand class-based inheritence have a very small leap to get prototypal inheritence. You can pretty much just say, "Inheritence works on the instances/objects, not on the class."

Explaining class based inheritence to people who only know prototypal seems trickier. You have to explain the concept of classes and then build from there.

BTW, are there any prototypal languages that support multiple inheritence -- you can create an object from a set of an arbitrary number of objects?

Re: John Resig: JavaScript as a First Language

#124

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.

The existence of things like jquery "on top of" javascript are really no different form having Microsoft Word or Open Office / Libre Office there to 'print' your postscript file.

Like it or not, neither javascript nor postscript are:

- Systems languages.

- Desktop application languages. (As Java can be).

- Low-level language suitable for writing drivers.

- Low-level languages suitable for writing network protocols.

- High-level languages suitable for prototyping very large, complex data structures and relationships

- High-level scripting languages suitable for abstracting away incredible sophistication and power and letting the user program in a very high level mode.

- Robust and scalable applications languags, suitable for putting in a version control system and having a team of fifty iterate on it

They're niche, domain-specific languages, like a Perl regex. Would you suggest anyone's first language be the regex Perl uses? Obviously not.

Appropriate first languages are anything from:

* A fake language like Turtle Logo

* An almost-fake academic language like Pascale

* An "electrical engineer" approach nuts and bolts introduction: assembly.

* A low-level systems language, C, or C++

* A high-level scripting language: Ruby, Python, Perl

* An interpreted systems language: Java.

* A markup language: HTML and CSS

* No language. Configuration files for nginx and other things.

etc etc.

Very, very low on the list would be something like Javascript. This would be akin to editing Adobe Illustrator files in a hex editor. Sure you could end up with an image and an understanding of vector art, but, why in the name of God would you try to learn those concepts in that way?

Re: John Resig: JavaScript as a First Language

#125

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...

No, we don't. Kids who don't know better might think it's cool; it isn't.

Re: John Resig: JavaScript as a First Language

#126
I'm a full-time javascript developer and entrepreneur myself, but I'm wondering why you don't consider Scheme instead, basing the course on the How to Design Programs v2 curriculum?

The people behind that book have spent a lot of time thinking about how you teach programs to people.

More importantly, they focus on problem decomposition and concepts that provide a great foundation for growing.

The reasons I can see for using Javascript first is because everyone has a runtime available at their fingertips (M. Haverbeke's approach of including the console was great.) and because people can immediately see the utility of the language to real world needs.

But does Javascript provide the best foundation for future concepts? Does it teach good habits both mental and in practice?

Ref: The Structure and Interpretation of the Computer Science Curriculum http://www.ccs.neu.edu/racket/pubs/jfp2004-fffk.pdf

Re: John Resig: JavaScript as a First Language

#127
post #46

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...

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... it 'compiles' fine, no complaints. So I thought I'd push the syntax tree button to see what was going on and it tells me:

Tree:

""

Which is less than spectacularly useful.

Oh, I went back and hit the JSLint button again and now it givess me lots of errors for the above code.

Including, but not limited to complaining that 127 occurs in column 1 instead of column 9. But then I try to enter a tab at the start of the line to achieve proper indentation... and of course it doesn't work because it is in the browser and so tab just goes and selects the next control.

Sensational.

If I had to enter all my indentation as spaces, by hand, I'd conclude that the Professor teaching this was a colossal idiot.

Re: John Resig: JavaScript as a First Language

#128

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…

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?

Java isn't a language that promotes "play" like Javascript does, because it's been engineered to prevent you from shooting yourself in the foot. Play helps make learning more fun.

C would be a good choice, except for the fact that memory management and pointers are a very important concept early on in the language that you really don't want to bog people down with that are completely new to programming. I remember a blog post by spolsky about how you lose a lot of people on that one concept, especially if it is poorly taught.

Re: John Resig: JavaScript as a First Language

#129

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

What, no disclaimer that you are actually the creator of coffeescript?? Your comment seems a bit biased to me. But I'd expect nothing less from a coffeescripter.

So you think it's better for someone who has no experience coding to have to understand why they would write some code one way, then have to "transpile" to something else to get it to run? Then if something goes wrong they have to figure out how to fix it in two languages? This doesn't sound like something I would recommend for a beginner, or someone experienced for that matter.

Re: John Resig: JavaScript as a First Language

#130

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.

[deleted]
Post reply on HN