update ch01-02-hello-world.md

pull/238/head
xiaohulu 7 years ago
parent fb8d949117
commit 5b071b936b

@ -99,7 +99,7 @@ fn main() {
println!("Hello, world!");
```
这行代码完成这个简单程序的所有工作:在屏幕上打印文本。这里有四个重要的细节需要注意。首先 Rust 的缩进风格 使用 4 个空格,而不是 1 个制表符tab
这行代码完成这个简单程序的所有工作:在屏幕上打印文本。这里有四个重要的细节需要注意。首先 Rust 的缩进风格使用 4 个空格,而不是 1 个制表符tab
第二,`println!` 调用了一个 Rust 宏macro。如果是调用函数则应输入 `println`(没有`!`)。我们将在附录 D 中详细讨论宏。现在你只需记住,当看到符号 `!` 的时候,就意味着调用的是宏而不是普通函数。
@ -143,15 +143,6 @@ $ ./main # or .\main.exe on Windows
如果 *main.rs* 是上文所述的 Hello, world! 程序,它将会在终端上打印 `Hello, world!`
If youre 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* 文件,他们需要先分别安装 RubyPythonJavaScript 实现运行时环境VM。不过在这些语言中只需要一句命令就可以编译和运行程序。这一切都是语言设计上的权衡取舍。
仅仅使用 `rustc` 编译简单程序是没问题的,不过随着项目的增长,你可能需要管理你项目的方方面面,并让代码易于分享。接下来,我们要介绍一个叫做 Cargo 的工具,它会帮助你编写真实世界中的 Rust 程序。

Loading…
Cancel
Save