> Another reason to write in JS would be to gain code reuse.
> If the person has a web app that uses node, then they can
> share code between the web and CLI applications.
I often see this argument presented for just about any server side js. I often wonder about actual real world reuse though.
I actually reuse the same code a lot, which is a very nice feature once you get used to it.
I share code between the client and server. For example, I have data type checks where I reuse the same library and the same application specific code on both the client and server.
I expose substantial portions of my server-side code via the command line. I also frequently call shell scripts from node as there are certain things I find easier to write in a shell script.
That said, I don't know if this amount of reuse is typical. And, code reuse is clearly not the only consideration.
Look at the top 2 depended on modules modules in the entire of the server side node.js ecosystem and guess what they were written for - https://npmjs.org/
I wrote a database specifically for web browsers and someone case along and write a relatively small pull request and it now works in node / on the server / with a http api - http://pouchdb.com