Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.

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.
Tags: rust, programming, hello world, macros, functions.

Listen in ogg, spx, or mp3 format. | Comments (0)

Part of the series: Programming 101

A series focusing on concepts and the basics of programming

Talking Points

    • 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 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/

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

Show Notes

Important Links:

Wikipedia Articles:

Contact Me

Show Transcript

Automatically generated using whisper

whisper --model tiny --language en hpr3453.wav

<< First, < Previous, Latest >>


Subscribe to the comments RSS feed.

<< First, < Previous, Latest >>

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:
Anti Spam Question: What does the P in HPR stand for ?
Are you a spammer →
Who hosted this show →
What does HPR mean to you ?