Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes every weekday Monday through Friday.
This page was generated by The HPR Robot at


hpr3453 :: Rust 101: Episode 1 - Hello, World!

In which BlacKernel introduces the cargo tool and goes into detail on the rust hello world program

<< First, < Previous, , Latest >>

Hosted by BlacKernel on Wednesday, 2021-10-27 is flagged as Explicit and is released under a CC-BY-SA license.
rust, programming, hello world, macros, functions. (Be the first).
The show is available on the Internet Archive at: https://archive.org/details/hpr3453

Listen in ogg, spx, or mp3 format. Play now:

Duration: 00:22:28

Programming 101.

A series focusing on concepts and the basics of programming

Talking Points

  • main.rs
    • Like main.cpp in C++ or main.c in C
    • Tells the compiler which file to start with
    • Can link to other "crates" and "modules"
  • Cargo.toml
    • Keeps track of application metadata
    • This includes dependencies!
  • Functions
    • Strictly typed, like everything in Rust
    • Declared by fn
    • Argument typed with argument: Type
    • Return typed with -> Type otherwise assumed to return nothing
  • The Main Function
    • Like the main functions in C and C++
    • Where the program starts within the main.rs file
    • CLI arguments handled by std::env, rather than argv and argc in C
    • Can return nothing or a Result<()>
  • Macros
    • Metafunctions or functions for functions
    • More general than functions, having flexibility in the number of arguments, etc, but harder to write
  • The println! Macro
    • Can take any number of arguments that implement the display trait
    • Usually things like strings or character literals
    • Will format them into a string and display it on the terminal
    • Similar to printf in C
  • The Hello World program
    • Can be automagically generated with cargo new and then the name of your application
    • Located in Name-Of-Application/src/main.rs

fn main() {
  println!("Hello, world!");
}


Show Notes

Important Links:

Wikipedia Articles:


Contact Me

Comments

Subscribe to the comments RSS feed.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Title:
Comment:
Anti Spam Question: What does the letter P in HPR stand for?
Are you a spammer?
Who is the host of this show?
What does HPR mean to you?