TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

If you're using Node.js, you're doing life wrong

139 点作者 fogus超过 13 年前

41 条评论

irahul超过 13 年前
<i>The Ruby and Python communities are just now, many years after the hype has faded, learning that stuff like dependency injection and proper modularization are actually good things that help you maintain code over time.</i><p>This remark is off the mark. Dependency injection, as in <i>injection by parameters</i> and <i>injection by constructors</i> are so obvious people do it sub-consciously. A fluff word isn't needed for it. As far as <i>IoC containers</i> are concerned, I don't see Ruby/Python communities using it, mainly because half of it is fighting static typing.<p>And people are learning proper modularization now? Seriously? Python/Ruby has proper namespaces(ruby doesn't have it), modules, classes et al. Like any other languages, Python/Ruby has it's share of programmers who write spaghetti code, and programmers who don't.<p>Again, if he writes AbstractConnectionDepenencyInjectioManagerAbstractFactory and calls it proper modularization, I am happy Python/Ruby isn't picking it up.
评论 #3547975 未加载
评论 #3548006 未加载
评论 #3548280 未加载
评论 #3548401 未加载
karterk超过 13 年前
Ok, as someone who has been actually building apps on Node for about 1 year AND working with a largish Scala codebase for the last six months:<p>&#62; Not to mention the fact that its balls-ass slower than some straight un-optimized Scala.<p>I don't see the point of comparison here. Slower/faster is meaningless without the context. Apples to Oranges. And, Scala has it's own issues. Yeah, the JVM's performance is there, but bringing your team onto a Scala codebase is not easy either.<p>&#62; It provides the least amount of aid and comfort to the programmer and its nigh-on-impossible to follow the code 6 months later.<p>Anyone who has developed more than a Hello World in Node will know that the problem of callback sphaghetti can be circumvented using events, promises and async libraries. Yes, until the language itself offers an async construct, this will be an issue, but frankly there are ways to get around it.<p>&#62; JavaScript has very little support for any of those nice things: it doesn't even have namespaces, for chrissakes.<p>Client side JS has no module system. But Node.js has. At this point, I really wonder if the OP has actually worked at all with Node.<p>&#62; It seems to me that people who are really crazy about Node.js are people who only knew JavaScript to begin with and to whom none of the above would ever even occur.<p>Another baseless claim. I urge you to go see the GitHub profiles of Node core committers. Seriously.
评论 #3547913 未加载
jim-greer超过 13 年前
If you get really angry about the choices other people make for their own work, you're doing life wrong.
评论 #3547845 未加载
评论 #3548246 未加载
评论 #3547743 未加载
评论 #3547822 未加载
andrewvc超过 13 年前
I'm really pretty anti-node, but this article isn't very good. The concerns here are mixed up and not very thorough. All these points need graphs, charts, something solid to anchor them to. This is the sort of article that polarizes, but doesn't add to the discussion.<p>It starts off strong talking about a high bug count, but never gets into specifics there.<p>As far as scaling across cores goes, it's disingenuous to suggest that node can't do this, there are a number of options here. Message passing, for instance, does indeed work.<p>As far as nested callbacks sucking, I totally agree. But a walk through why would add a lot more substance here as well.
评论 #3548214 未加载
评论 #3548007 未加载
substack超过 13 年前
&#62; 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?<p>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 code near it because of how node_modules are resolved to the most local copy. You can bump dependencies without worrying how this will affect other packages.<p>Plus, require() just returns an object. It doesn't puke a bunch of objects into the current scope. This is massively useful for readability. I've sunk a lot of time on other systems tracking down unqualified exports to figure out which package's documentation to consult.<p>I've got nothing against scala and am sure it's a useful language but I wonder if the author has even used node.
评论 #3559862 未加载
davidw超过 13 年前
I don't really have a dog in this fight, but I see node.js as being "disruptive":<p>* It's "not as good" as languages/environments like Erlang.<p>* 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.
评论 #3547803 未加载
评论 #3547925 未加载
didip超过 13 年前
Everybody is angry if bugs keep punching them in the face. I get that. But this post needs more info to be informative:<p>* If I read correctly, OP is using Chrome/V8 directly. I don't see if the bug list is on V8 itself or his bindings?<p>* "Callback Spaghetti". To each his/her own. I happened to read callbacks easier than other solutions. And this is coming from Python programmer, not JS programmer.<p>* The last 2 points are also information-less rants. What happened to HN?
jessedhillon超过 13 年前
Here's my problem and why I don't care to use it:<p>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 this happened?<p>It's a community built around someone else's tool, and Google develops it for entirely different reasons. Case in point, someone posted IcedCoffee, which adds an "await" keyword to CoffeeScript -- you have to implement a compiled language on top of Javascript to have the language features you need!<p>Finally, to preempt questions about my being concerned about other people's language choices -- other people are choosing, inexpertly in my opinion, the technologies with with I will contend in the future. Future employers may value and demand experience in node, and future employees may have to be disabused of bad habits accumulated during the learning of it.
评论 #3548048 未加载
评论 #3549829 未加载
antrover超过 13 年前
It's posts like this that make me embarrassed to be a programmer. The author basically states, "Node.js is not a good fit for my company, therefor everyone using node.js is wasting their time." It's generalizations like this that just blow my mind.<p>I don't go around saying, "Snickers is the worst candybar, therefor anyone who eats a Snickers is wasting their time."<p>I bet the author is not a pleasant person to work with.
virmundi超过 13 年前
I 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.<p>I like node for system level scripting. I find bash annoying and non portable to windows. I really don't want to have to learn batch scripting for dos on windows. But I can use JavaScript with node to script in both environments.<p>On the server I think that node might be helpful for certain network level tasks. But I haven't used it for much. But honestly what type of person would I be if I don't even consider it? The OP seems to be making an emotional decision rather than a technical one. Interestingly he's using Scala. There are many similar posts about Scala being the wrong way to do life. I just can't agree with any of those views.<p>Finally I wonder what the value is for these rage posts. They just seem to further divide people. I do see the value in the posts about I've used node for X months, here's my thoughts or here's why I'm going back to X paradigm. But just a rant where faces should be punched seems out of place for HN.
评论 #3548996 未加载
hello_moto超过 13 年前
Article like this needs to be sliced-n-diced in different ways:<p>1) If you don't know technology X and use it due to hype, you deserve to get burned<p>Let that be a lesson for anybody.<p>2) There's no silver bullet<p>Choosing node.js over web-framework just because you want the front-end and the back-end to use the same code-base is to trade one feature for another: Ruby and Rails still have better tools than Node.js while you get JS all over the place (assuming you're good with JS).<p>3) Complaining about the language is a sign that you have no clue<p>I used to think that Java is better than some of the hype dynamic languages out there but I was wrong: Java is better for ME because I _KNOW_ Java Better. If I know Ruby more than I know Java then Ruby is better than Java FOR ME.<p>4) Don't program using another language's idioms<p>This is documented left and right already. If you use technology X, find best-practices for technology X. Don't just apply best-practices from technology Y.<p><a href="http://dirtsimple.org/2004/12/python-is-not-java.html" rel="nofollow">http://dirtsimple.org/2004/12/python-is-not-java.html</a><p>Or some of the comments here about Dependency Injection (which is quite common in Java but not so in Python/Ruby).<p>In the past, I had one instructor that noticed that my QBasic code looked like Fortran. He asked me if I knew Fortran beforehand and I told him that I've taken Fortran before this class.<p>People see and notice.
jconley超过 13 年前
Node enforces a programming model that puts you down the path to extreme vertical scalability, you know, actually using all the hardware you are paying for. CPUs and the kernels that manage them are good at running code. They suck at waiting for things to happen.<p>Out of the box the callback model can be difficult to wrap your head around. But if you are serious about writing a vertically scalable IO-bound service, it is currently the only option. There are some add-ons to make the code less ugly, but you still have to have the mental model down.<p>It's a lot like multi-threaded programming, or functional programming. It's a matter being able to visualize the flow and pass context around. This takes time to change the way you think.<p>If you approach problems in Node like you'd approach a problem in a functional language the spaghetti of callbacks becomes much less of a burden.<p>For the async haters out there operating at scale. How many of you have farms of machines with idle CPU's, maxed out memory, and practically idle network interfaces? Yeah, I thought so.
tingletech超过 13 年前
Node is not for every use case,<p>This tech talk on node is pretty interesting<p><a href="http://sna-projects.com/blog/2011/08/nodejs/" rel="nofollow">http://sna-projects.com/blog/2011/08/nodejs/</a><p>I watched it last weekend, and from what I understood/remember from the talk the reason the node people picked javascript was not because they liked javascript. It was because they wanted to do async programming, and they found other languages had too much synchronous baggage. In javascript, node.js could start from a clean slate and build a pure async culture and environment.
brianshumate超过 13 年前
The problem I see with all these kinds of negative posts concerning Node.js is that they essentially boil down to "this is so radically different and uncomfortable to me that it cannot possibly be good for anyone else." and do not provide any concrete business examples of why it should be avoided.<p>Until I see an actual example of how "Node.js crashed my business, cost us N dollars, and here's exactly how...", I will continue to look at such posts as developers complaining about having to learn to do things a new way — something that has been going on since there were developers.
robinduckett超过 13 年前
I have to agree with the rest of the commenters here. You make a blanket statement about something you've obviously never used. You're leveraging hearsay and third party complaints against a framework and language that you don't appear to be overly familiar with.
hamidpalo超过 13 年前
The spaghetti code of node.js callbacks is really a problem of Javascript lacking monads, and in this case something like the Async monad from F#.<p>TameJS is a step in the right direction by adding a C#-style await.
jdelsman超过 13 年前
His comment about node.js only being able to use a single core is bullshit, and has been for a while:<p>* Before native support: <a href="https://github.com/learnboost/cluster" rel="nofollow">https://github.com/learnboost/cluster</a><p>* Now, native: <a href="http://nodejs.org/docs/latest/api/cluster.html" rel="nofollow">http://nodejs.org/docs/latest/api/cluster.html</a>
bunderbunder超过 13 年前
I've got my doubts about Node.js, since it seems like rather a one-trick pony.<p>But it is a good trick. Node.js deserves credit for calling attention to an underappreciated design pattern that has a lot to offer in certain circumstances. (Personally I think the .NET team hit the nail more squarely on the head with TPL, a pony that can do that trick as well as many others. But .NET doesn't have the sex appeal it takes to be a spokesmodel so meh.)<p>Javascript isn't my favorite language, or the most performant one. But as a "Lisp with C syntax", on a semantic level it's much better suited to the higher-order programming techniques that the pattern requires than most other popular Web languages are. Ruby also has the right features, but it isn't exactly the poster child for high-performance computing either. Might as well flip a coin, because either way opinionated folks with blood pressure conditions will call you an idiot.
crazygringo超过 13 年前
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.<p>But the callback spaghetti problem can be largely solved by dropping in, for example, the IcedCoffeeScript fork:<p><a href="http://maxtaco.github.com/coffee-script/" rel="nofollow">http://maxtaco.github.com/coffee-script/</a><p>Or the previous JavaScript TAME functionality:<p><a href="http://tamejs.org/" rel="nofollow">http://tamejs.org/</a><p>There are of course many other async helper solutions as well, and if you're doing serious Node development, it's kind of insane not to use one of these.
评论 #3548148 未加载
libria超过 13 年前
I haven't used node.js before, but I see 2 main points being made about it, by proponents and detractors respectively:<p>* It uses non-blocking evented IO so it can scale well.<p>* It is single threaded so it can't scale well.<p>Someone teach me: which of these statements is true?
评论 #3547818 未加载
评论 #3547844 未加载
评论 #3547843 未加载
评论 #3547864 未加载
评论 #3548595 未加载
bryanh超过 13 年前
Nonsense. Perhaps your choice to use Node.js is suboptimal? That isn't an indication of Node.js's quality, it's an indication of your inability to choose the right tech. People choose tools that make it easier to do something, Node.js accomplishes that for a wide range of tasks.<p>I just spun up a IM API we needed in an <i>evening</i> thanks to Node.js and community contributed packages. It's humming along great, I even wrote up a piece about it: <a href="http://news.ycombinator.com/item?id=3547664" rel="nofollow">http://news.ycombinator.com/item?id=3547664</a>
sktrdie超过 13 年前
It seems to me like the author overly cares about languages, when the power of Node is the community and its simplicity of use - there's very little boilerplate even for complex things like network programming.<p>Who cares about the language. Use JS if you want, or use Scala. At the end of the day is the maintainability of the product you're developing that matters.<p>I feel, for example, that NPM is much easier and simpler to use than something like Maven. If it makes my life easier, I'll stick with it.
chrismealy超过 13 年前
"The Ruby and Python communities are just now, many years after the hype has faded, learning that stuff like dependency injection and proper modularization are actually good things"<p>WTF?!
Kilimanjaro超过 13 年前
Node solves a problem I don't have in a so convoluted way that if I ever have that kind of problem I won't be using node for sure.<p>Is there a need for webstackers to go play at the server side? YES! but node is not THE solution, it is just ONE solution. I venture to say, as javascript evolves more towards a coffeescript flavor, then a coffeescript flavor on the server is what is needed.<p>And I'll support something along these lines.
mustardamus超过 13 年前
If you're using [your fav framework], you're doing life right.<p>Just use it and see if it works out for you.
lightblade超过 13 年前
All the points that OP mentioned, whether they are correct or not, are irrelavent.<p>The only factor that drives technology success is the people, aka the community. There are a lot of people on board of nodejs. This just creates more gravity and pulls more people toward it. Together, the community will carry the momentum that drives its success. If v8 is not server technology like OP said, there are enough open source developers to make its on fork.
steele超过 13 年前
Never take life advice from someone who responds to hype with a compulsion to "punch faces" while donning "rageface". To be fair though, I bet this is just a casual blog entry that the guy didn't know would hit HN.<p><a href="http://meyerweb.com/bkkt/okaythen.gif" rel="nofollow">http://meyerweb.com/bkkt/okaythen.gif</a>
gumbo超过 13 年前
Please give me a break. This guy made some points: spaghetti code, .... He state it in the wrong way, however one should admit that node.js is not mature enougth for many use cases. I'm still learning but, haven't seen how just by using node.js you get a scalable server.
rdouble超过 13 年前
I recently evaluated Node and Scala for a presence server for an iOS app. With my naive understanding of both platforms, it was way easier to do this with Node. It would be interesting to hear more detail about how Scala was used and why it was better.
IsaacSchlueter超过 13 年前
This is hilarious.
Lazare超过 13 年前
Okay, 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).<p>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 realize...<p>...damn. This app really needs a lot of functionality ripped out and shoved in the browser. I'm losing my marbles writing spaghetti jQuery code, but what I really need is some client side templates.<p>So you poke at it, and think about it, and you realize that the proper design of your app is <i>really</i> a bunch of client-side code using Backbone, and a server that just handles authentication and is otherwise a thin RESTful wrapper around your database.<p>Great! But at this point, most of the actual code you will be writing is Javascript. Your server could be written in, practically, anything. And there's some compelling reasons to leave it in Python. On the other hand, if you switch to node.js it means all your code is in the same language (which is nice). It also opens the door to being able to use the <i>same</i> code on both the client and the server - which is really good. Client-side templates are nice, but being able to render them on the server when you need to is practically a requirement. And Python's support for rendering Javascript templates is very limited. And if you're a Python coder, you'll probably want to be writing your client in CoffeeScript anyhow, which requires having node.js installed, so, at least for development, just have the whole damn stack in node.js. You can always hack together a little RESTful server in Python later if you decide that node.js isn't right for production.<p>Seems simple enough, right? And as you can probably guess, I just went through this process. And so now we have this blogpost, which is saying...well, it's not really clear what it's saying. That I should be using Scala, I guess. This is, frankly, so wrong it's embarrassing.<p>1) Even if the JVM was just so amazing and awesome, I'm not a JVM developer. The ecosystem is radically different. As a Python developer, I'm able to install, configure, and be productive with node.js very quickly. npm, nvm, coffeescript, and we're away. My IDE of choice (PyCharm) even supports CoffeeScript. There is very low impedence. Switching to Scala...where would I even <i>begin</i>?<p>2) I'm doing this because I need to write a client side app. That must be written in Javascript, or something that compiles to Javascript. Scala is neither. And while there are JVM language that <i>do</i>, there are some major concerns with their suitability, maturity, and tooling. Clojurescript looks great, but it's not something you pick because you think coffeescript is too new and little used!<p>3) The rant would be more compelling if the author came across as someone who actually knew anything about Python, Javascript, or node.js. Contrary to his assertions: Javascript does have namespaces. Python and Python developers have ALWAYS been convinced that modularity is good. And Python developers are still quite aware that dependency injection is a way to solve problems with the design of Java which aren't even relevant to their language of choice.<p>4) Also, if you don't grok callbacks, it doesn't <i>mean</i> you are a bad programmer. But it might be worth keeping in mind that there are plenty of programmers who do, and they're going to laugh at you when you reveal you don't. Not to mention that there are plenty of ways of programming in node.js WITHOUT callback spaghetti, and revealing that you have no clue about the framework your slagging is not going to improve your credibility.<p>5) To continue the theme, insulting a framework for not scaling well may work better if you don't reveal that you don't know how it scales in the same paragraph.
评论 #3564395 未加载
评论 #3549343 未加载
eliaskg超过 13 年前
What's the problem if someone creates great stuff with it?
alexchamberlain超过 13 年前
Glad to see someone has been brave enough to come out against this. I too don't like Node; JavaScript was never designed to take on this sort of load.
EhevuTov超过 13 年前
Certain tools are used for certain jobs. Node.js is a different tool and I welcome it. I don't curse a hammer because it is not a screwdriver.
skrebbel超过 13 年前
I love articles like this. All the dry analyses, the subtle counter-counter-arguments, that the usual tech opinion articles on HN have make me nuts.<p>The little layer of emotion and drama added here gets the point across much better, IMHO. Of course it doesn't do anything but preaching to the choir (hi there), and not convincing anyone not already in the choir, but it's a great read! (and so is this thread).<p>In other news, if you're voluntarily using a dynamically typed language and an editor without an integrated debugger, you're not fit for programming!
nathanwdavis超过 13 年前
Wow, this guy seems like a very angry person.
mnot超过 13 年前
Wow, seriously? This is just as bad as the fanboy "you'll use X for EVERYTHING!" posts. Please.
dhconnelly超过 13 年前
different tools for different jobs
aiscott超过 13 年前
From the article: "The hype around Node.js on this issue makes me want to punch faces."<p>"But the kind of misunderstanding going on in this video clip seems to pervade the Node.js hype and gives me rageface."<p>This seems like a really over-the-top response to people that have a differing opinion. I can't take the rest of his post seriously after reading these parts. This certainly isn't the sort of thing you read in an informed opinion piece.
评论 #3548402 未加载
funkah超过 13 年前
Node seems unnecessarily complicated and faddish, but if you really want to mire yourself in callback soup then go ahead. I'll just be over here, not tearing my hear out.
indutny超过 13 年前
You're just using it wrong