Live data from Hacker News

Javascript the right way

jstherightway.com

21–30 of 43 posts

Re: Javascript the right way

#21
post #9

Earlier quoted context omitted.

With all due respect, Crockford jumped the shark some time ago.

In what sense?

Crockford is as important to modern JS as Lerdorf is to modern PHP. He has a very minimal role in the community, and most of that involves resting on his laurels and being divisive.

Re: Javascript the right way

#22
post #12

Looks more like JS the java way. Singletons make no sense in a language that has global variables and never lets you stop an object from being duplicated. The command pattern makes no sense in a language with first-class functions. I'd steer clear of this resource if you want to write javascript the right way.

Care to point us to some better resources?

Re: Javascript the right way

#23
post #17
post #12

Looks more like JS the java way. Singletons make no sense in a language that has global variables and never lets you stop an object from being duplicated. The command pattern makes no sense in a language with first-class functions. I'd steer clear of this resource if you want to write javascript the right way.

I somewhat agree with your points. You can't just explain every single design pattern available in any given language and then say, you now know how to write that language "The right way!". Thats the feeling I got from this, it just goes into way too much detail about way too many things, and forgets to start with the basics, which is all you need to know to write JavaScript the right way. How can you write any langu…

Yeah. I was expecting things like "use semicolons", "global variables are bad", "=== is often what you want, not ==". These are the things that many devs will need to learn. A bunch of design patterns was not what I expected.

Re: Javascript the right way

#24
post #12

Looks more like JS the java way. Singletons make no sense in a language that has global variables and never lets you stop an object from being duplicated. The command pattern makes no sense in a language with first-class functions. I'd steer clear of this resource if you want to write javascript the right way.

In JS, a singleton is a reference to a module. It is used to ensure you invoke the module only once.

Global variables are irrelevant since your global namespace most likely resembles a tree structure.

edit: you may be right about the command pattern, I've never used something like that. It may just be the example is half-assed though.

Re: Javascript the right way

#25
post #12

Looks more like JS the java way. Singletons make no sense in a language that has global variables and never lets you stop an object from being duplicated. The command pattern makes no sense in a language with first-class functions. I'd steer clear of this resource if you want to write javascript the right way.

In JS, a singleton is a reference to a module. It is used to ensure you invoke the module only once. Global variables are irrelevant since your global namespace most likely resembles a tree structure. edit: you may be right about the command pattern, I've never used something like that. It may just be the example is half-assed though.

There are no modules in JavaScript as well. At least not in ES5.

Re: Javascript the right way

#26
post #17
post #12

Looks more like JS the java way. Singletons make no sense in a language that has global variables and never lets you stop an object from being duplicated. The command pattern makes no sense in a language with first-class functions. I'd steer clear of this resource if you want to write javascript the right way.

I somewhat agree with your points. You can't just explain every single design pattern available in any given language and then say, you now know how to write that language "The right way!". Thats the feeling I got from this, it just goes into way too much detail about way too many things, and forgets to start with the basics, which is all you need to know to write JavaScript the right way. How can you write any langu…

Intermediate JS devs need online resources too. Imo, an in-depth explanation of inheritance and the module pattern would be the best possible resources for people at that level of the learning curve. In other words, just read Doug Crockford.

Re: Javascript the right way

#27
post #12

Looks more like JS the java way. Singletons make no sense in a language that has global variables and never lets you stop an object from being duplicated. The command pattern makes no sense in a language with first-class functions. I'd steer clear of this resource if you want to write javascript the right way.

Care to point us to some better resources?

I've shipped very little JS code, so take this with a grain of salt. However I have had to ship JS code, and since I'd heard horror stories, I tried to find some solid resources to make sure I wasn't shipping garbage. I found these really helpful:

Eloquent JavaScript, a freely available book with an in-browser REPL and a lot of fun exercises

http://eloquentjavascript.net/

Douglas Crockford's JS master class, which covers a lot of the same material as his "JavaScript: the Good Parts" but in video format, and I think in a much more digestible way. The Good Parts book is very, very dense and probably best used as a reference. (why he thought starting with a formal definition of the langauge's grammar was a good idea completely escapes me)

http://shop.oreilly.com/product/9780596809614.do

I don't actually know if these are really up-to-date, and all the cool kids are using CoffeeScript anyway, so anyone with more experience please correct me if these aren't any good. They definitely point out how to avoid the most painful quirks of the language, and how to leverage the core that is actually decent.

Re: Javascript the right way

#28

Earlier quoted context omitted.

In JS, a singleton is a reference to a module. It is used to ensure you invoke the module only once. Global variables are irrelevant since your global namespace most likely resembles a tree structure. edit: you may be right about the command pattern, I've never used something like that. It may just be the example is half-assed though.

There are no modules in JavaScript as well. At least not in ES5.

Module pattern. It is easily one of Javascripts greatest strengths.

Re: Javascript the right way

#29
Hi guys! This a WIP, and we'd like to ask for your help to get this guide more complete! It's a live document.

Please, feel free to fork the project and send a pull request, we really want to make this guide a reference for JavaScript developers.

Post reply on HN