Danes-Vault/3-99 Research/Rust/Chapter 1 - Introduction.md

29 lines
839 B
Markdown

# First things first
Chapter 1 takes you through an introduction to rustc -- an older version of compiling and running rust that predates Cargo. The first thing I did was create a 'Hello, world!' program.
I also learned that when naming files, the convention is underscores:
**Good**:
hello_world.rs
**Bad**:
helloworld.rs
# What does a Rust program look like?
Here was our full hello world program:
```rust
fn main() {
println!("Hello, world!");
}
```
First, there's the fn main() function. This is always the first piece of code that will run in a Rust program.
Second, indents always happen with 4 spaces, not a tab.
Third, the print statement is doing something a little different. It is a *macro*, not a function. Macros use ! at the end, while functions do not.
Fourth, each line ends with a semicolon. Much like C.