Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One of these is not like the others: node.js is a nice, progressive step forward, not a leap that is discontinuous with what preceded it like WebGL and WebSockets. And certainly, node.js did not enable this chat example to happen -- not in the same way that WebGL or WebSockets did.

<rant>I am getting a little tired with the node.js cheerleading on HN. I've tried it and I don't see it as a huge leap forward from what can be done with Twisted + Python, or Go, or many other solutions. The major drawback is that you're writing in Javascript -- and maybe I have been doing something wrong, but any sufficiently complex JS app tends towards callback spaghetti, in my experience. (And I do like writing JS)</rant>



People are "cheerleading" node.js because they tried it, successfully built something with it and want to give proper credit to their stack.

The existence/prevalence of node.js submissions does not imply that anyone thinks it any more technologically capable than Twisted, Go, Tornado, or eventlet. Node.js just happens to be simpler to install, have more easily accessible documentation and has more of a network effect going for it.


My point is that the proliferation of HN posts regarding node.js is not reflective or driven by a host of new and significant improvements that it brings to the table. I suppose one response is this shouldn't be surprising, since anything implemented after the 70s could have been done with C instead of language X.

But my complaint is that it seems a lot of attention is paid to projects which are not actually doing new things with node.js, just things that have already been done with other technologies.

Actually, this comment sums it up much better than my comment: http://news.ycombinator.com/item?id=1549023


I'd argue that being in javascript is an advantage rather than a disadvantage. Sharing code between server and client (browser) is much easier, and there is no alternative to javascript in the browser.

I'm not saying javascript is the king of languages, just that we're limited to it because that's what's in the browser, and writing server code in the same language simplifies things.


> Sharing code between server and client (browser) is much easier, and there is no alternative to javascript in the browser.

That's a fallacy, the environments have nothing in common, the coding styles and interactions don't either, the only things you're going to be able to meaningfully share are trivial helper libraries à la underscore..

> and writing server code in the same language simplifies things.

Why? How? Where? I see that assertion often, but I have yet to see it backed by anything but "because I said so".


Actually the environments have a whole lot in common. Templating, validation and data retrieval/storage for example can be done both client & server-side, depending on the situation.


A fallacy? Sharing code between client and server is easier when the two are in the same language than when the two are in a different language. How is that flawed reasoning?

One example: you can run the same input validation in the client as you do in the server if you can easily share code between the two.

But there is way more. Here's an example of an application that shares all of its data models between client and server: http://tilemill.com/docs/models.html


Server side logic is usually radically different. And given that you usually share information between the server and the client in a language agnostic manner (e.g. JSON) and that the client (browser) cannot be trusted with other than view logic, I see few cases where implementation specific code sharing contributes greatly.

The server and the client has such different concerns that code sharing probably wouldn't contribute that much.


Except the client can act as a server once you start thinking about localStorage caching. Form/input validation is another thing which is really useful to have on both the client and server and benefits greatly from code sharing.


Except in most cases validation cannot be complete on the client side, anything related to server side logic has to be additionally checked.

Validation is also two different concerns if you compare serverside vs clientside.

http://stackoverflow.com/questions/162159/javascript-client-...

Basically: Client side validation is about user experience, Server side is about security. I'm hard pressed to believe you can get both with the same code.

I also don't see how localStorage is relevant to code sharing between client and server.


Rendering templated HTML on the server for serving the first page from cache and then using the same code to render subsequent pages on the client is one use I'd like to experiment with.


I definitely regard server side JavaScript as a strong advantage - doing client development in JavaScript, database development in CouchDB is feels wrong to be doing the server application component in something else.


Why does it feel wrong? JavaScript isn't that great a language; even if you use CoffeeScript, there are nicer languages out there, and on the server you have the option of using whatever language you want.

