Is it possible to do large-scale projects with Node.js [closed] - node.js

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Hi everyone I wonder if Node.js provides doing large projects like Disqus and Ghost.
Is this possible or do we have to use minimum 1 language as additional like Python, Django, PHP?

Node.JS is a powerful, fast developing technology. It allows you to make anything you want as if you write in PHP ot Python. But there are also some nuances that can make you doubt about it, and you can read a good article about them. You will see that Node.js is suitable for big projects.
From my experience, the main trouble when you develop for Node.js even in small projects is
"Callback Hell"
Node.JS is mainly asynchronous, so performing consecutive actions turns into adding one statement in the callback function of another statement, which is situated in callback function of another...
doAsync1(function (callback) {
doAsync2(function (callback) {
doAsync3(function (callback) {
doAsync4(function (callback) {
})
})
})
This is good for performance, because the server is not locked waiting for result, but it is really painful for your eyes, especially when you need to perform large sequential operations, and it slows the development speed. Async.js can help you with it.
But everything else about Node.js is great. Using a framework such as Express and a lot of modules (it is not Python, Node.js does not have a big standard library with a lot of cool things in it) will allow you to build large projects.

Related

Reason for using 4-spaces instead of 2-spaces? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Is there any rationale why HapiJS endorses using 4-space indentations?
Source: http://hapijs.com/styleguide
Short answer: No better reason than anyone else - styleguides are typically only rules for project maintainers. They had to adopt some convention and that was the choice. As a user, you don't really need to care.
Long answer: Hapi is a great framework, built by the folks at Walmart. and specifically a person named Eran Hammer who was unhappy about some architectural choices made by Express, another server framework for Node. It is somewhat opinionated in general, it was effectively created in an environment of opinion, not to mention a large company (which means it desperately needed a convention). That said, you can safely use the Hapi API with any indentation you want, including tabs, though. Likewise, the Hapi internals could have been written the same way. Their specific choice likely comes down to established tools or conventions already in use at the company. Many different projects make different choices for a variety of reasons. In my experience, many large JavaScript applications go with 2 spaces and the Node.js core itself is written with 2. But there's nothing wrong with those that do otherwise.

How does node.js fare against other frameworks for predominantly rendering large templates [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am about to build an app that will predominantly render large numbers of table entries on an html page server side, i.e., I will be looping over a results object in my template and just wrap each returned row/listItem in some html and then return the document to the client asynchronously; client side it will there will be lots of trivial (in terms of processing) user interaction. I anticipate that the entries that I will loop over will be in the thousands so I guess template engine is my main feature requirement in a web framework.
My app will--for the most part--be a single page application with views changing asynchronously rather than reloading any pages.
I may split up the loading/rendering and returning of documents into blocks, increasing the number of asynchronous calls further.
I come from a python/flask (jinja2) and java servlet/playframework (japid) background and was just wondering if this project seemed like a decent fit for a node.js project (I have no node experience, have only read about it) or if I should just stick to my familiar tech stacks. I am just making sure I'm not forcing node on something that I shouldn't be.
A key benefit of Node is its streams architecture and patterns. Similar to Unix pipelines, Node streams allow processing lots of data without having to buffer it all into memory at once.
Node.js is well-suited for streaming out large templates which you would rather not buffer into memory all at once (for example, if they are very large, or if you have many connections, so you want a low memory footprint for each connection).
I am not familiar with these, but a quick search for streaming template engines reveals:
https://npmjs.org/package/as_ejs
https://npmjs.org/package/dt-stream
https://npmjs.org/package/blue
Whether it is worthwhile depends on your application.

Structure recommendation [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I try to find a good directory structure for my nodejs/express/mongoDB application.
Currently I use the native-mongodb driver which feels nice and fast but is limited when a proper structure should be defined... when MVC is the express/node way to go defining proper db models is not that easy.
Although mongoose and its concept of schemas would make the actual design of models easy but I am not that big of a fan of another layer on top of my stack... it feels kinda bloated to me.
I looked for an alternative and found mongoskin which is a thin wrapper on top of the native-driver but adds some features to support MVC-ish patterns.
In general I found this to be a common problem for other people too. I appreciate the idea presented in the link: https://stackoverflow.com/a/8428281/1055685
Nevertheless the query inside the model directory is not really MVC-like (as mentioned in the comments...) - I do not like it...
The MVC demos in express are not that helpful... did you find some inspiration there?
Which pattern do you recommend to follow (if MVC is recommended models are the real problem)?
Do you recommend mongoskin in general?
I would suggest looking at either LocomotiveJS or RailwayJS
LocomotiveJS is more "lightweight" and there is a great boilerplate available to get you started.
RailwayJS contains more "generators" to make it more rails-like however.

mongoose best-practice with data layer in node application [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
looking into the nodejs server stack with nodejs/express and mongoose
What is considered a best practice solution?
(1) Creating a mongoose datamodel module then working with the model objects
(2) Creating a wrapper datalayer module that will internally use the mongoose model
Pros for (1)
I really like the OOP style classes mongoose gives me, add my own methods, my own setters and getters, I can add validation and event-handlers, and use the DataModel without redefining it in another module.
Pros for (2)
I should be able to mockup the data layer with simpler implementation (tests, etc..)
or switch a database if needed.
What do you think?
I usually start with the easiest and least complex option to start and only move to a more complex one when it's really needed. So in this case I always start with Option 1 and have yet to find an instance where I wish I had started with Option 2. If I really need to change databases, I'll do the work then instead of doing more work upfront for something I may never need.
Keep in mind that this depends on how big of a project it is and how many people are working on it. If it's a small team (or just you) extra layers of abstraction generally aren't needed. If it's a large project with a large team, I'd take a bit longer figuring out the best architecture for long term maintainability.

Reading Material on Async Programming Practices [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Asynchronous programming is the next up-and-coming paradigm... or so it seems. I have been programming in Node.js for the past few months and have been learning to write code this way. I have a coworker who works in Silverlight and I have been trying to teach him how to use the TPL. I have also been showing him the "await" keyword and how it works.
After a while, using callbacks becomes pretty normal. In Node.js, I am using the caolan/async project to avoid deeply nested callbacks. I have taken a peek at the source code, but it is like reading the STL for the very first time.
Even though I have learned a lot of techniques that work in this environment, I worry I am missing others. I was curious if there were any reading materials/videos that explained async programming techniques and how to build an async library like the TPL or caolan/async.
Just trying to master the paradigm before it's everywhere.
Well even though I know most of Async source code and how does it work, but I still use async mostly. So don't worry about that, you don't need to know exactly how it works. But as of learning, well I suggest you to read these articles:
http://book.mixu.net/node/ch7.html
http://stella.laurenzo.org/2011/03/bulletproof-node-js-coding/
http://howtonode.org/promises
http://web.archive.org/web/20120111150910/http://nodebits.org/distilled-patterns?
http://raynos.github.com/presentation/shower/controlflow.htm (from Raynos comment)
These are the best things that I've seen on the net explaining async control flow at without any abstractions.

Resources