Live data from Hacker News

Ask HN: Why Node.js and for which type of App?

news.ycombinator.com

1–10 of 49 posts

Ask HN: Why Node.js and for which type of App?

#1
Hi guys,

i'm a computer scientist student and previously read a lot about Node.js. But, to be honest, i have not really a feeling for what i can use a node.js App. Is it a desktop application where i can use html to render the views and the communication between view an backend works i.e. with a RestAPI? Or is it for pure web applications?

Thanks a lot for your inputs.

edit: started yesterday with the node.js tutorial from Visual Studio Code and was just curious what type of app i can build with it

Re: Ask HN: Why Node.js and for which type of App?

#2
Node.js in itself is a wrapper around V8, the JavaScript engine of Google Chrome. It is used to execute JavaScript on the server for example to implement REST APIs. I would consider Node.js if you implement actual webbased software because you could take advantage of a shared codebase. If you want to display content on the internet there are more comfortable alternatives you could use.

What you are probably looking for is Node-Webkit. It is a toolkit to basically pack a stand alone application with a browser and node.js to create a desktop application.

I personally would recommend to use QT or GTK or some Windows framework if you want to learn how to program a desktop application. No need to deal with the performance problems of web technology and then ship a whole browser with your app if you have to learn something new anyway. In my opinion you should use Node-Webkit only if you know why you use it or if you do not know how to use anything else.

Re: Ask HN: Why Node.js and for which type of App?

#4
post #3

Generally Node has been targeted at server side projects to date (i.e. building web APIs/etc). Stand it up register a listener on a port, and start servicing requests.

Curious: isn't Node single-threaded? How can it scale on a server i.e. on a beefy server with 64 hyperthreads, now can Node capitalize on the available horsepower?

Re: Ask HN: Why Node.js and for which type of App?

#5
post #3

Generally Node has been targeted at server side projects to date (i.e. building web APIs/etc). Stand it up register a listener on a port, and start servicing requests.

Curious: isn't Node single-threaded? How can it scale on a server i.e. on a beefy server with 64 hyperthreads, now can Node capitalize on the available horsepower?

Node includes the cluster module to create child processes that all share the same server port, allowing you to take advantage of all available cores.

You can also run multiple node processes on the same machine (on multiple ports) and use something like NGinx to loadbalance between them. You can use this to get zero-downtime upgrades on a single machine.

Re: Ask HN: Why Node.js and for which type of App?

#6
post #3

Generally Node has been targeted at server side projects to date (i.e. building web APIs/etc). Stand it up register a listener on a port, and start servicing requests.

Curious: isn't Node single-threaded? How can it scale on a server i.e. on a beefy server with 64 hyperthreads, now can Node capitalize on the available horsepower?

Previously you could launched multiple instance of your program. Today you can use https://nodejs.org/api/cluster.html and leverage all those sweet cores on your server. You can multiprocess but not multithread.

Re: Ask HN: Why Node.js and for which type of App?

#8
TL;DR: Apps that perform high I/O.

For example, if your app is just getting data from a database and returning it to the user, 90% of your time will be spent:

* Receiving the user's request (Network, IO)

* Fetching something from the DB (Network, IO)

* Returning the data (Network, IO)

That's a good scenario for an event based system like Node.js.

Try not to use node.js if you're CPU-bound: rendering images or PDF, processing sound, etc. If you do need to do something like that and you still want to use node.js you should use a processing queue.

Re: Ask HN: Why Node.js and for which type of App?

#9
Node is a tool for running Javascript on the server. Your desire to use it will stem entirely upon your desire to write javascript to perform server side tasks.

There are many languages and environments for running code on the server, so I personally have problems finding a niche where Javascript is the obviously better choice for these tasks. In my experience with it so far, it's "fast enough" for IO bound tasks (routing, serving CRUD applications), but if you'd like to perform any form of computation on inputs, you'd probably be better served by a different language ecosystem.

Re: Ask HN: Why Node.js and for which type of App?

#10

Node.js in itself is a wrapper around V8, the JavaScript engine of Google Chrome. It is used to execute JavaScript on the server for example to implement REST APIs. I would consider Node.js if you implement actual webbased software because you could take advantage of a shared codebase. If you want to display content on the internet there are more comfortable alternatives you could use. What you are probably looking f…

Hi there, thanks for your response.

I programmed some Desktop Apps with Java and C#. And during some hackathons i used python+flask+nginx to implement a Web-Applications with a RestAPI on the backend.

I was just curious for which type of application i can use node.js (since i didn't use javascript on the backend at all). Usually i used PHP, C# or Pyhton for the backend..

Is MS Windows 10 using node.js for their applications (since its possible to develop Node.js apps in Visual Studio Code)?

Post reply on HN