Using the same language on client and server can come in handy if you've got some non-trivial amount of code they can share in common. When I made a multi-user text editor (think Etherpad, but simpler), all the code for transforming the editing operations so that everybody's documents converge was written in a single JavaScript file, which I ran on both the client and the server, via node.js. That was great. That was fun. But if you don't have a situation like that, where's the advantage in using JS on the server?


Of course, the comment about it being "wrong" is completely subjective. I just really like JavaScript these days (and I've been paid to program in a lot of other languages - Lisp, C, C++, PostScript, Java, C#...).


> but any sufficiently complex JS app tends towards callback spaghetti

Callback spaghetti is quite easy to avoid.

> and maybe I have been doing something wrong

If you have callback spaghetti, regardless of the complexity of the app, you are most likely doing something wrong.

> I don't see it as a huge leap forward from what can be done with Twisted + Python, or Go

Of course not, but it's not hard to imagine that Node.js will have the biggest ecosystem in this space and with it comes advantages (and perhaps disadvantages).


> Callback spaghetti is quite easy to avoid.

That's what people say about most bad programming practices. "It's not the language, you can write good code in the language." This doesn't really help, though. The reality of programming is that different languages encourage different styles of programming. They shape the eco-system, the space of the solutions you will find for you problems.

JavaScript lacks tools for managing complexity. I don't work with it a lot, but most of the JS code I've seen recently was, in fact, callback spaghetti (with arbitrary global state modifications). That's the ecosystem the language created. Hearing how it's avoidable doesn't make my life any easier when I work with such code.


This is subjective and anecdotal, but every large JS framework whose source I've examined shows this tendency towards spaghetti.


I use node.js for batch processing: it's just fantastic. Instead of ugly bash scripts that are absolutely unreadable and therefore unmaintainable, I get to write beautiful Javascript and lightning fast JSON processing and transformation. This is an area where node.js really shines and that is not often mentioned.

As for client-server development, I think the future is going back to the client. Instead of "dumb clients", what we have now are extremely powerful and fast clients. It's much cheaper to send raw data to the client and compute it there, since as a web developer you pay for server CPU, but not for client CPU. (Of course, it's a little wasteful since the computation happens many times instead of one; but you can always send the results back to the server for caching, if that worries you).


> I use node.js for batch processing: it's just fantastic. Instead of ugly bash scripts that are absolutely unreadable and therefore unmaintainable

I am confused: if you don't like bash scripts why in science's sake did you keep using them instead of one of the billion alternatives out there?

> This is an area where node.js really shines and that is not often mentioned.

Because it's nonsensical. What makes node.js "shine" more at batch processing more than every other language on the planet?


> What makes node.js "shine" more at batch processing more than every other language on the planet?

Because every other language on the planet is not Javascript...?

- - -

Edit: maybe I should clarify? The only other solution (that I know of) to write Javascript for the server is Helma; I've tried it and it kind of works but it's very clumsy. Is there another simple way to write JS on a Linux box?

- - -

Edit2: maybe I should not clarify.


Node.js is great because bash is ugly. Way to go indeed.


[deleted]


> You could have done with AJAX what WebSockets does

If you consider long-polling (the nearest approximation you can do with AJAX) the same as true bi-directional communication.


[deleted]


Please show me how a server can send two consecutive messages to a long-polling client without requiring the client to make a request between the receipt of message 1 and message 2.


I'm not sure what you are replying to as it's been redacted, but just wanted to say that there's really nothing wrong with that technique. Developers tend to way overestimate the cost of a long polling request with minimal headers.

Also the speed benefit of websockets over long polling is so trivial that it doesn't really matter.


I could not agree more with this comment.


A couple of posts were deleted on this thread, perhaps because the authors realized they were mistaken. The claim was that long-polling and WebSockets are bi-directional in the same sense, and mine was that one type of bi-directionality is simulated and has real limitations.

It doesn't matter if the overhead is low: with long-polling, the server can't send a waiting message until the client requests them. With true sockets, the server can send messages as soon as they are available.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: