4 ms·
Great resource with tons of good advice! What worked for me: 1. Watch Ryan Dahl's intro videos to Node—he is doing the best job of explaining how Node is work
by tferris 14y ago
Great resource with tons of good advice!
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.
- czzarr 14y agoi'm curious, why do you recommend the mongo native driver instead of mongoose?
- KaoruAoiShiho 14y agomongoose is an ORM, so they're not the same thing. mongoose depends on native driver anyway.
- tferris 14y agoMongoose is great and should be also checked out. 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.
- czzarr 14y agook thanks for replying I see your point. We are currently developing a project that hopefully will reach web scale (that is the goal anyway) and we started out with mongoose (without really thinking about it though) because it brings you a lot of nice things such as hooks, validators, setters and getters. Of course from an experimentation point of view, what you said makes a lot of sense given my experience with mongoose.
- blantonl 14y agoI cannot say enough about the express module. It brings a simple, yet powerful framework for Web and API development. If you are doing any serious API or Web delivery using Node, you will, at the least, be evaluating express.
- tferris 14y agoSeconded. Express is incredible and it's a refreshing take on anything you seen before regarding web frameworks. People saying that it's similar to Sinatra, yes maybe but the strengths lie in the details: i.e. Express" error messages are so aesthetically pleasant, this just a minor thing but this make you happy all the time when working with Express and every other framework feels a step back now. And Node and Express have a rich ecosystem of stand alone modules—they are not designed for one-does-it-all framework. Paired with Node and its modularity Express it really an eye opener Sinatra never was.