javascript 服务器端javascript框架
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11487539/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Server-Side javascript framework
提问by Sandman4
I'm looking to replace PHP with something better (everybody seems to say that PHP is evil, right ?), and considering server-side JavaScript.
我希望用更好的东西替换 PHP(似乎每个人都说 PHP 是邪恶的,对吧?),并考虑使用服务器端 JavaScript。
node.js seems very popular, but I'm afraid I'll go crazy with asynhronous stuff. Is it possible to write normal (synchronous) code under node ?
node.js 似乎很受欢迎,但恐怕我会对异步的东西发疯。是否可以在 node 下编写普通(同步)代码?
My whishlist: web and command-line scripting, good performance (on the The Computer Language
Benchmarks Game , V8 seems to be an order of magnitude faster than PHP), preferably developed by some company or community so that it will not be just abandoned someday, user community with a decent modules library.
我的愿望清单:web 和命令行脚本,良好的性能(在计算机语言
基准游戏中 ,V8 似乎比 PHP 快一个数量级),最好由某些公司或社区开发,以免有一天被放弃, 用户社区有一个不错的模块库。
I don't consider various frameworks based on Rhino, as Rhino runs in Java, and I'm not into Java, aware of it's memory footprint, and the whole idea of compiling javascript to java makes no sense to me.
我不考虑基于 Rhino 的各种框架,因为 Rhino 在 Java 中运行,而且我不喜欢 Java,意识到它的内存占用,并且将 javascript 编译为 java 的整个想法对我来说毫无意义。
Spent some time googling, and found numerous projects: Myna, Meteor, GromJS, APE, GLUEscript, v8cgi, silkjs, wakanda, GPSEE, sorrowjs, ejscript, Persevere, PhantomJS.
花了一些时间google,发现了很多项目:Myna、Meteor、GromJS、APE、GLUEscript、v8cgi、silkjs、wakanda、GPSEE、sorgejs、ejscript、Persevere、PhantomJS。
Does somebody have any experience with those ? Any recommendation are welcome.
有人有这些经验吗?欢迎任何建议。
回答by Split Your Infinity
Well Node.JS is the way to go if you ask me. You can write synchronous code, BUT only do that in command line scripts. When writing a web servers you have to go the async route otherwise it will not perform because JavaScript is single threadedand everything comes to a halt.
好吧,如果你问我,Node.JS 是要走的路。您可以编写同步代码,但只能在命令行脚本中这样做。在编写 Web 服务器时,您必须走异步路线,否则它将无法执行,因为JavaScript 是单线程的,一切都会停止。
The reason Node.js is so fast is because of asynchronous IO.
Node.js 如此之快的原因是因为异步 IO。
You will get used to callbacks and eventing and after a while you don't want to go back.
你会习惯回调和事件,过了一段时间你就不想回去了。
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
Node.js 是一个基于 Chrome 的 JavaScript 运行时构建的平台,用于轻松构建快速、可扩展的网络应用程序。Node.js 使用事件驱动的非阻塞 I/O 模型,使其轻量级和高效,非常适合跨分布式设备运行的数据密集型实时应用程序。
回答by Dan Dascalescu
Meteor. Built on top of Node.js and growing veryfast.
In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.
在 Meteor 中,您的服务器代码在每个请求的单个线程中运行,而不是 Node.js 典型的异步回调风格。我们发现线性执行模型更适合 Meteor 应用程序中的典型服务器代码。
UPDATEOne year later - Why Meteor
UPDATE一年后-为什么流星
回答by bill1
Have you looked at Comparison of server side JavaScript solutions?
您是否看过服务器端 JavaScript 解决方案的比较?
Node.jsis popular. As for php speed, have you looked at HipHop? Rewriting your code in javascript probably won't give much of a performance boost over php.
Node.js很受欢迎。至于php速度,你看HipHop了吗?用 javascript 重写你的代码可能不会比 php 有太多的性能提升。
回答by jamjam
Nodejs is very good option on many fronts.
Nodejs 在许多方面都是非常好的选择。
But you say you are concerned about its a async nature.
但是您说您担心它的异步性质。
Two points on this.
关于这一点有两点。
you never need to worry about async and can continue to write you application from top bottom like PHP. That's if you are not performing "blocking IO".
If you are performing "blocking IO" like reading a database or accessing the file-system than you will need to deal with async. Luckly there are good ways to do this without the need to change you coding practices too much.
您永远不需要担心异步问题,并且可以像 PHP 一样从上到下继续编写应用程序。那是如果您没有执行“阻塞 IO”。
如果您正在执行“阻塞 IO”,例如读取数据库或访问文件系统,那么您将需要处理异步。幸运的是,有一些很好的方法可以做到这一点,而无需过多地改变您的编码实践。
回答by Andreas Stankewitz
Thanks for providing the list of "numerous projects" you found. We are currently using Microsoft ASP 3.0 ("Classic ASP", coming with IIS) that provides a server-side JavaScript implementation since 1996 - it's fast, mature and due to the COM technology quite extensible. If you are not fixed to open source, it's worth a look. For our open source strategy, we will have a closer look at SilkJS.
感谢您提供您找到的“众多项目”列表。我们目前正在使用 Microsoft ASP 3.0(“Classic ASP”,随 IIS 一起提供),它自 1996 年以来提供了服务器端 JavaScript 实现——它快速、成熟并且由于 COM 技术非常可扩展。如果你不固定开源,那么值得一看。对于我们的开源策略,我们将仔细研究 SilkJS。