55. Hello Rust!.
All coding languages and frameworks that I have used have been mainly to make web apps or mobile apps. I have never really played around with a low-level language. Rust seems like the perfect opportunity. It is trending a lot these days. I had always known that there is a language called 'Rust' but I got to know that it is trending when I saw a reel about it on instagram. I will start on my rust journey by referring the book: The Rust Programming Language.
Today I learnt:
- Rust is a low-level language. It is mainly used for systems related things.
- We will download Rust through rustup (a command line tool for managing Rust versions and associated tools).
- You will also need a linker, which is a program that Rust uses to join its compiled outputs into one file. C compiler acts as a linker.
- A rust file is a .rs file.
- Hello world looks like this:
fn main() {
println!("Hello, world!");
}
- Then you have to compile the file with the following command
rustc file-name.rs
then an executable will be generated of the same name../file-name
will run the executable. Compiling and running are separate steps. - The main function is special: it’s the first code that is run for every executable Rust program.
- println! is a rust macro. If it were calling a function instead, it would look like this: println (without the !). When you see a ! that means that you’re calling a macro instead of a normal function.
- The line ends with a semicolon (;).
That's all for the day! Next time we will learn about Cargo!