How do I get started with Node.js
stackoverflow.com
stackoverflow.com
What worked for me:
1. Watch Ryan Dahl's intro videos to Node—he is doing the best job of explaining how Node is working and what were his thoughts back then. Highly recommended.
2. Instead of reading long tutorials rather give yourself a small task like a mircosite or a chat (the typical Node standard example) and build it. I would start with a plain and simple site. Later you should dive into some packages. Highly recommended are Express, Jade, Stylus for a quick web app. Then deploy the thing to Nodejistu with 'jitsu deploy' (or another Node hoster).
Step 1 takes 1 hours and step 2 takes 1-2 hours and after that you realize the power and ease of Node and the great ecosystem in form of the npm and its modules.
Next steps are getting into more great modules like Socket.io and trying MongoDB with the native driver (then you rethink web development entirely). Node shines also with none web apps (e.g. just pure services), so choose a use case which you are most happy with.
Paired with Node and its modularity Express it really an eye opener Sinatra never was.
To get this paradigm shift and the entire experience with Node, NoSQL and especially Node in combination with Mongo the Native Driver is essential:
Mongoose is great and basically an ORM (or they call it ODM, Object Document Mapper) which forces you for good reasons to do a little more preparations like doing a scheme and so on. Point is that's highly recommended as migrations are with SQL counterparts but the point is for the 90% of the projects you start you do not know:
- Will you ever finish the project?
- Will the project ever be deployed?
- Will you ever get heavy traffic and traction?
Often especially with private side projects you just play around and try. Client projects most of the times never reach web scale (and if they reach refactoring and optimizing is easy). Then, most important is is just to get started and the Native Driver is then the best choice because it totally rewires your brain. No scheme, just start. Want another field? Just save another key to this document (=record). Want a join to give users multiple options in a field? Just use an array. Want to save pictures in the DB and not in the filesystem with creating some file organization script, just put them in Mongo with GridFS too (which is fast btw). Let's not forget that Mongos JS interface and JSON data structure are very close to JS and do not feel low level, so native driver isn\t a low lewel driver, it basically provides the original Mongo JS interface which is very convenient and not low lewel at all. You don't have validations but as soon as you need them switch to Mongoose or write them yourself.
To get a proper db model and architecture it's definitely better to a design nice relational data model, use SQL, do migrations and if performance required, put some NoSQL or Redis in between (or whatever). BUT: this is all work and even with Rails where migrations are kind of easy, it is work beforehand and you have to plan a godd structure. This often prevents you just from starting and with the native driver you just start and in ridiculously many cases a plain document orientated data model is fully sufficient and even for those which would require rather a RDBMS this can be tweaked. Performance should never be a problem.
Point is: the classic approach with SQL, data models, mapping, ORMs is good but prevents you from just starting, "sketching" you program and getting out of the door. Latter is more fun and gets things done. Maybe later you have to refactor when a project is successful. But this is easier than doing all projects always in a structured and formal manner. And even if you will use Mongoose all the time it is good that you experienced once the Native Driver, that you know this thing exists and using Mongo with its native interface is as easy as using a toy.
Instead of a chat or a todo app, why not create something cool? Try a small game, a remote control app, cloud music player, etc. Node won't slow you down.
It will slow you down at least as much. Then some more if you try to do something non-trivial and discover node's limitations.
You can extend to your heart's content with node on functionality - but you start with the bare minimum and build accordingly to your requirements. You aren't overwhelmed - you are presented with a basic set of building blocks, and when you cannot accomplish what you need to with the current set of blocks, you research the modules that meet those specific needs.
Think of it like building your own PHP stack from scratch from the source. Except with more of a dynamic perspective.
For example, standard crypto functions are not available in the base node, but installing the "crypto" module makes them available. Same for mysql, server pooling functions, clustering, and even a decent web/api "framework" (Express). You add as appropriate. you leave out what isn't needed.
Our team runs a huge PHP stack for all our apps, so it is a breath of fresh air to be faced with the notion that we are truly architecting our entire code platform, bottom up, vs just calling a bunch of pre-loaded functions. This also gives you greater visibility of the overall stack that your code is running under.
http://www.amazon.com/Node-js-Action-Mike-Cantelon/dp/161729...
[1]: https://peepcode.com/products/nodejs-i (Last update: August 2010: https://peepcode.com/products/nodejs-i/versions*)
If youre interested leave me a contact email or whatever in reply.
Why should I get started with Node.js?
I've monkeyed around but don't get it. Maybe I just don't encounter a need for it when building websites for clients. Dunno.
If you use child processes then interaction between processes (employing different threads) is easy. With cluster you have to setup some communication between nodes.
Check it out. The way meteor does client/server code-reuse is the archetype of node.js possibilities.
http://stackoverflow.com/questions/tagged/node.js?sort=votes...
If you find a category and then look at votes - you can usually find plenty of information in the top few results.
If you need a brushup on js, there are a lot of other options for that including the free ebook Eloquent JavaScript.