Live data from Hacker News

Preparing Yourself for Modern JavaScript Development

codethinked.com

11–20 of 75 posts

Re: Preparing Yourself for Modern JavaScript Development

#11

Here are a couple book recommendations for those of you looking to improve your JavaScript: "JavaScript: The Good Parts" by Douglas Crockford "JavaScript Patterns" by Stoyan Stefanov

The Crockford book is 4 years old now, is it still considered to be a good book to pickup? I've done JS off and on for a while, but mostly haphazardly (with an emphasis on the hazard). I'm looking to start doing some backbone.js and jquery and a book to help start off with it.

Re: Preparing Yourself for Modern JavaScript Development

#12

Here are a couple book recommendations for those of you looking to improve your JavaScript: "JavaScript: The Good Parts" by Douglas Crockford "JavaScript Patterns" by Stoyan Stefanov

The Crockford book is 4 years old now, is it still considered to be a good book to pickup? I've done JS off and on for a while, but mostly haphazardly (with an emphasis on the hazard). I'm looking to start doing some backbone.js and jquery and a book to help start off with it.

Despite being a small book you can ignore a good third of it, and I think his constructor pattern is out of date? but - it does do a good job of explaining the actually idiosyncratic thing about js - the whole prototype chain thing, and the scoping.

Re: Preparing Yourself for Modern JavaScript Development

#13

Earlier quoted context omitted.

I've been working on following the good parts for my latest project. I've started to cringe any time people talk about the prototype or using "this"

That's unfortunate. Properly using prototypes and "this" is the only way to do high-performance JavaScript with objects. Get cozy with them -- they're useful.

It isn't the only way, it's just that browser JS engines tend to be optimised for them.

Re: Preparing Yourself for Modern JavaScript Development

#15
post #7

This is a nice, gentle introduction, but if you're going to start using modules you might as well go slightly farther and use something like RequireJS ( http://requirejs.org/ ) or Browserify ( https://github.com/substack/node-browserify ).

Both RequireJS and Browserify are not even good options. Browserify's implementation is awkward, incomplete and pollutes global scope a lot. Check out OneJS: http://github.com/azer/onejs it's the only tool that lets you structure your clientside project as a commonjs package and produces unobtrusive code mixable with other code in same global scope

Re: Preparing Yourself for Modern JavaScript Development

#16

I always find it odd that the same developers who deride PHP look at things like IIFE and think "wow, JS is a cool, modern language!" Thanks for the article though, if I ever need to write some JS this will help keep me a little more sane.

The first time I saw something like IIFEs was in one of the SICP lectures, where they show that variable definitions with let or define can be seen as syntactic sugar over immediately invoked lambdas.

And even those Scheme uber-nerds considered it big hack, more useful in theory then in practice.

Re: Preparing Yourself for Modern JavaScript Development

#17
post #12

Earlier quoted context omitted.

The Crockford book is 4 years old now, is it still considered to be a good book to pickup? I've done JS off and on for a while, but mostly haphazardly (with an emphasis on the hazard). I'm looking to start doing some backbone.js and jquery and a book to help start off with it.

Despite being a small book you can ignore a good third of it, and I think his constructor pattern is out of date? but - it does do a good job of explaining the actually idiosyncratic thing about js - the whole prototype chain thing, and the scoping.

Even though I recommended the book, I completely agree with you.

Re: Preparing Yourself for Modern JavaScript Development

#18
post #4

I'd be interested if one of these articles on modularity also addressed testability. For example, the IIFE pattern in the article: (function(window, $, undefined){ //do some work }(window, jQuery)); If instead of immediately executing this function, we kept a reference to the function, then reference it, the function can be supplied with mocks for testing. Obviously there's an issue that you'd pollute the global name…

I don't think you need to go through all the trouble. Some thing like the following should be enough:

    oldJQuery = jQuery;
    jQuery = mock;

    //Run module

    jQuery = oldJQuery;
Remember that IIFE's are basically equivalent to variable definition and assignment. The only reason we even have to go through the trouble of using them is due to JS not having block scope.

Re: Preparing Yourself for Modern JavaScript Development

#19
This is the kind of article I really needed to read 18 months ago instead of fumbling my way through it by myself.

It's amazing how few tutorials there are out there that fill in that gap between being a traditional web developer versed in .net / php and knowing the basics of javascript to being an actual javascript coder.

Most articles and tutorials around the web seem to target the beginner while most hacker news front page pieces target the advanced coder who already understands closures / prototypes etc and there seems to be very little in between.

Re: Preparing Yourself for Modern JavaScript Development

#20

Here are a couple book recommendations for those of you looking to improve your JavaScript: "JavaScript: The Good Parts" by Douglas Crockford "JavaScript Patterns" by Stoyan Stefanov

The Crockford book is 4 years old now, is it still considered to be a good book to pickup? I've done JS off and on for a while, but mostly haphazardly (with an emphasis on the hazard). I'm looking to start doing some backbone.js and jquery and a book to help start off with it.

If four years would be enough to change a lot about the core JavaScript language, there wouldn't be a need for the book in the first place. It's still quite modern enough, and will be until a major EcmaScript overhaul is propagated and accepted by all common browsers…

It's not about modern web techniques, which is why it aged that well. For those, I'd personally recommend pulling apart some modern webapps or libraries, or reading modern tutorials. Usually you're somewhat outdated once your book reached its publisher… (Having said that, JavaScript Patterns is also pretty neat)

Post reply on HN