Live data from Hacker News

John Resig: JavaScript as a First Language

ejohn.org

181–190 of 228 posts

Re: John Resig: JavaScript as a First Language

#181
post #120
post #90

Earlier quoted context omitted.

Java isn't really simple in comparison to Haskell--Java is full of warts and inconsistencies while Haskell is simple, consistent and elegant. The reason Haskell is viewed as hard is that it takes basically nothing from languages you already know. If you don't know any languages, it's actually a great starting point.

> The reason Haskell is viewed as hard is that it takes basically nothing from languages you already know. If you don't know any languages, it's actually a great starting point. At my undergrad program, Haskell was used for the second CS course after the basic intro course. It was a nightmare and drove people away from the major in droves. They just did a curriculum overhaul and one of the changes the CS faculty are…

Had a similar experience, except we focused on using SML. We went from 15 people down to 3 in the class by the end. I think the tough part is that most of us had zero experience with functional concepts, while the professor couldn't seem to grasp that everything that made complete sense to him, didn't make sense to us.

There's a lot of potential for Khan Academy to make significant impact with this -- I'm not entirely sure JavaScript would be my first choice, but it does present a lower barrier of entry that is ubiquitous and allows people to even mess around straight in their browsers. With JS, you can show people a little bit of both worlds at a time and compare imperative/functional examples (whereas in Haskell, you're stuck with functional, unless you really want to mangle things). It's also a bit more exciting to be able to throw up a little JS creation on the web so that everyone can see, as opposed to writing a program in C and not really being able to show it to people easily without having them run some executables or bringing them to your computer.

One might argue that people who can't make it through Haskell or other "tough languages" shouldn't bother being CS majors -- but we need all kinds of people in the industry and people have many differing interests. There's blue collar work and white collar work even within software engineering.

Re: John Resig: JavaScript as a First Language

#182

Earlier quoted context omitted.

Yeah. Because only kids use and love Python and like the significant whitespace, right? And Haskell with it's significant whitespace --yeah, that's another language for "kids who don't know better"... Anyway --you're a Smalltalk guy. How do you get to talk about weird syntax people don't like? Do many people like interleaving-argument selectors?

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 one, you should follow EXACTLY the same whitespace conventions in any bracketed language, even C. That is: you should properly indent blocks, and you should not mix spaces and tabs. If someone does not do that, I don't really think many people would like to work with his code. And if he already does that, then Python's whitespace is not any different, it just removes the brackets.

"""as well as it being the source of a great many bugs."""

I cannot think of ANY bug that can be caused by Python's use of significant whitespace. On the contrary, it prevents a lot of common bugs in bracketed languages (if/else nesting, etc).

The only think Python's use of whitespace can cause is compiler error messages (when you have messed the indentation) -- which is totally different from "bugs".

So, what bugs are you talking about? Any specific example?

"""As for Smalltalk, yes, they do like them, since faking them by passing literal hashes is a common pattern."""

Literal hashed are more like named arguments than Smalltalk selectors. For one, elements inside them are optional...

Re: John Resig: JavaScript as a First Language

#183

Earlier quoted context omitted.

Yeah, because it totally didn't work for Python... :3

Touting what is arguably the most hated single feature of a particular programming language as a clear success? Uh...ok.

It is probably the most controversial feature. Most people either hate it or love it. I think it's hated mostly by those who don't use Python, and well-loved by those who do.

It was not the first programming language to use significant whitespace, but it is probably the most mainstream one that does, and it did pave the way for other languages to do the same. So it makes sense (IMHO) that sometimes other languages copy this feature, because it makes code shorter and more readable.

I haven't really heard any good arguments against significant whitespace, just the usual "but when I copy & paste a block the indentation might be off" (so use the indent/dedent function in your editor) and "I cannot mix tabs and spaces" (which you shouldn't do to begin with). The "hate" is mostly because people are not used to it. Not unlike Lisp's parentheses...

Re: John Resig: JavaScript as a First Language

