Javascript beginner - self study recommendations needed

Status
Not open for further replies.

ChiefSpaceGoblin

Smack-Fu Master, in training
80
Having recently been made redundant from a large IT services company I'm looking at something to do with my redundancy time & money. The winning idea at the moment is to go to university to obtain the degree I had neither the maturity or self discipline to work for in my youth. Having attended a local university open day i've pretty much settled on applying for a computing degree and asked about entry requirements, course pre-requisites etc.

Looks as though my work experience to date, predominantly Windows desktop & server sys admin, IP routing and firewall work, desktop & application virtualisation together with softer project admin skills etc will suffice for entry requirements as a mature student. It was suggested though that I make some time to study programming with Javascript being heavily hinted at. The last programming I did was just enough Visual Basic to be able to script certain pre-execution requirements for virtual application deployment - highly Microsoft eco-system centric and extremely narrow in focus. Prior to that I'm looking at BASIC coding back in the halcyon days of 8 bit computing in my bedroom at my parents house!

Taking the university self study recommendation to heart, I'm now looking at either an inexpensive online course or a good beginners guide to Javascript book with exercises. There's no shortage of offerings out there, but little to distinguish any of them and certainly nothing I'd trust by way of endorsement.

Anyone care to make any suggestions? Any and all ideas appreciated!
 

Mile Zero

Ars Praetorian
578
Subscriptor++
JavaScript, the Definitive Guide by David Flanagan is a good reference text. As a side benefit, it is large enough to beat small animals to death if you're attacked by a honey badger or something.

Some people will recommend Crockford's JavaScript: The Good Parts. That's a really good book, even if (in retrospect) it's wrong about a great many things. But it's a hard place to start for beginners.

Eloquent JavaScript is also good, and free. The second edition talks a lot more about the browser, which is good, since that's where most of your code will run.
 
Javascript: The Good Parts is a must-read for anyone learning JS.

JS-Koans and JS-Assessment are excellent starting points for interactive learning.

https://github.com/mrdavidlaing/javascript-koans
https://github.com/rmurphey/js-assessment

That'll get you the fundamentals; after that I'd recommend taking a look at module patterns (AMD, CommonJS) to break up your code into manageable chunks, and looking through some frameworks (not jQuery, as it has an artificially low skill ceiling). I recommend Dojo, Backbone, Ember, or (grudgingly) Angular.

If you get serious about proper development practices, becoming competent at npm and/or bower is recommended for dependency management, as well as Grunt or Gulp for workspace automation.
 

Sleepperi

Ars Scholae Palatinae
679
[url=http:/civis/viewtopic.php?p=27895197#p27895197:1u8lgy4c said:
Mile Zero[/url]":1u8lgy4c]Some people will recommend Crockford's JavaScript: The Good Parts. That's a really good book, even if (in retrospect) it's wrong about a great many things. But it's a hard place to start for beginners.
Can you elaborate on that - what kinds of things does it get wrong? Any books/weblinks discussing that stuff?

I have only written about 2k lines of JS and that was two weeks of coding two years ago, so I've forgotten the details of how the language works, but I remember I went with what Crockford suggested for basic code architecture - no "new" anywhere, etc. I was left with the general impression that in JS you can pretty much decide for yourself whether and how you want to do inheritance, etc. and good ways of structuring your code probably don't look like C++/Java/C#. Crockford's approach certainly didn't. With that kind of freedom it seems important to read what the best practices are. Is the general "Crockford approach" a good one still? Are there other major approaches that are a good idea?

Reading Crockford and others also left me with the knowledge that JS is a functional language at its core, and would maybe have been a dialect of LISP if marketing didn't dictate otherwise. It would be interesting to hear how much good devs are actually using JS in a functional way in practice these days. I have a little bit of dabbling history with Scheme/Scala/Haskell and generally prefer functional approaches where possible.

I know most people doing anything with JS are using some framework, but I haven't used any, and don't know whether and how they change the core practices of JS programming.
 

Mile Zero

Ars Praetorian
578
Subscriptor++
[url=http:/civis/viewtopic.php?p=27967637#p27967637:3cg16smk said:
Sleepperi[/url]":3cg16smk]
[url=http:/civis/viewtopic.php?p=27895197#p27895197:3cg16smk said:
Mile Zero[/url]":3cg16smk]Some people will recommend Crockford's JavaScript: The Good Parts. That's a really good book, even if (in retrospect) it's wrong about a great many things. But it's a hard place to start for beginners.
Can you elaborate on that - what kinds of things does it get wrong? Any books/weblinks discussing that stuff?

Crockford's book was important for a lot of JS devs, because it laid out for a lot of people how the functional side of the language worked, and provided tools for thinking about how to use that to provide the kinds of things that it really should have added long ago (privacy, modularity, etc.). I spent about two weeks working my way through it when I first got a copy, and it made me a much better coder.

The problem with a lot of his advice is that, in this day and age, it's not actually very good for performance or memory:

  1. Modern JS engines optimize object property lookup using hidden classes, and the best way to give them good hints about what those classes should look like means using the new keyword, and not being afraid of prototypical inheritance. Crockford's emulation of class-based inheritance causes de-optimized code, because the VM can't predict the shape of the object as efficiently.
  2. The Good Parts was a big proponent of creating "private" properties by closing over variables in the constructor with getter/setter functions. Invariably, this means moving more stuff into the constructor, because that's the only way to give it access to that private scope. Turns out this is also terrible for memory/performance, because every time the constructor runs it's creating a unique version of all those variables and functions--they aren't shared through the prototype.
  3. The book does a lot of augmenting built-in prototypes, which we now know is just generally a bad idea. It's usually safe to shim Function methods, and I usually shim the Array methods if I'm forced to work in a pre-ES5 browser, but adding stuff to Object.prototype is just asking for trouble.

I don't mean this as a way to bash Crockford--I still think The Good Parts is a fantastic book. I teach JavaScript classes at the local community college in my spare time, and if they ever give me an advanced class, we'll probably use it as the textbook. It was highly influential, and parts of it (like the module pattern) are still fundamental to good JS development. But it's best taken with a big grain of salt, especially as the runtime has changed--we have a lot of features available to us in JavaScript now that weren't there when The Good Parts was written, and the underlying tech has gotten a lot more sophisticated.
 
Status
Not open for further replies.