Live data from Hacker News

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

news.ycombinator.com

11–20 of 49 posts

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

#11
Node.js is typically used for servicing web applications, but it has found some other surprising uses as well. There's a fairly sizable robotics (check out Johnny-Five) and drone community around it as well. The programming editor Atom by Github is also a "traditional" desktop app with Node.js at the core.

In my opinion, Node's biggest advantage today is the absolutely massive module ecosystem that has sprung up around it in record time. It's already the biggest, as well as the fastest growing according to http://www.modulecounts.com/ You can find a package for almost everything imaginable, and your typical Node app is made up of dozens of these modules. So take a look at https://www.npmjs.com/, and try searching for whatever field interests you.

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

#12
Having used Node.js recently for a high volume service my feeling is it is best for lots of network communication.. but not long running or CPU/disk intensive operations. So, we're slowly transitioning to a Go backend with a slim Node.js layer to form the very friendly API while we use some RPC between the Node and Go. In this, Node.js is amazing and--I would guess--hard to beat.

EDIT: Clarify with "CPU/disk intensive operations"

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

#13

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, pr…

Thanks!

So, you would use node.js just as a service to process data on the server side and not as a application for the desktop (with a gui)?

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

#15
post #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 appli…

I do not think, that node.js is involved in the JavaScript apps for Windows. In your place I would test node.js the next time you do something like you did with Flask. If you now C#, I would not recommend to waste time to implement a node-based Windows GUI app.

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

#16
post #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 (ro…

> 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.

Now that's often what people think of Node.js, but that's not really why Node.js is interesting. It's not just "JavaScript on the browser".

Instead, you should think of Node.js more like a JavaScript binding to `libuv`, which is the C library that provides the event-driven I/O core (event loop / queue). (An example for a `libuv` binding in another language, Lua would be `luv` [1].)

Reasons why JavaScript was picked for Node.js: 1) It already dealt with events due to its usage in browsers and 2) a fast existing JIT runtime, V8.

To answer the original question: You might want to use Node.js if your problem is a good fit for the Reactor pattern [2]. For example, scalable network services that "mediate" between a lot of (async) I/O. Not number crunching. Nginx uses the same core concept (Reactor).

[1]: https://github.com/luvit/luv

[2]: https://en.wikipedia.org/wiki/Reactor_pattern

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

#17
post #13

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, pr…

Thanks! So, you would use node.js just as a service to process data on the server side and not as a application for the desktop (with a gui)?

Typically Node.js is for high I/O web applications. Thanks to the wonderful asynchronicity of javascript (callbacks "let me know when this is ready/done") it's really wonderful for browser-based programs.

However, there is growing discussion about using Node.js for desktop applications. Please see https://nodesource.com/blog/node-desktop-applications

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

#18
I found Node.js to be quite difficult to work with, mostly due to nature of Javascript. Module ecosystem is vast, but each one has an API written in a different style. Combine that with no type-checking and lack of robust IDE auto-completion (Webstorm is quite disappointing at the moment) - and you get a frustrating experience. Oh, and also add asynchronicity into the mix.

Making restful APIs is quite fun with it, though.

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

#19
Node.js itself is Google's V8 JavaScript engine (the one in Google Chrome) coupled with a heap of asynchronous non-blocking APIs for IO (http, file system, etc). In that sense, you'd usually use it as a web server (using the builtin http module), although you can pretty much use Node.js just as you'd use any scripting language.

npm[0], Node.js's package manager, is also pretty useful. There's a package to do most things.

Yes, there's some projects that let you create desktop applications using Node.js - what they're doing is using an embedded version of Chrome and pairing it with Node.js. You can then use HTML and CSS to create a user-interface that you can then manipulate with JavaScript. You end up with a fairly bloated distributable application, but the JavaScript code runs on Mac, Windows and Linux.

NodeSchool[1] seems to be the recommended learning resource for Node.js. I've never really used it, but it looks pretty good.

[0] https://www.npmjs.com/ [1] http://nodeschool.io/

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

#20
I've been use node.js for the server part of my browser multiplayer game. It's been a great decision due to the amount of shared code I have between the client and server.

For example, I share the physics code which is responsible for controlling the simulation that runs on both the server (authoritative) and clients (for predictions).

I no longer have to switch languages which also saves a lot of time!

Post reply on HN