Live data from Hacker News

How to write a command line application in Node.js

blog.liangzan.net

31–40 of 56 posts

Re: How to write a command line application in Node.js

#31
post #3
post #2

Is there a reason to build a command line application in Node.js? It doesn't really seem like Node is the right tool for the job...

It's fun, simple, fast, and has a good package manager. JS is a high level scripting language like python or ruby but gives significant speed benefits in a lot of cases (in particular, the startup time of CLI programs written in Ruby always bothers me). If you want to write in C for performance reasons, go ahead. But if your other alternatives are Python or Ruby and you already know JS, give node a go -- it's pretty…

This is what happens when you let front-end developers loose in your infrastructure.

Re: How to write a command line application in Node.js

#32
post #12
post #6

Earlier quoted context omitted.

There are tons of better options to choose from. If you're not making a web UI, literally any choice is better than Javascript, unless that is the only language you know.

Compared to most languages you'd use for a commandline application, node has a simple, usable async I/O interface, and the libraries you can get for it actually assume async. If you need that, there are only a handful of choices and node is one of them.

Which scripting language doesn't have an async library available (most of which don't descend into the Chinese Hell of Being Called Back Ad Infinitum)? Granted, most of the other languages have lots of libraries that don't play well with async, but then again, that's mostly because they have lots of libraries. And it's not like there's a guarantee that a random Node package won't screw you up, either.

I'm not really arguing against using JavaScript for command-line interfaces. I'd much rather see that than the same in PHP, and if the programmers don't know Perl, Python or Ruby, then why not? We're talking about an area where there are still way to many hacks that consist of badly written bash scripts with lots of inline sed and awk...

Re: How to write a command line application in Node.js

#33
post #31
post #3

Earlier quoted context omitted.

It's fun, simple, fast, and has a good package manager. JS is a high level scripting language like python or ruby but gives significant speed benefits in a lot of cases (in particular, the startup time of CLI programs written in Ruby always bothers me). If you want to write in C for performance reasons, go ahead. But if your other alternatives are Python or Ruby and you already know JS, give node a go -- it's pretty…

This is what happens when you let front-end developers loose in your infrastructure.

Don't knock it 'till you try it. Most developers would balk at the idea of creating a project in something that isn't their favorite language, especially when they've been burned by poor uses of that language before.

Re: How to write a command line application in Node.js

#34
in this day and age, if i had to create a command line app, from zero, i would definetly start with go.. it has all the functionality in standard libs and the package manager can handle github repos for third-parties (like mongo or mysql drivers).. you just compile it and go!

can be as simple than that? the right tool for the job..

if i would create a library that everyone could use and embed i would use C for that..

if i would like to build a VM, a compiler, a browser or a OS i would use c++ (is almost c, fast and gives you easy composability and control)

i would use javascript.. but only in the browser and because and dont have nowhere to go or to runaway for.. (no transpiling either please)

this is just the general experience of my years of coding and deling with every lang in the earth.. rsrs

ruby is pretty, eyecandy, bu is like a virgen that cant be touched.. python looks just like perl.. is a complete mess, and is like the mafia,i prefer not to touch or to have any involvement with them.. java is the frankenstein child of c++.. you can create big software with it.. but to many keywords and excessive use of vtables..

and for ui and web, network, etc.. i would use something like dart for this job, any day.. the code can grow and you can still understand your code

so these days i would use c, c++, go or dart.. in the case i can choose of course.. :)

Re: How to write a command line application in Node.js

#35
post #31
post #3

Earlier quoted context omitted.

It's fun, simple, fast, and has a good package manager. JS is a high level scripting language like python or ruby but gives significant speed benefits in a lot of cases (in particular, the startup time of CLI programs written in Ruby always bothers me). If you want to write in C for performance reasons, go ahead. But if your other alternatives are Python or Ruby and you already know JS, give node a go -- it's pretty…

This is what happens when you let front-end developers loose in your infrastructure.

[deleted]

Re: How to write a command line application in Node.js

#36
post #6
post #4

Earlier quoted context omitted.

If you're doing crazy heavy processing or something, it's not the right tool. But you wouldn't do that in JS. You'd shell out or call something native. Node is best used managing parallel streams of stuff. Perhaps surprisingly, a command line application is a great example of that. I would much rather build a nontrivial command line app in node than in anything else. Try it, you'll see.

There are tons of better options to choose from. If you're not making a web UI, literally any choice is better than Javascript, unless that is the only language you know.

[deleted]

Re: How to write a command line application in Node.js

#37
post #33
post #31

Earlier quoted context omitted.

This is what happens when you let front-end developers loose in your infrastructure.

Don't knock it 'till you try it. Most developers would balk at the idea of creating a project in something that isn't their favorite language, especially when they've been burned by poor uses of that language before.

I have written plenty of JS, and absolutely hate it.

Re: How to write a command line application in Node.js

#38
post #2

Is there a reason to build a command line application in Node.js? It doesn't really seem like Node is the right tool for the job...

I was thinking the same, does nodejs even has a complete linux api interface like python or ruby?

EDIT: Ok, just went through the nodejs api, they have cover a lot of ground now :)

Re: How to write a command line application in Node.js

#39
post #31
post #3

Earlier quoted context omitted.

It's fun, simple, fast, and has a good package manager. JS is a high level scripting language like python or ruby but gives significant speed benefits in a lot of cases (in particular, the startup time of CLI programs written in Ruby always bothers me). If you want to write in C for performance reasons, go ahead. But if your other alternatives are Python or Ruby and you already know JS, give node a go -- it's pretty…

This is what happens when you let front-end developers loose in your infrastructure.

Well, there's my daily laugh :)

Re: How to write a command line application in Node.js

#40
post #27
post #26

Earlier quoted context omitted.

Hahaha really? Have you seen a pom file on a real project its about 10 pages with plugins galore.

The verbosity of the XML pom is the problem. Alternative syntax using the same coordinate system are great and much easier on the eyes. The real value in maven (I think) is having that clean dependency chain and it works great. XML is what sucks (especially doing it by hand).

Yeah, pom files are disgusting, but leiningen (the clojure build tool) is built on top of maven and it's wonderful.

    [enlive "1.1.1"]
instead of

    
      enlive
      enlive
      1.1.1
    
Post reply on HN