运行时环境的作用是什么?
从根本上来说,什么是运行时环境,它的作用/目的是什么?
另外,你能给我一些与网络相关的例子吗? (XAMPP 是其中之一吗?)
In basic terms, what is a runtime environment, and what is it's role/purpose?
Also, could you give me any web related examples? (Is XAMPP one?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
运行时环境可以由几部分组成。
http://en.wikipedia.org/wiki/Run-time_system 谈论一些代码在“您编写的程序”实际执行之前运行。
它们具有不同程度的复杂性。 Windows 上的 C 运行时将执行一些操作,例如为控制台应用程序创建进程和线程、获取并准备任何环境变量等并调用 int main(argc, argv) 函数。然而,Java 和 .NET 运行时系统的作用远不止这些:它们实例化虚拟机、内存管理环境。它们有许多线程,其中一个将在某个时刻运行您的代码。
在Java中,运行时环境可以通过java.lang类型对象(例如Thread)进行交互。在 Windows 或 Linux 上的 C 语言中,可以使用外部库来完成此操作。因此,运行时环境可能在某些情况下提供功能,但在其他情况下则不提供功能。
裸机嵌入式系统可能是极少数没有运行时环境的软件系统之一。这是在知道没有操作系统、调度程序、进程或线程的概念、DOS 提示符、内存管理器等任何东西的情况下编写 C 代码的地方。然而,通常会有一些样板 C 代码在 main() 入口点执行之前立即链接并运行。这可能是用汇编程序编写的,并初始化一个堆栈。
对于 XAMPP,这并不是真正的运行时环境,因为它只是一组服务器包。您编写的任何代码要么是 PHP、Perl,要么是 MySQL 数据库中的代码。 PHP 和 Perl 可以说有自己的脚本代码运行的运行时环境。但不,我想说 XAMPP 不是一个运行时环境。
ASP.NET 和 Java Server Pages(或者现在的任何名称 - 曾经在 Glassfish 中的服务器端 Java 东西 - Java EE,就是这样!)为您编写的代码提供运行时环境。
Runtime environment can consist of several things.
http://en.wikipedia.org/wiki/Run-time_system talks about some code that runs before the "program that you wrote" actually gets executed.
They come in various levels of complexity. The C runtime on Windows will do things like create a Process and a Thread for a console app, grab and prepare any environment variables etc and call the int main(argc, argv) function. However, Java and .NET runtime systems do a lot more: they instantiate virtual machine, memory managed environments. These have many threads, one of which will be running your code at some point.
In Java, the runtime environment can be interacted with via the java.lang type objects, like Thread. In C on Windows or Linux, one uses external libraries to do this. So runtime environments may provide functionality in some cases, but not in others.
Probably one of the very few software systems that do not have a runtime environment is the bare-to-the-metal embedded systems exmaple. This is where C code is written knowing that there is NO operating system, scheduler, concept of a Process or Thread, DOS prompt, memory manager, anything. There is however usually some boilerplate C code that is linked in and run immediately before the main() entry point is executed. This is probably written in assembler, and initialises a Stack.
Re XAMPP, this is not really a runtime environment, because it is merely a set of server packages. Any code you write is either in PHP, Perl, or code inside the MySQL db. PHP and Perl arguably have runtime environments of their own in which the script code runs. But no, XAMPP i'd say is not a runtime environment.
ASP.NET and Java Server Pages (or whatever it's called nowadays - the server-side Java stuff which used to be in Glassfish - Java EE that's it!) provide runtime environments to code that you write.
RichColours 的答案在技术上是正确的。然而,在实践中,人们也将运行时环境称为运行应用程序所需的所有第三方软件。
如果您正在开发 Web 应用程序,这还包括使您的应用程序运行所需的 Web 服务器或数据库。运行时本身是编程语言(PHP、Java、Python 和 Ruby),但如果您想运行应用程序,您需要一个完整的环境,其中可能包括 Apache、Passenger、Tomcat、MySQL、PostgreSQL 等。通常还有 OpenSSL 等附加库、curl、libxml 可能是必需的。例如,我是 BitNami 的开发人员,我们提供用于开发和部署 Web 应用程序的完整环境(类似于 XAMP,如你提到)。大多数时候,我们称它们为“堆栈”,但我们的用户(很多时候我们自己)也称它们为运行时环境。
The answer from RichColours is technically correct. However, in practice people also refer to a runtime environment as all the third party software you need for running your application.
If you are developing an web application this will also include the web server or database that is required for make your application work. The runtimes themselves are the programming languages (PHP, Java, Python and Ruby), but if you want to run your application you need a full environment that may include Apache, Passenger, Tomcat, MySQL, PostgreSQL, etc. Usually additional libraries as OpenSSL, curl, libxml, may be required. For instance I am a developer at BitNami, and we offer full environments for developing and deploying web applications (similar to XAMP, as you mention). Most of the time we call them "stacks" but our users ( and many times ourselves) also call them runtime environments.