是否可以使用 JavaScript 编写后端?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11652026/
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
Is it possible to write the backend using JavaScript?
提问by DNB5brims
As we all know, JavaScript is widespread on the web. For client side scripting it does a great job.
众所周知,JavaScript 在网络上很普遍。对于客户端脚本,它做得很好。
But is it possible to take JavaScript outside the browser? For example, writing a streaming socket or writing DB, doing schedule job? Things like that in the backend? Thanks.
但是有可能将 JavaScript 带出浏览器吗?例如,写一个流式套接字或写数据库,做调度工作?后台有这样的事情吗?谢谢。
回答by Matt Gibson
Have a look at node.js. It does a certain number of things very well, but may not be best suited for all purposes.
看看node.js。它在某些方面做得很好,但可能并不适合所有用途。
If you are looking to do stuff that involves a lot of parallell processes and/or you want to keep persistent connections open to and from a user's browser, then it may be perfect.
如果您希望做涉及大量并行进程的事情和/或您希望保持与用户浏览器之间的持久连接打开,那么它可能是完美的。
回答by Cleric
Yes, you can do a lot of backend things in Javascript.
是的,你可以在 Javascript 中做很多后端的事情。
There is a lot of frameworks and application that runs Javascript as a backend, all with different pros and cons.
有很多框架和应用程序将 Javascript 作为后端运行,但各有优缺点。
NodeJs
NodeJs
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 模型,使其轻量级和高效,非常适合跨分布式设备运行的数据密集型实时应用程序。
OPA
OPA
Opa is an advanced application framework for JavaScript. All aspects are directly written in Opa: Frontend code, backend code, database queries and configuration. And everything is strongly statically typed.
Opa 是 JavaScript 的高级应用程序框架。所有方面都直接用Opa 编写:前端代码、后端代码、数据库查询和配置。一切都是强静态类型的。
CommonJs
CommonJs
The CommonJS API will fill that gap by defining APIs that handle many common application needs, ultimately providing a standard library as rich as those of Python, Ruby and Java. The intention is that an application developer will be able to write an application using the CommonJS APIs and then run that application across different JavaScript interpreters and host environments.
CommonJS API 将通过定义处理许多常见应用程序需求的 API 来填补这一空白,最终提供一个与 Python、Ruby 和 Java 一样丰富的标准库。目的是让应用程序开发人员能够使用 CommonJS API 编写应用程序,然后在不同的 JavaScript 解释器和主机环境中运行该应用程序。
Vertx.io
Vertx.io
Vert.x is the framework for the next generation of asynchronous, effortlessly scalable, concurrent applications. Vert.x is an event driven application framework that runs on the JVM - a run-time with real concurrency and unrivalled performance. Vert.x then exposes the API in Ruby, Java, Groovy, JavaScript and Python. So you choose what language you want to use. Scala and Clojure support is on the roadmap too.
Vert.x 是下一代异步、可轻松扩展、并发应用程序的框架。Vert.x 是一个在 JVM 上运行的事件驱动的应用程序框架 - 一个具有真正并发性和无与伦比性能的运行时。Vert.x 然后在 Ruby、Java、Groovy、JavaScript 和 Python 中公开 API。因此,您可以选择要使用的语言。Scala 和 Clojure 支持也在路线图上。
回答by Kris Zhang
回答by Michael Aston
Yes, you can utilize JavaScript outside the browser. Both for server-side scripting (similar to JSP or ASP). This can most notably be accomplished using Node.js (http://www.commonjs.org/) however there are other options available. Similarly you can create aps entirely outside of the webspace using the CommonJS API (http://www.commonjs.org/).
是的,您可以在浏览器之外使用 JavaScript。两者都用于服务器端脚本(类似于 JSP 或 ASP)。这可以通过使用 Node.js ( http://www.commonjs.org/)来完成,但是还有其他选项可用。同样,您可以使用 CommonJS API ( http://www.commonjs.org/)完全在网络空间之外创建 aps 。
Check out the Wikipedia article about JavaScript (http://en.wikipedia.org/wiki/JavaScript#Server-side_JavaScript).
查看关于 JavaScript 的维基百科文章 (http://en.wikipedia.org/wiki/JavaScript#Server-side_JavaScript)。
回答by Nuno_147
Never used it , but for server-side JS the most populate framework is nodejs http://nodejs.org
从未使用过它,但对于服务器端 JS,最流行的框架是 nodejs http://nodejs.org