42

Recently I got introduced to node.js and cool packages like express and jade. I have few questions consistently knocking my door:

If I pick node.js to build my next website, I will be using JavaScript to write my server-side complicated logic? but I don't think you can compare JavaScript with Java or Python to write server-side code as they have such a vast ocean of libraries. Is node.js really meant for it? or I have missed something?

Can I call Java or Python from node.js?

agf
  • 171,228
  • 44
  • 289
  • 238
Vishal
  • 19,879
  • 23
  • 80
  • 93
  • 2
    +1, +fav: I have already made the same question to myself! with no answer! really interested in this answer =) – Arthur Neves Aug 11 '11 at 22:51
  • http://stackoverflow.com/questions/4488614/node-js-vs-java-for-comet-application check discussion on nodejs vs java – TeaCupApp Aug 11 '11 at 22:59
  • And this one is more bias about nodejs http://www.quora.com/What-are-the-benefits-of-developing-in-node-js-versus-Python – TeaCupApp Aug 11 '11 at 23:01
  • 2
    Can you clarify the question a little bit in the following aspect: Are you asking whether one can produce complex but well-organized & maintainable business logic code with Javascript OR one has enough power (libraries) to write complex server-side code with Javascript (nodejs)? In other words, are you targeting maintainability or the availability of the libraries? – Guven Aug 11 '11 at 23:05
  • 1
    @Guven: It's about availability of the libraries in JavaScript in comparison to Java or Python. – Vishal Aug 11 '11 at 23:13

6 Answers6

30

Not quite sure what most of these folks are talking about.

A "vast ocean of libraries" is something the community is actively working on. Check this: http://search.npmjs.org/#/_analytics -- there were 8 packages published yesterday

Its not going to solve your software design for you. As for where and how to write business logic, many of us embrace mvc or mvvm or something close to it. If you're building an application and like how Rubyists (for example), structure their code you might look at doing something just like that -- aint nobody going to tell you how to structure your code.

Check https://github.com/joyent/node/wiki/modules

Some of the more popular libraries for doing the day to day:

There's also a host of ORMs out there, if thats your bag. Things like http://mongoosejs.com/, http://sequelizejs.com/ and friends

Test-driven development is at the core of node. There are 15 different TDD packages to choose from that range from full code coverage analysis to custom assert modules.

Saying all modules are incomplete is silly. There is an incredibly dedicated group of people building and maintaining tons working open-source in this community every day.

There might be reasons to pass over node, but its not for an inactive community or lack of libraries.

Josh
  • 12,602
  • 2
  • 41
  • 47
  • 2
    Considering this was answered in 2011 - these days in 2016 the answer is a bit different. We saw some JS frameworks win the landscape lately such as ReactJS and Node.js still holding strong but for pure API you now have many options from Amazon API to python to laravel/slim. – Ron Oct 21 '16 at 16:34
4

I would say you missed something - more specifically, the core purpose of Node.js, that is, the asynchronous I/O model.

I started a little pet project to test Node.js - how it "feels" and how to program on it. I became impressed by the ease of working in such ecosystem: Node.js code is easy to write (although its asynchronous paradigm is not that straightforward for the conventional programmer), libraries are easy to build etc. etc. Even npm is amazingly easy: I just found the most straightforward way to provide code of your own as a library is to make a public package of it - and it is absurdly easy!

However, there is not much good tools to work with Node.js. Maybe because it is too easy to do anything, most libraries are partially-implemented, undocumented solutions.

Also, note that the relevant difference of Node.js is not the JavaScript language, but the asynchronous I/O model. It is the most interesting aspect of Node.js, but the asynchronous programming style is not as well tested as the conventional way of web development. Maybe it is really the marvel that is propagandized - or perhaps, it is not as good as promised.

Even in the case it pays off, will you have enough developers to maintain such an (at least still) unusual codebase? If you can get a lot of advantages from the asynchronous "way of life" of Node.js, you can use more consolidated languages and frameworks, such as Twisted for Python (which is my preferred languabe, so take care with my opinion :) ). There may be something like this for Java, too. Anyway, I suspect that you do not have a lot of interest in this model for now, since your question focuses more on languages than in the programming paradigm, so Node.js does not have much to offer to you anyway.

