|
|
@ -143,15 +143,6 @@ $ ./main # or .\main.exe on Windows
|
|
|
|
|
|
|
|
|
|
|
|
如果 *main.rs* 是上文所述的 Hello, world! 程序,它将会在终端上打印 `Hello, world!`。
|
|
|
|
如果 *main.rs* 是上文所述的 Hello, world! 程序,它将会在终端上打印 `Hello, world!`。
|
|
|
|
|
|
|
|
|
|
|
|
If you’re more familiar with a dynamic language, such as Ruby, Python, or
|
|
|
|
|
|
|
|
JavaScript, you might not be used to compiling and running a program as
|
|
|
|
|
|
|
|
separate steps. Rust is an *ahead-of-time compiled* language, meaning you can
|
|
|
|
|
|
|
|
compile a program and give the executable to someone else, and they can run it
|
|
|
|
|
|
|
|
even without having Rust installed. If you give someone a *.rb*, *.py*, or
|
|
|
|
|
|
|
|
*.js* file, they need to have a Ruby, Python, or JavaScript implementation
|
|
|
|
|
|
|
|
installed (respectively). But in those languages, you only need one command to
|
|
|
|
|
|
|
|
compile and run your program. Everything is a trade-off in language design.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
如果你更熟悉动态语言,如 Ruby、Python 或 JavaScript,则可能不习惯将编译和运行分为两个单独的步骤。Rust 是一种 **预编译静态类型**(*ahead-of-time compiled*)语言,这意味着你可以编译程序,并将可执行文件送给其他人,他们甚至不需要安装 Rust 就可以运行。如果你给他人一个 *.rb*、*.py* 或 *.js* 文件,他们需要先分别安装 Ruby,Python,JavaScript 实现(运行时环境,VM)。不过在这些语言中,只需要一句命令就可以编译和运行程序。这一切都是语言设计上的权衡取舍。
|
|
|
|
如果你更熟悉动态语言,如 Ruby、Python 或 JavaScript,则可能不习惯将编译和运行分为两个单独的步骤。Rust 是一种 **预编译静态类型**(*ahead-of-time compiled*)语言,这意味着你可以编译程序,并将可执行文件送给其他人,他们甚至不需要安装 Rust 就可以运行。如果你给他人一个 *.rb*、*.py* 或 *.js* 文件,他们需要先分别安装 Ruby,Python,JavaScript 实现(运行时环境,VM)。不过在这些语言中,只需要一句命令就可以编译和运行程序。这一切都是语言设计上的权衡取舍。
|
|
|
|
|
|
|
|
|
|
|
|
仅仅使用 `rustc` 编译简单程序是没问题的,不过随着项目的增长,你可能需要管理你项目的方方面面,并让代码易于分享。接下来,我们要介绍一个叫做 Cargo 的工具,它会帮助你编写真实世界中的 Rust 程序。
|
|
|
|
仅仅使用 `rustc` 编译简单程序是没问题的,不过随着项目的增长,你可能需要管理你项目的方方面面,并让代码易于分享。接下来,我们要介绍一个叫做 Cargo 的工具,它会帮助你编写真实世界中的 Rust 程序。
|
|
|
|