News for hackers. Stuff that matters.
Re:John Resig: JavaScript as a First Language by absconditus on Wednesday December 21, 2011 @02:35PM (#3378771)
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...

Re:John Resig: JavaScript as a First Language by zackzackzack on Wednesday December 21, 2011 @03:59PM (#3379113)
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 figured out all the questions he was going to ask and learned just enough to explain the really difficult ones. He was not a zen master LISP programmer who had glided down from the plane of Forms to enlighten us.

But I started to learn programming because of him. He knew what he knew and he had his presentation down. I didn't know how to program so anything was better than what I was going with. He explained terms and ideas in the most stereotypical of ways. But they made sense. In a way, he passed off his framework of knowledge to those who cared to take it. It was incredibly mind expanding at the time.

And so I had this little ball of specific domain knowledge. I wanted to be able to do cool stuff though on my website though. Java wasn't quite there yet, couldn't do all the things I wanted it to do. So I picked up Javascript from W3 schools online. It was terrible, awful Javascript that I have purposefully forgotten. But I could make my pages interactive, I could impress my friends. My little ball of know how was growing and expanding. I kept at it and started seeing how Java "sucked" and why Javascript was the One True Language. New ideas like functions as variables, easy to run scripts, interactive webpages, they all got added on and replaced old less useful ideas from Java.

Pretty soon after that I started actively learning Mathematica in college. The whole IDE is just lisp with some mathematical lipstick, but I didn't know that at the time. I started thinking of how to solve problems with lists, how to use IDE's, and reading and writing to files so I wouldn't have to redo everything each time. I had programs that wouldn't run in less than a second which made me really aware of what I was writing and how to optimize things.

And the story just keeps going and going on like that. Common lisp with Emacs last winter because of PG. More Mathematica and jQuery during last spring and summer because of an Internship. Node, Haskell, Clojure, Python during this past fall for enlightenment. And now R and, maybe, Ruby/Rails during the winter because I have ideas I want to make happen. I'm by no means a professional, but I know enough to shoot the shit with the CS majors and randomly drop into tech meetups (What up Cinci.rb!)

All that sprung from a high school class taught by a standard teacher on a shitty language that I don't ever want to touch again. And so when people talk about first languages and why X will be an absolutely horrible language to use to learn, I zone out. Every language is going to be a horrible first language. All of them. I don't care what arguments you make about js gotchas or Python's batteries included or why scheme is more beautifuller than common. If you don't know how to program, learning how to program is going to suck. Period. Maybe learning C++ first isn't the hottest idea, but at some point you have to grit your teeth and go "Programming is hard."

So I applaud Resig's and Khan Academy's use of javascript. Not because I love javascript, but because I know they are going to doing an amazing job presenting the tiny balls of programming knowledge to kids across the world. They could have picked most any mainstream language they want to present these ideas with and I would still be excited by their ideas. All that matters is how they plant the seeds. If they can stir up a kid's desire enough to get over the "ARRAYS SUCK. FOR LOOPS SUCK. WHY WON'T MY PROGRAM COMPILEEEE." and learn the next language or build the next project, then they have done an amazing job and good for the world.

tl;dr Programming is hard, every language has it's own use, waffling about the choice of languages isn't going to teach you what you need to know any faster.

Re:John Resig: JavaScript as a First Language by __david__ on Wednesday December 21, 2011 @05:50PM (#3379483)
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 BASIC, but I learned something far more important: That I loved programming.

Re:John Resig: JavaScript as a First Language by ejmiller on Thursday December 22, 2011 @08:43AM (#3381466)
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 by ejmiller on Thursday December 22, 2011 @08:50AM (#3381485)
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 by bradleyland on Wednesday December 21, 2011 @02:44PM (#3378802)
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 browser on any platform. It is the closest thing to a universal programming language you'll find today.

Re:John Resig: JavaScript as a First Language by kevingadd on Wednesday December 21, 2011 @02:48PM (#3378823)
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?
Re:John Resig: JavaScript as a First Language by fiblye on Wednesday December 21, 2011 @05:11PM (#3379377)
Java is an extremely confusing language for newcomers. While it's "simple" in comparison to languages like C++ and Haskell, the perceived inconsistencies (do I use == or equals()? length, length(), or size()?) really drive newcomers--and some veterans--up a wall. Throw that in with the insanity of generics, the "everything must be within a class" concept, the mess between objects and primitive types (ints AREN'T Integers!), the verbosity (and inconsistency in naming things), and the lazy-ass exceptions that only vaguely sometimes give you a general idea of where things go wrong, and it's horrible for new programmers.

Javascript is relatively strange, but it's much easier for me to teach JS to somebody than Java. I find it much more easy to explain how and why things work in javascript, whereas when someone asks me why something in Java works this way, I respond with an "I have no clue--they just decided it'd be a good idea and I think it's terrible."

Re:John Resig: JavaScript as a First Language by tikhonj on Wednesday December 21, 2011 @05:44PM (#3379460)
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.
Re:John Resig: JavaScript as a First Language by adgar on Wednesday December 21, 2011 @07:01PM (#3379690)
> 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 most excited about is moving the Haskell course out of the spot where it crushed the spirits of potential majors.

Re:John Resig: JavaScript as a First Language by asianexpress on Wednesday December 21, 2011 @10:39PM (#3380253)
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 by TimboMac on Wednesday December 21, 2011 @08:50PM (#3379980)
Funny that http://www.lambdassociates.org/blog/decline.htm should be on the front page at the same time.
Re:John Resig: JavaScript as a First Language by BasDirks on Wednesday December 21, 2011 @09:56PM (#3380151)
What are you doing in CS if Haskell "crushes your spirit"? Go study finance.
Re:John Resig: JavaScript as a First Language by tikhonj on Thursday December 22, 2011 @03:48AM (#3380912)
Funny you should say that--finance is probably the field that uses the most Haskell :)
Re:John Resig: JavaScript as a First Language by adgar on Thursday December 22, 2011 @11:18AM (#3382009)
The people who knew they were going to be CS majors before they got to college didn't have their spirits crushed. When I TA'd the haskell-based course, they comprised about 25-30% of the students in the class.

The students who were trying out the field but weren't born computer scientists were the ones who were miserable. It was their second course/experience with computer science ever and dealing with Haskell was extremely challenging for them. Being an internet tough guy about it doesn't help them embrace the field, it turns them off more.

Re:John Resig: JavaScript as a First Language by malandrew on Wednesday December 21, 2011 @07:17PM (#3379739)
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 by maximusprime on Wednesday December 21, 2011 @02:57PM (#3378869)
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.

Re:John Resig: JavaScript as a First Language by kevingadd on Wednesday December 21, 2011 @03:06PM (#3378904)
The claim that everyone has a profiler, debugger and REPL is blatantly false. Only a subset of commonly available desktop browsers include those features, and out of those, only recent versions do. Mobile web browsers don't include any development or debugging tools.

The cost of installing Visual Studio or Eclipse is pretty small considering that you only have to do it once. Compare that with the cost a newbie programmer pays every time they use the comparison operator or the arithmetic operator and they now have to consult their reference text to figure out what the operator is going to do and whether they're using the right operator.

If your goal is to lead someone into a lifetime of programming and help them enjoy it, choosing a language in order to avoid a pesky 15 minute setup cost for a compiler is tremendously short-sighted.

Re:John Resig: JavaScript as a First Language by DrHankPym on Wednesday December 21, 2011 @03:28PM (#3379006)

    > Mobile web browsers don't include any development or
      debugging tools.
LOL. Great point. /sarcasm

    > The cost of installing Visual Studio or Eclipse is
      pretty small considering that you only have to do it
      once.
Boom. That's all it takes to create a barrier of entry. Not everyone has permissions to install whatever they want on the computer they're using.

Then you get into issues with multiple operating systems. Windows does it one way and Linux and OSX does it another way. Also, the tools you've mentioned are always changing. Will it be the same in a year or two?

And for what? So you don't confuse an extra set of comparison operators? Javascript is not that bad.

Re:John Resig: JavaScript as a First Language by kenjackson on Wednesday December 21, 2011 @04:04PM (#3379138)
Boom. That's all it takes to create a barrier of entry. Not everyone has permissions to install whatever they want on the computer they're using.

Then you get into issues with multiple operating systems. Windows does it one way and Linux and OSX does it another way. Also, the tools you've mentioned are always changing. Will it be the same in a year or two?

But won't they need to install an editor anyways? Or are they just going to use notepad? That will be a horrible experience.

And JS is changing too. None of the languages change so drastically that it's not just something simple to incrementally learn. And I think getting students used to the fact that things change isn't a bad thing. But also let them know that typically backwards compat isn't broken with these changes.

With that said I'm a big fan of JS as a first language. I'd probably spend the first day with them using notepad or vi (or whatever is natively installed on the system) -- and then have them install some nice IDE of my choosing.

Re:John Resig: JavaScript as a First Language by wahnfrieden on Wednesday December 21, 2011 @05:24PM (#3379409)
I'm all for vim, but you're mad if you think first-time coders should pick that up before even writing their first piece of code. Talk about barriers to entry and unintuitive behaviors...

I think the most viable environments for absolute beginners will be online ones that include an REPL and editor, using either JS or something that compiles to JS or to anything else on the backend, so even browser choice is irrelevant. Then you don't have to teach how to load a JS file into a document and so on.

Re:John Resig: JavaScript as a First Language by thenduks on Wednesday December 21, 2011 @09:55PM (#3380150)
Khan Academy is a training/teaching company. I don't think it's a leap to assume they will be providing online tools to write code with (eg http://c9.io/).
Re:John Resig: JavaScript as a First Language by freehunter on Wednesday December 21, 2011 @03:29PM (#3379007)
I would find it hard to believe that even a significant minority of users who would have any remote or even fleeting interest in programming anything would have a mobile web browser as their only choice. You'd be hard pressed to find someone who has a smartphone or tablet but not a computer.
Re:John Resig: JavaScript as a First Language by absconditus on Wednesday December 21, 2011 @03:10PM (#3378929)
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.
Re:John Resig: JavaScript as a First Language by Apocryphon on Wednesday December 21, 2011 @03:19PM (#3378968)
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!
Re:John Resig: JavaScript as a First Language by exDM69 on Wednesday December 21, 2011 @04:57PM (#3379333)
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 by stdbrouw on Wednesday December 21, 2011 @07:05PM (#3379700)
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 by maximusprime on Wednesday December 21, 2011 @03:13PM (#3378945)
Well, I grew up in a day when it was even easier.

  * Buy home computer (ZX81)
  * Turn on
  * 10 Print "Hello world"
  * run
I don't think the instant gratification and ease of use did me any harm.
Re:John Resig: JavaScript as a First Language by kls on Wednesday December 21, 2011 @05:51PM (#3379486)
Right the technical stack has become daunting to the point that many cannot get the feedback so needed early on. Now days you either advanced with the technology, or you spent a significant investment of time to learn the trade with the intent of entering the field. The days of the hobbyist programmer have seen their peek until that changes.
Re:John Resig: JavaScript as a First Language by tmorton on Wednesday December 21, 2011 @05:42PM (#3379458)
Of course, the "buy home computer" step was a lot harder back in those days.
Re:John Resig: JavaScript as a First Language by chc on Wednesday December 21, 2011 @06:58PM (#3379682)
More expensive? Sure.

Less common? Definitely.

Harder? Not all that much.

Re:John Resig: JavaScript as a First Language by maximusprime on Thursday December 22, 2011 @04:59AM (#3381041)
It wasn't. At least in the UK in the 80s, you could go out to any town center, walk into a shop, and buy a "home" computer. They were everywhere.
Re:John Resig: JavaScript as a First Language by anonymoushn on Wednesday December 21, 2011 @06:38PM (#3379624)
That's fine. We can already run lots of better languages in the browser either using interpreters written in JS or cross-compilers targeting JS.
Re:John Resig: JavaScript as a First Language by laconian on Wednesday December 21, 2011 @04:51PM (#3379315)
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 by syaz1 on Wednesday December 21, 2011 @09:26PM (#3380066)
Almost everything comes with installer these days, yet some refused to install better, secure browsers since they already have IE by default.

Barrier of entry is a problem.

Re:John Resig: JavaScript as a First Language by blub on Wednesday December 21, 2011 @03:28PM (#3379002)
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.
Re:John Resig: JavaScript as a First Language by brudgers on Wednesday December 21, 2011 @04:28PM (#3379234)
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 by wwweston on Wednesday December 21, 2011 @03:51PM (#3379077)
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 the bunch depending on what your goals were.

Prolog had some real strengths. The combination of accessibility for some simple applications with the power and conceptual depth of the logic paradigm tended to put more or less smart people with no previous experience on the same footing with those with some experience.

But JavaScript seemed to be the best of the bunch in terms of balancing accessibility, speed from which students could get to doing something with everyday practical use, and available depth.

And despite the fact that those of us who were teaching were just learning and coming to grips with some of the "bad parts" ourselves (because how many people really knew JavaScript in the 1990s, right?), everybody got stuff done anyway.

Re:John Resig: JavaScript as a First Language by showell30 on Wednesday December 21, 2011 @07:37PM (#3379784)
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 by wwweston on Thursday December 22, 2011 @01:50PM (#3382722)
I'm a little down on things like Logo and Karel, partly because I prefer things that are more general, and partly because even in the niche I might use them, my judgment is that Scratch is better. :)

I didn't try Python myself until late 2001, and by then, I was already more or less out of education, so I didn't get to try it out on anybody else.

But if I were guessing, I think the language itself would probably work pretty well for most students, possibly somewhat better than JS. Not sure how big the advantage would be, though (like I said, we really didn't struggle with JS's warts much), and I think the broad target for JavaScript's use give it something of an advantage too.

This would vary by domain, though. If I were trying to teach a number-crunching focused class, for example, Python would probably move way up my list.

Re:John Resig: JavaScript as a First Language by DrHankPym on Wednesday December 21, 2011 @03:17PM (#3378959)
Whatever, Javascript is the easiest language to get started on. No installing a complicated IDE. No configuring a server. Nothing is required except for a browser!

If anything, it's the best language for such purposes: getting started.

Re:John Resig: JavaScript as a First Language by showell30 on Wednesday December 21, 2011 @03:30PM (#3379014)
I don't think Javascript's availability in the browser should be a major driving concern. Browser-based REPLs and editors are getting better and better. Two examples: http://repl.it/ and http://cloud9ide.com/.
Re:John Resig: JavaScript as a First Language by asktell on Wednesday December 21, 2011 @02:45PM (#3378809)
Every language has its gotchas. Even assignment operators are kind of a gotcha.

If you're coming from a basic math background, and have no programming experience, then the expression "a = 15; a = a + 1;" would be confusing in any mutable language, because assigning a value to a variable is not equivalent to stating the equality (identity) of both sides.

Re:John Resig: JavaScript as a First Language by brlewis on Wednesday December 21, 2011 @03:55PM (#3379097)
You're right in that even Scheme, which evolved with teaching in mind, has gotchas. However, the Racket folks made "student languages" that specifically exclude gotchas, so DrRacket is as close as a student can get to a gotcha-free environment.
Re:John Resig: JavaScript as a First Language by phzbOx on Wednesday December 21, 2011 @03:19PM (#3378970)
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, I'd feel bad to teach that to students who will try to find an internship and writing on their resumes "Scheme" while other universities students would have "C++/Java". And, please, before your argue that a language can be learned or something else, have in mind how companies recruit and parse resumes.. they often just search for a keyword. Now, one might say that you don't want to work for a company who does that, but then, you have to start somewhere in your first internship.

Thus, I like JavaScript as a first language; not because it's the easiest to learn but because I believe it gives a strong foundation but also gives students the ability to find a good internship.

Re:John Resig: JavaScript as a First Language by Stormbringer on Wednesday December 21, 2011 @07:14PM (#3379731)
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 by joshuacc on Wednesday December 21, 2011 @07:36PM (#3379781)
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 by Stormbringer on Wednesday December 21, 2011 @10:15PM (#3380194)
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.

The tool should be a force multiplier that lets you solve other problems more easily.

Re:John Resig: JavaScript as a First Language by phzbOx on Wednesday December 21, 2011 @11:08PM (#3380330)
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 by joshuacc on Wednesday December 21, 2011 @11:15PM (#3380351)
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 by Joeri on Thursday December 22, 2011 @08:12AM (#3381398)
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 by malandrew on Wednesday December 21, 2011 @07:33PM (#3379775)
Whitespace can be a huge gotcha for novice programmers. Hard spaces? Soft spaces? New lines?
Re:John Resig: JavaScript as a First Language by maratd on Wednesday December 21, 2011 @03:09PM (#3378922)
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!

Re:John Resig: JavaScript as a First Language by jordan0day on Wednesday December 21, 2011 @03:58PM (#3379109)
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.

Re:John Resig: JavaScript as a First Language by munificent on Wednesday December 21, 2011 @05:05PM (#3379357)
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 by kls on Wednesday December 21, 2011 @06:00PM (#3379513)
The problem is deeply technical people will put for the effort to learn deeper languages so that leaves a majority of the candidates as being people who want to learn programming because they want to scratch an itch. That being said, BASIC is usually not the language or platform they want to scratch that itch on, more and more the web and mobile are where they want to deliver to. That being said, JavaScript becomes the better investment of time, due to the fact that it directly parallels their goals in learning programming in the first place.

More and more I am starting to think Objective-C and IOS may be a contender, while, Objective-C is technically more difficultly to get started in, the technology stack is a lot simpler, to be effective on the web, one needs to know HTML, CSS and JavaScript and then really and truly they need to know a back end language or Node.js to deliver a back end. Whereas Objective-C and IOS is a visual editor and code. The feedback loop is faster for IOS development than JavaScript development and I believe the feedback loop is very important to a certain population of would be developers. I have never tried to teach a non-programmer Objective-C and IOS dev so the above statement is loaded with assumptions. Please read it as such, but I am leaning towards trying it next time someone approaches me and wants to learn.

Re:John Resig: JavaScript as a First Language by bdfh42 on Wednesday December 21, 2011 @02:45PM (#3378804)
I disagree as well - it is a very capable language with some very friendly features.

Also it is very applicable for many new programmers - an all round good choice.

Re:John Resig: JavaScript as a First Language by maximusprime on Wednesday December 21, 2011 @02:40PM (#3378788)
Disagree... for example from the link:

  In JavaScript:

  '5' + 3 gives '53'
  Whereas

  '5' - 3 gives 2
That's just logical and obvious, since "+" is both numerical addition, and string concatenation, but "-" is only numerical subtraction, and the '5' starts out as a string.

Every language has 'gotchas'. Doesn't really matter which you pick to learn first at all. The more important thing is that you don't give up. possibly there are languages that just make people want to give up, but I'd say perhaps they're not motivated enough to learn if that's the case.

I started out on BASIC, and after a while I decided it was a piece of shit language and learnt assembly. But it taught me programming which is what I wanted to learn. I'm really glad I learnt BASIC first... essentially I learnt to swim really fast through syrup, and then switched to swimming in water.

The good thing about javascript as a first language is that people can be programming in it immediately, in their browser. They have a built in REPL to help them, as well as a debugger, profiler, etc. They have numerous docs to look at, and if they go to any website they can check the source to see how it works. That's a big win.

Re:John Resig: JavaScript as a First Language by kevingadd on Wednesday December 21, 2011 @02:45PM (#3378808)
Calling your example logical and obvious is only logical and obvious if you're completely trapped within the JS mindset. It's the same as how people defend the absurd semantics of Visual Basic and PHP. It's fine if you like it, but to claim that it's objectively okay is just not supported by fact.

It's also worth considering that even if every language has 'gotchas', some of them have far worse gotchas than others. It is worthwhile to choose a starting language that teaches the fewest bad habits and the fewest bizarre rules so that people can easily learn new languages.

Re:John Resig: JavaScript as a First Language by maximusprime on Wednesday December 21, 2011 @02:56PM (#3378866)
See my comment below. It's not about being trapped in any mindset. It's about thinking logically.

Either '5' - 3 results in an error of some kind, or it evaluates to 2. There is no other logical outcome. Javascript chooses to do the latter.

I also disagree that starting language matters. It's like saying you need to have a steinway grand to learn the piano properly.

Learning is about learning what not to do just as much, if not more, than what to do.

Also if you learn to swim through syrup, imagine how fast you'll be when you try swimming through water...

Re:John Resig: JavaScript as a First Language by mquander on Wednesday December 21, 2011 @03:13PM (#3378942)
Your ideas about what is "logical" are completely arbitrary. Look, I can make up rules too:

* '5' - 3 should return '5', since it's the string '5' minus all the instances of the character '3' in it. There is no other logical outcome!

* '5' - 3 should return an empty string, since it's the string '5' with the last three characters removed. There is no other logical outcome!

* '5' - 3 should return '2' -- since we started with a string, the result should turn back into a string. There is no other logical outcome!

* '5' - 3 should return 50, since the only logical way to do math on a character is to take the UTF-8/ASCII value of it and then do the math. There is no other logical outcome!

* '5' - 3 should return undefined, since subtracting from a string typically doesn't produce a reasonable result. There is no other logical outcome!

You have provided absolutely no rational basis for discriminating between the merits of these choices, so your claim that Javascript's choice is one of exactly two "logical" ones is bizarre. If you think Javascript's choice is better, give a reason why it's better, don't just say that it's better.

Re:John Resig: JavaScript as a First Language by kevingadd on Wednesday December 21, 2011 @03:03PM (#3378895)
The time wasted learning the quirky semantics and special rules covering each operator and data type in JavaScript could be better spent learning to reason about algorithms and data structures in a less confusing language. Not all learning is equal, and not all challenges are exactly the same.

The claim that by hindering a newbie programmer's attempts to express themselves will make them more effective in a better language is ridiculous. Even if it's true, it's missing the point - your goal when teaching newbie programmers should be to teach them good habits and generally applicable skills, and most importantly, you want them to love programming.

Having to memorize arcane minutiae and spend tons of time debugging problems caused by stupid design decisions is not going to make people love programming. JavaScript is tremendously accessible by virtue of its ubiquity, but that does NOT implicitly make it a good language for learning to program. Its numerous flaws and divergent implementations will drive away beginning programmers that might otherwise learn to love programming if presented with a better environment.

Re:John Resig: JavaScript as a First Language by absconditus on Wednesday December 21, 2011 @03:13PM (#3378940)
Please do not downvote maximusprime's comments just because you disagree with them.
Re:John Resig: JavaScript as a First Language by barrkel on Wednesday December 21, 2011 @02:47PM (#3378816)
It's logical and obvious if you already know the language; otherwise, it's perverse. I had to read your comment (the initial edit of it) twice to be sure you weren't being sarcastic.
Re:John Resig: JavaScript as a First Language by maximusprime on Wednesday December 21, 2011 @02:52PM (#3378844)
No it's not.

Logically, the only other thing that could happen is for an "error" or "exception" be thrown when you do

  '5' - 3
There's really only 2 choices. Either convert the '5' to a number and subtract, or throw a hissy fit because it's a string.

That's not perverse. It's very logical.

Re:John Resig: JavaScript as a First Language by rprospero on Wednesday December 21, 2011 @03:07PM (#3378909)
You're looking at the wrong side of it. The subtraction does behave in a perfectly logical manner. The problem is that, given the the behavior of the subtraction operator, the addition operator's actions are illogical. Specifically, I'd argue it's perverse because it breaks commutativity:

'5' + 3 - 3 != '5' - 3 + 3

The logical approach would be to only assume that '+' is a string concatenation if both operands are strings and otherwise type coerce into numbers. Then:

'5' + 3 = 8 '5' - 3 = 2

To someone who doesn't code Javascript for a living, the above seems like a far more consistent and useful behavior.

Re:John Resig: JavaScript as a First Language by maximusprime on Wednesday December 21, 2011 @03:12PM (#3378936)
That would be ridiculous because then what would 'hello' + 1 equal? Everyone would expect it to equal 'hello1'.
Re:John Resig: JavaScript as a First Language by rprospero on Wednesday December 21, 2011 @03:25PM (#3378986)
Except, not "everyone" would expect that.

I'd expect "hello" - 1 to return NaN, since you can't perform numerical subtraction on something that isn't a number. That's exactly what Javascript does.

In the same way, I'd expect "hello" + 1 to return Nan, since you can't perform string concatenation on something that isn't a string, and you can't perform numerical addition on something that isn't a number.

Edited for clarity

Re:John Resig: JavaScript as a First Language by maximusprime on Wednesday December 21, 2011 @03:55PM (#3379095)
"hello" - 1 doesn't return NaN out of some sense of exception to trying to subtract from a string.

It returns it because parseFloat("hello") = NaN, and NaN - 1 = NaN.

Re:John Resig: JavaScript as a First Language by barrkel on Wednesday December 21, 2011 @09:29PM (#3380077)
I would expect 'hello' + 1 to throw an exception. I would similarly expect '5' - 3 to throw an exception. Why? Because you can't add a string to an integer, and nor can you subtract an integer from a string. Doing anything else is arbitrary and unpredictable, IMO, leading to subtle type errors. You want to find type errors early as possible, rather than letting bogus values flow through the program.

I think Javascript is broken here, and Python has it right.

Re:John Resig: JavaScript as a First Language by maximusprime on Thursday December 22, 2011 @05:00AM (#3381046)
You're conveniently ignoring the fact that the + operator also means string concatenation.

Javascript thinks to itself 'hello' string concatenated with a 1 value.

Re:John Resig: JavaScript as a First Language by rimantas on Thursday December 22, 2011 @04:09AM (#3380945)
Huh? Everyone? I expect it to be 'hellp' because I am thinking it works similar to Ruby's 'hello'.succ
Re:John Resig: JavaScript as a First Language by hello_moto on Wednesday December 21, 2011 @02:52PM (#3378843)
That's definitely not obvious. Some people think in patterns or generalizations.

String [binary_operator] Number = String

String [binary_operator] Number = Number

That's just begging for further explanation.

Explaining JavaScript is probably more challenging than say Java. Java has many keywords and usages, but when it comes to explaining the concept of those keywords/semantics to students, it may be a little bit less confusing.

Re:John Resig: JavaScript as a First Language by maximusprime on Wednesday December 21, 2011 @03:00PM (#3378882)
OK here's plain english simple explain...

Left hand side is a string, and "+" is string concatenation as well as addition. So '5' + 3 = '53' (String concatenation). Just as "Hello" + 1 would equal "Hello1". The right hand side is converted to a string.

Left hand side is a string, but "-" is subtraction for numbers. JS converts the '5' to a number, then subtracts. So '5' - 3 = 2 (Numerical subtraction).

That's the explanation, and it's not terribly hard to get past.

Re:John Resig: JavaScript as a First Language by barrkel on Wednesday December 21, 2011 @08:31PM (#3379926)
The issue isn't explaining it. The issue is it needing an explanation at all.
Re:John Resig: JavaScript as a First Language by absconditus on Wednesday December 21, 2011 @03:00PM (#3378880)
You picked one of a dozen or more examples from one list of problems with JavaScript. Of course this particular example can be understood by those of us who already have programming experience. JavaScript's type coercion is likely to be a big stumbling block for many beginners and Resig specifically points this out.
Re:John Resig: JavaScript as a First Language by __david__ on Wednesday December 21, 2011 @05:57PM (#3379501)
I hate behavior myself, though it's probably because I learned Perl first, where there's a separate string concatenation operator ("." in perl5, "_" in perl6). I do wish javascript had that same separation so that "+" was always addition and not sometimes string concatenation.