http://rubylearning.com/blog/2012/04/23/ruby-in-2012/ What is your opinion on Node.js? Is this the future? Do you think Node.js will beat Ruby in web application development?
Matt Aimonetti: This is a question I often get. I personally like node.js, I think it’s fun, easy to get started and with CoffeeScript, writing JavaScript (JS) is almost fun. That said, Node is really young, not very well documented and relies extremely heavily on callbacks which can be quite confusing at times. My experience with Node is limited, but as my personal project started growing, I started struggling to keep my code simple and easy to maintain. Because I already know Ruby quite well and because equivalent tools exist in Ruby land, I don’t see a real need to use Node besides being the new cool framework.
But the project is fast growing, the cross-platform focus is welcomed and I think that for some developers, Node.js can be a great solution, especially when developing simple web APIs.
Will it “beat” Ruby? Well, a framework and a programming language are two different things. Will it beat Rails in popularity, that’s a possibility due to the fact that JavaScript is becoming very popular. However, some of the issues I mentioned earlier might prevent Node.js to become as popular as some people seem to believe. Finally, at the end of the day, if a JS framework becomes a better solution than anything else I use, I will certainly switch. But so far, I don’t see that happening.
callback 调用太深,无论开发,debug 还是测试,都会欲仙欲死的............以前写 python 就是一边吐一边 twisted...直到 eventlet 的出现........
我要说句公道话: Node.js 性能比 Rails 强。但是,你整个 stack 跑起来以后,view, DB, controller,然后再用什么 expressjs 去搞搞。性能又强不了多少了。
而且大家要注意的是:
Node.js 是强在用来开发实时 web application 的。那个可以说跟 Rails 完全不搭噶的。跟 Ruby 的 EventMachine 搭噶的。EventMachine 性能绝对比 Node.js 快。一倍不敢说,但是快一点。EM 比 Node 最大的差别是 Node 的社区旺啊。所以插件支持多。
其实性能 还是 golang 好,内存消耗真少,全公司项目可以跑在一个服务器上,跑测试的时间不能上厕所了。 @sunfmin 可以作证。 但是 golang 的支持能跟 Rails 的社区比么,也没有最近火爆的 Node 社区比。所以暂时风头盖不上其他两个。有时候,性能不是一切,只是额外的获得而已,因为你什么都没做。
@hooopo 你做任何事情都不能脱离整个 stack, 短板效应。今天数据库有问题明天网络有问题。 我上次做过一个实验。 前端 Nginx, 可以处理 20000 + r/s, 后端跑了 4 个 EventMachine, 4 核的机器,每个能处理 1w+ r/s,猜猜结果如何。6000r/s, 操作系统在分配资源上很多东西都消耗了性能。所以语言在快,还得考虑整个 stack 能否配合你上去。架构啊架构啊。架构师吃牛排是有理由的啊
Node.js is just a server with some server side commonjs support. It itself is not a all included framework as rails is.
个人感觉 node.js 在 web 上的优势还是在于两点:
目前这个方向的 node 应用框架有不少:比如 http://meteor.com http://derbyjs.com
而作为传统的 web 框架来使用就没有太大优势了,express 本身比 sinatra 就快不了多少,并且底层库 js 还是远不如 ruby 支持的好
服务器端可以为不支持 js 的浏览器和搜索引擎渲染出静态内容 這是甚麼意思?跟據 request header 中的 agent 發頁面嗎。實際意義不大,不如真接作 web 和移動兩個 view。而且 Node.js 是基於 gecko 的並不能自動解決跨流覽器的這兼容問題。
It's like that old joke about learning Chinese: it can't be that hard, even two year old Chinese kids speak it …