#184
Its pretty easy to criticise, so instead I will discuss the steps I would take to a student CS principles from my own experiences. I find graphs to be fundamental, so I would start the student out with them.

1. Teach the student basic concepts in graph theory such as nodes, edges, walks, paths, cycles, and structures such as trees, and linked lists.

2. Introduce the student to syntax trees as a means of representing mathematical equations, and the representation of them used in Lisp: (+ (* a x x) (* b x) c).

3. Describe dataflow graphs to the student. For example, loops are cycles in the dataflow graph, and infinite loops occur when the cycle is endless.

Re: John Resig: JavaScript as a First Language

#185

Earlier quoted context omitted.

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/

By "readily available at the command line" - have you forgotten that the context of this discussion is for a language to use for a first year programming course? A not insignificant portion of the people taking those courses will not be command line savvy. Also, I think that the fascination some programmers have for tools that are cumbersome and difficult to use is unhealthy. The tool should not itself be the problem…

Well whatever the language you want to use, you'll have minor installation/configuration to do. For real beginners, the teachers can do it for them. So, if they use Eclipse for instance, the IDE can be configured to automatically use JSlint.

By "Command line", the OP meant that it's easy to plugged it wherever you want it; i.e. it is not strictly an online tool.

About:

  "fascination some programmers have for tools that are cumbersome and difficult to use is unhealthy" 
Not sure what you're thinking about. It's more an opinion than a fact. I.e. Some programmers like emacs better than vim, some prefer Eclipse.. some prefer notepad++. "Cumbersome and difficult" mostly depends of your taste and your background.

Is 'grep' hard to use? What about ctrl+shift+f in Visual Studio? Which one is the most cumbersome and difficult to use? Highly subjective imo.

Re: John Resig: JavaScript as a First Language

#186

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

Block Scope: This is a tricky one, because unfortunately it can't be emulated in a performant way in JavaScript.

This is not true. ClojureScript does this and it's plenty efficient. What you lose is mutability of the loop local from inside a closed over function. Given how many people get burned by the JavaScript behavior clearly block scope is expected. I doubt anyone would miss the dubious ability to mutate a loop local via callback. Certainly not as much as I miss control over scope & names in CoffeeScript.

Re: John Resig: JavaScript as a First Language

#187

Earlier quoted context omitted.

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/

By "readily available at the command line" - have you forgotten that the context of this discussion is for a language to use for a first year programming course? A not insignificant portion of the people taking those courses will not be command line savvy. Also, I think that the fascination some programmers have for tools that are cumbersome and difficult to use is unhealthy. The tool should not itself be the problem…

No. I am operating under the assumption that a competent instructor would provide a pre-configured text editor or IDE for the students to use.

Re: John Resig: JavaScript as a First Language

#188

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…

> I propose we don't talk about languages with "significant whitespace", but instead about "languages with proper indentation enforced".

Yes, 'significant whitespace' is too sweeping a term to be useful. I've heard people complain about Python's 'significant whitespace' until they realize that it uses basically the exact same whitespace rules as Java does, except with sensible indentation rules instead of braces.

http://www.secnetix.de/olli/Python/block_indentation.hawk

Re: John Resig: JavaScript as a First Language

#189

Earlier quoted context omitted.

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…

Upvote from me. It's a sad day when Kiddiescript is somehow magically elevated to the status of a real programming language.

JavaScript is Lisp in C's clothing. http://javascript.crockford.com/javascript.html

Also this: http://gigaom.com/cloud/node-js-and-the-javascript-age/

Re: John Resig: JavaScript as a First Language

#190

I once considered teaching JavaScript as a first language, but the absence of synchronous user input made me reconsider. For example, there is no way to do this in JavaScript, > var line = read_line(); Of course you could use the prompt() function, but that only works in the browser, and it's an ugly hack.

"Synchronous I/O Considered Harmful" or "I once considered teaching JavaScript as a first language, but then I found out it has no GOTO statements"
Post reply on HN