Live data from Hacker News

John Resig: JavaScript as a First Language

ejohn.org

211–220 of 228 posts

Re: John Resig: JavaScript as a First Language

#211

Earlier quoted context omitted.

"Easier" is (usually) the enemy of "better".

Again. These are classes for _beginners_. I'm not suggesting that you should never learn these things. They should also learn functional programming, estimating how algorithms perform, concurrent programming, binary trees, and a few hundred other things. But Programming is not something you master overnight. You need to understand that 2+2=4 before you can understand that 2+i^2=1.

You are correct, but in that case it's not the question of what is easier, but what is necessary. "Easier" implies that there is a choice between comparable options, not that one is the prerequisite for the other.

Re: John Resig: JavaScript as a First Language

#212
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...…

Common web IDE's all embed JSLint error reporting in the editor window while you're typing. I've used Aptana, Zend Studio and Jetbrains PHPStorm, and they all integrate jslint (though usually it's disabled by default). I've found phpstorm's check-while-you-type functionality is the most comprehensive, better than jslint.

Re: John Resig: JavaScript as a First Language

#213

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…

The secret to enjoying Javascript is to stick to the non-brain-damaged subset identified by Crockford in his Javasript:The Good Parts. For example, if you always use the triple-equals comparison operator, you don't have to worry (as much) about implicit type coercion.

Re: John Resig: JavaScript as a First Language

#214

Earlier quoted context omitted.

Whenever I see a post about what to use as a first language I always think about how I learned, and am learning, how to program. Warning: long-ish story/rant ahead. My first class in high school was the basic Java 101. The teacher did not know anything more than how to draw UML diagrams and tell us to use for loops. He had been teaching the class for years and had no industry experience. I imagine 10 years ago he fig…

Yes, yes, a hundred times yes. My first language was Apple BASIC. Looking back now it is a horrible language (no while loops, only 2 character variable names, line numbers with GOTO as the main way of controlling program flow), but it was easy enough to get my hands wet and get the feel for programming. And more importantly, I got stuff done. I certainly didn't learn any best practices or good programming style from…

Ditto - except it was extended basic on a TI 99/4a. Once I wrote a program of my own that actually worked I was hooked. PDP 11 Basic -> Pascal -> C -> Visual Basic -> C# and now Javascript. There was no going back.

Re: John Resig: JavaScript as a First Language

#215

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

Whenever I see a post about what to use as a first language I always think about how I learned, and am learning, how to program. Warning: long-ish story/rant ahead. My first class in high school was the basic Java 101. The teacher did not know anything more than how to draw UML diagrams and tell us to use for loops. He had been teaching the class for years and had no industry experience. I imagine 10 years ago he fig…

Exactly the situation my daughter is experiencing now. Her Java I instructor cannot program her way out of a paper sack and is going at a snail's pace (an entire semester and they have yet to learn decision making or looping). She's so bored she's decided to drop Java II and switch to an online C++ course so she can go at her own pace. She doesn't want to be a programmer, her love is for digital imaging and animation. But she loves mathematics and wants to understand everything related to her art. /proud father is proud/

Re: John Resig: JavaScript as a First Language

#216

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""" 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 an…

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

Yeah, I thought that was your conception on the issue: i.e just blind prejudice.

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

You invoked some mysterious bugs due to Python's whitespace rules, I asked for a specific example, but conveniently "you are done discussing it".

Nice.

Re: John Resig: JavaScript as a First Language

#217

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"

It may not have GOTO statements, but JavaScript (ECMA-262 Ed. 3) does have its cousin, label-breaks,

  foo:
  if (1) {
    break foo;
    console.log("nope");
  }
  console.log("yep");
https://developer.mozilla.org/en/JavaScript/Reference/Statem...

Re: John Resig: JavaScript as a First Language

#218

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.

To quote Dijkstra: "Computer science is no more about computers than astronomy is about telescopes."

While learning how computers work has its place in computer science, I think computation and manipulating information are better teached on a language where you can concentrate on those concepts instead of secondary issues such as memory management.

Re: John Resig: JavaScript as a First Language

#219
post #148

Earlier quoted context omitted.

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

> but later in the code it was important that the value was actually 5 and not "5". The bug was in that part and not in previous if(5=="5") part. Issues like these appear when Java programmers start to code PHP as if it's Java.

Yes, but using === would have identify such bugs by causing failure of the test rather than running the code for "is true" and getting odd results. The conditional code simply not running will often make the bug (one of the values not being of the expected type) easier to trace than a calculation resulting in 51 instead of 6 ("5"+1 rather than 5+1) at some point later.

You can fix such a bug in two ways: "manually" coerce the values when used, or make sure they get converted to the right type as early as possible. I find tha ltter, along with using === except where you really must have a more flexible comparison, to be the better approach. And if I mistype and skip a = I end up with == instead of = (which would cause a different class of bug!)

Re: John Resig: JavaScript as a First Language

#220

Earlier quoted context omitted.

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

"""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.""" Yeah, I thought that was your conception on the issue: i.e just blind prejudice. """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.""" You invoked some mysteriou…

I told you to google it because it's common, don't be an ass. Obviously I'm talking about the difficulty of sharing code and cut and paste issues between developers who have different ideas about tabs vs spaces.

It's not blind prejudice, signifigant white space is a valid reason to dislike a language; that's anything but blind. That is but one of several reasons I don't like Python, and none of them are blind. Ruby is my scripting language of choice when Bash isn't sufficient.

Post reply on HN