So... no, I would not develop something professonaly in Node.js for now, although I think it is both fun and instructive to study. You can do it, however - just do not do it without having in mind the main purpose of Node.js: asynchronous-IO, event-driven programming. If it is what you want, Node.js is a good alternative.

brandizzi
  • 26,083
  • 8
  • 103
  • 158
  • `I would not develop something professionally in Node.js for now` - Is Node.js good enough to be used for production in 2018? – Mohan Sharma Jul 20 '18 at 09:18
  • 1
    @MohanSharma I posted this answer a long time ago, and I'm confident things are different now. The platform is more stable these days, for sure, and there is a huge community around it. I guess this is the most important factor, indeed: more people using it means many errors were already found and repaired, and newer ones have more support. So, if it may help you, go ahead using Node! – brandizzi Jul 28 '18 at 20:56
3

Ryan did not start with JavaScript. A large part of why Node was created in JavaScript is that JavaScript lacked vast oceans of libraries.

Those vast oceans of libraries are almost all written in blocking code.

To take full advantage of Node.js you need to limit your self to non blocking libraries. Which means that might need to write some libraries to complete your project in Node.js.

generalhenry
  • 17,227
  • 4
  • 48
  • 63
  • +1 : because a lot of ppl think that as Node.js is javascript we have million of libraries out there, however most of them are blocking code! which doesnt make sense have in Node.js – Arthur Neves Aug 12 '11 at 13:17
2

Of course, you can use Python, PHP, c++ or other technologies with nodejs 'cuz node can run it as a child process. Nodejs give you the freedom to use any technology which you want inside itself. You can use whatever you want combining the most performance programs.

Lin Du
  • 88,126
  • 95
  • 281
  • 483
Paul Rumkin
  • 6,737
  • 2
  • 25
  • 35
2

I think you'll be surprised by the amount of work you can get done in JavaScript via Node.js. There are a bunch of libraries available for Node and more are being written all the time. Furthermore, native extensions are also available for those times where you might need to drop down to a lower-level.

If you think there's a gap where Node won't be able to provide for your business logic, take a look around NPM or give Google a quick serch to see if anyone else has already solved your problem.

Michelle Tilley
  • 157,729
  • 40
  • 374
  • 311
  • Do you have some real experience?! some website?! or some solution that you can point me out that is using pure Node.js?! – Arthur Neves Aug 12 '11 at 13:16
  • 2
    Most of my own personal Node projects are smaller, but it's not difficult to find larger Node apps in the wild. [WordSquared](http://wordsquared.com/) is a famous one, and there have been some write-ups on the app. The backend for [Voxer](http://voxer.com/) is written in Node. You're sure to find [lists](https://github.com/joyent/node/wiki/Projects,-Applications,-and-Companies-Using-Node), [posts](http://www.quora.com/Node-js/What-are-the-biggest-websites-built-with-Node-js-on-the-server-side), and [directories](http://www.nodecloud.org/) if you take a look around. – Michelle Tilley Aug 13 '11 at 02:17
  • That's not to say Node is the right tool for every job, nor am I saying that you should build your app *solely* on Node. That said, asserting that Node isn't useful because it doesn't have a "vast ocean of libraries" is a bit of a fallacy. – Michelle Tilley Aug 13 '11 at 02:17
  • Oh, one more! I don't know how I forgot it, but we're using Node.js where I work to drive the "live" portions of our site (environments that function as multiplayer games). – Michelle Tilley Aug 13 '11 at 05:42
0

There are some things that JavaScript just can't do. If you come up against those Node might not be the best choice for your app. However you can probably accomplish most of what you need.

As far as the API being limited, I suggest you take a look at npm and all the libraries in its repository. Specifically ones like underscore.js. Many aim to fill in the gaps of what native JavaScript lacks compared to other languages.

sym3tri
  • 3,747
  • 1
  • 29
  • 25