Programming with Node's async model makes it extremely powerful and fast to run database queries and file functions in parallel, but the downside is the potential for huge callback spaghetti indeed. But the callback spaghetti problem can be largely solved by dropping in, for example, the IcedCoffeeScript fork: http://maxtaco.github.com/coffee-script/ Or the previous JavaScript TAME functionality: http://tamejs.org/ T…
If you expect a lot of callback it makes more sense to design that functionality as an object rather than as a single function. That way you can spread callbacks over many functionality and still maintain modularity.
If you're using Node.js, you're doing life wrong
91–100 of 100 posts
Re: If you're using Node.js, you're doing life wrong
#92I guess it depends on what I how I want to do my life. If I want to live my life by learning new ideas and using those ideas for something tangible, Node's a pretty good choice. If I want to live my life as a person with a particular language/architectual ideology, then anything that is not in that world view is wrong. I like node for system level scripting. I find bash annoying and non portable to windows. I really…
Don't let the name fool you, it's not only for databases. I would say that it's probably more suitable for general purpose scripts than Node, though some of the APIs are a bit clumsy.
It's not open source, but it's free and cross platform and actually pretty good for a lot of general purpose scripting. Seems that it is developed by a single guy. I found out about it a few years ago and used it to get some things quickly done.
Re: If you're using Node.js, you're doing life wrong
#93Re: If you're using Node.js, you're doing life wrong
#94Okay, let's play a little game. I'm going to describe a scenario (using Python; feel free to substitute the equivalent Ruby terms if that makes it more relevant for you). You're a pretty good Python developer. You know, and feel comfortable with, not just Python, but the entire ecosystem. Virtualenv, pip, the whole nine yards. And now you're working on a really nifty Django app, maybe a CRM or something, when you rea…
Re: If you're using Node.js, you're doing life wrong
#95Earlier quoted context omitted.
You're welcome to use whatever you like, of course — I'm just saying that you haven't really raised any specific objections that couldn't be (and haven't been) leveled against most other languages. Ignoring the confusion of a language and a framework, so far, your concrete objections seem to be: • Node.js is a framework built by people other than the language's core maintainers (which is true of most frameworks) • If…
No, there is no language v. framework confusion on my part. What I'm arguing is a concrete, fundamental fact that pertains to both the framework and the runtime. I'm not sure what I can do to clarify the point anymore: the V8 engine is created and maintained for the purposes of speeding up a web browser's processing of Javascript within the context of an HTML document. The goals of the team implementing the runtime a…
And I think it's kind of a basic misconception that V8 is made just with web browsers in mind. If you look on the V8 developer site, nowhere does it say anything close to that. Their stated objective is "fast execution of large JavaScript applications." They go out of their way to draw a distinction between the browser and the engine, explaining what is and isn't part of JavaScript (e.g. the DOM is just an interface that browsers choose to expose). Is Chrome the original client for V8? Sure. And shell scripts were the original use case for Python. It seems to me that "V8 is just a browser language" is the new "Python is just a scripting language."
And I wouldn't describe the language-level ability to write asynchronous code in a synchronous fashion a fundamental feature. It's really cool and allows a lot of expressiveness, but so would a lot of potential changes in, say, Ruby. If you don't want the language feature, there are really nice libraries that get you most of the way there. (And I don't really see how the existence of CoffeeScript or ICS is any more an indictment of V8 than the existence of Scala is of the JVM. Choice is a good thing. Lots of people prefer vanilla JavaScript.)
Re: If you're using Node.js, you're doing life wrong
#96Here's my problem and why I don't care to use it: It's a community built around an implementation of a language which they do not control. Who is Guido or Matz in node.js? Ryan Dahl I suppose; does he take requests or hold discussions concerning the future evolution of the language? Does he issue any rationale documents concerning his language design philosophy? Could he add multithreading to V8 and if so, why hasn't…
Re: If you're using Node.js, you're doing life wrong
#97I don't really have a dog in this fight, but I see node.js as being "disruptive": * It's "not as good" as languages/environments like Erlang. * But it's good enough, and significantly simpler, as an approach to tackle a certain class of problems. This, combined with widespread knowledge of Javascript, will probably make it fairly widely used.
I disagree about it being that "disruptive". The concepts that it uses aren't new. They've existed in POSIX environments for decades. At a very basic level, Node.js is a callback-based API that's based around some(probably select) notifier loop. That's not particularly new.
However, Node is written from head to toe to take advantage of that style of coding, whereas Tcl never had the assumption that everything had to be async, so many calls block. Same thing with Python and Ruby, except that they're relative latecomers to the embedded "select loop" game (sure, modern systems have moved on from select, but it still conveys the idea).
Erlang has been around for a while, and does async beautifully, but for every person who knows Erlang there are 10,000 who know Javascript.
Re: If you're using Node.js, you're doing life wrong
#98Re: If you're using Node.js, you're doing life wrong
#99> JavaScript has very little support for any of those nice things: it doesn't even have namespaces, for chrissakes. Why would I want to repeat these same mistakes over and over again in a new language? Javascript doesn't have this (by itself) but node has a very nice require() system that is really excellent for long-term maintainability. When you bump a dependency in a node project that change will only affect the c…
Re: If you're using Node.js, you're doing life wrong
#100Okay, let's play a little game. I'm going to describe a scenario (using Python; feel free to substitute the equivalent Ruby terms if that makes it more relevant for you). You're a pretty good Python developer. You know, and feel comfortable with, not just Python, but the entire ecosystem. Virtualenv, pip, the whole nine yards. And now you're working on a really nifty Django app, maybe a CRM or something, when you rea…
If you've already finished your project, I'm not going to try to convince you to move away from Node, but if you've got a lot to do still, you might consider sticking with Python. I'm not saying that Node isn't a workable solution on the server side, I just don't think it's proven that it is the way that Python and other, more mature platforms have. I don't give too much credence to inflammatory posts like the one being discussed, but when I see posts like: http://news.ycombinator.com/item?id=2519674 from a developer I respect, it gives me pause. That post is 18 months old now, so the situation could have changed.
There's something to be said for building things you know are rock solid and won't result in 2am notifications. That's my perspective, so I try to stay away from the bleeding edge. For stuff that's not critical, I'm more ok with taking a few risks. But someone's got to be the one that takes those risks in a mission-critical environment to figure out which of the new technologies will become proven and which will fail, so I disagree that these people are doing life wrong. If it wasn't for people like them, my way of doing life right wouldn't work.