Settings

Theme

Ask HN: JavaScript code base to read and learn from

10 points by ahmadajmi 12 years ago · 4 comments · 1 min read


I just discovered this amazing site http://www.readingcodegood.com/ and watched the talk, it's very inspire. She gives good examples of Ruby that is nearly ~ 100 line of code. I just want to do this exercise with JavaScript and I want to get some very good and clean JavaScript code to read and learn from. Any suggestions?

Thanks

BonsaiDen 12 years ago

In general there are two types of JS code bases you'll encounter, the ones for the Browser which end up putting everything into a single file and the ones for Node.js, which (in most cases) organize their code in the usual directory / file structures you may be used too from other programming languages.

There are also multiple camps which battle about whether too use semicolons at all and where to place commas that separate the individual parts of `var` statements. I'm not going to take any sides here, since I think that style is something everyone has to decide on their own :)

Now as for the code to read, there's obviously jQuery, but Angular.js is definitely a good read too these days.

https://github.com/angular/angular.js

If you're into parsing (or want to learn about it), there's also Esprima which is a JavaScript Parser written in JavaScript:

https://github.com/ariya/esprima

Taking a look at NPM might give you an idea of another syntax style, since commas are infront of the lines here and there are no semicolons:

https://github.com/npm/npm/tree/master/lib

And last but no least a shameless plug or two!

gbaasm this is a assembler for z80 GameBoy code (which takes assembly files and build a ROM) written by myself, it has a big focus on performance and is another example of lexing / parsing source code.

https://github.com/BonsaiDen/gbasm

For something short and sweet I got a minimal 2D physics engine here. Beware though, if you're new to physics simulation is can be quite hard to figure out what excactly is going on:

https://github.com/BonsaiDen/box

  • ahmadajmiOP 12 years ago

    Thanks so much Ivo for this very good list, yes I'm looking for ones for Node.js as you said they are more organized and cleaner. I will consider Angular first as I learn it theses days and will be great to learn from the source code.

mattkrea 12 years ago

I believe this was posted on HN a while back but check out this video and the jQuery repo. It's actually very, very interesting.

http://www.paulirish.com/2010/10-things-i-learned-from-the-j...

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection