I learned JavaScript first, and I think in many ways I'm actually better off for it.
Anyone who's serious about JS hears constantly about the problems of lexical scoping, type coercion, lack of modules, etc. When I moved on to learning PHP and Python, I largely knew what to expect - and found them both pretty easy (aside from PHP's standard library being ENORMOUS and impossible to memorize).
On the other hand, I've seen people coming from classic OOP languages really struggle with things like first class functions and prototypal inheritance.
I don't think the problem is that people are learning JavaScript as a first language. I think the problem is that a lot of people who write JS don't ever really learn it.
I think that you're misinterpreting disgust as "struggle" when it comes to those people with a more traditional OO background dealing with JavaScript's prototype-based OO approach.
Languages like C++, Java, C#, Objective-C and Smalltalk have very well-defined and consistent ways of declaring classes, inheritance relationships, instantiating objects, using objects, and so forth. With some experience, it becomes extremely trivial to quickly understand and work with such code, even when it was written by other developers far away or long ago.
JavaScript is the opposite. Like so much of the rest of the language, its prototype-based approach is an absolute mess, and this further encourages code that uses this functionality to be a mess, too.
Those are three different ways of doing the same thing (and one of them also has non-obvious resource consumption impacts). Those are a very basic case, as well, without even any inheritance. This lack of consistency may not seem like a big deal when it comes to simple examples like that, but it does quickly become an issue in any code written by more than one or two developers, and meant to be maintained for years. Some will claim that coding standards will help here, but they do absolutely no good once integrating code developed independently of said coding standards.
The numerous problems with JavaScript's approach might be excusable if it brought any benefit relative to more traditional OO approaches, but it just doesn't. It takes something that is done quite sensibly in so many other languages, and ruins it. While somebody who started with JavaScript as his or her first (and often only) language may not see these problems, it is very frustrating and disgusting for those coming to JavaScript after years or decades of experience with other languages.
I disagree with your assessment. Arguably your trying to cram non JavaScript style into JavaScript and then getting upset that it'a not what your used to.
I had a bad opinion of JavaScript at first too coming from a C++ background. Then I finally stopped trying to make it C++. I never want to go back. Things that are hard in statc languages are so easy in JavaScript.
My best advice would be to maybe read though one of the more popular libraries though I don't know which one to recommend. There's a level of elagance there I rarely see in C++
The "classical inheritance background" frustrates the heck out of me at times. I strongly encourage developers to look at traits/roles -- http://en.wikipedia.org/w/index.php?title=Trait_(computer_pr... -- for OO development and the first thing I have to do is to try to get them to "unlearn" class-based inheritance.
For me, the key bit of learning that unlocked my ability to switch between OO paradigms was actually assembly programming.
Having an understanding of how C++ types, strings, structs and finally objects all impacted the stack and memory, then being able to actually create something in x86 let me 'see' how classes create objects, and also got me over the 'how do pointers work?!' hurdle.
It might be entirely counter-intuitive, but learning assembly was the key to me being able to shift OO-gears. Today I write in PHP and JS, and the only thing that I find myself stumble over when moving back-and-forth are weird things like the `this` scope of setTimeout returning to global space when invoked locally.
Interesting. For me, I learned OO with Perl (scary, I know), but really started grokking it when I learned to Java. Finally, I started studying Smalltalk and when I found out that it doesn't have "if" statements (it creates boolean objects you can send ifTrue/ifFalse messages to said objects). Once I grokked that, it was like my eyes opened. I still have more to learn, but OO programming is so much easier and more pleasant after understanding how multiple languages approach it.
Hmm. There was another comment in the chain last night about why Dart doesn't use prototypal inheritance. That's what I was replying to. Must have been deleted and orphaned the comment above.
Anyone who's serious about JS hears constantly about the problems of lexical scoping, type coercion, lack of modules, etc. When I moved on to learning PHP and Python, I largely knew what to expect - and found them both pretty easy (aside from PHP's standard library being ENORMOUS and impossible to memorize).
On the other hand, I've seen people coming from classic OOP languages really struggle with things like first class functions and prototypal inheritance.
I don't think the problem is that people are learning JavaScript as a first language. I think the problem is that a lot of people who write JS don't ever really learn it.