Fork me on GitHub

Project Notes

Hello World in Rust

So the simplest “hello world” in rust is very C-like:

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

and runs as expected:

$ rustc hello_world.rs
$ ./hello_world
Hello, world!

But that doesn’t show off much that’s special.

Concurrent Programming

So we could get a bit clever and use the std::thread library to create a concurrent hello world.

Believe it or not, this example actually comes from the Rust wikipedia page, with modifications.

$ rustc concurrent_hello_world.rs
$ ./concurrent_hello_world
Hello from thread number 0
Hello from thread number 1
Hello from thread number 2
Hello from thread number 3
Hello from thread number 4
Hello from thread number 5
Hello from thread number 6
Hello from thread number 7
Hello from thread number 8
Hello from thread number 9
Goodbye from thread number 1
Goodbye from thread number 5
Goodbye from thread number 0
Goodbye from thread number 4
Goodbye from thread number 3
Goodbye from thread number 6
Goodbye from thread number 2
Goodbye from thread number 7
Goodbye from thread number 8
Goodbye from thread number 9

Credits and References

About LCK#13 Rust
Project Source on GitHub Return to the Project Catalog

This page is a web-friendly rendering of my project notes shared in the LittleCodingKata GitHub repository.

LittleCodingKata is my collection of programming exercises, research and code toys broadly spanning things that relate to programming and software development (languages, frameworks and tools).

These range from the trivial to the complex and serious. Many are inspired by existing work and I'll note credits and references where applicable. The focus is quite scattered, as I variously work on things new and important in the moment, or go back to revisit things from the past.

This is primarily a personal collection for my own edification and learning, but anyone who stumbles by is welcome to borrow, steal or reference the work here. And if you spot errors or issues I'd really appreciate some feedback - create an issue, send me an email or even send a pull-request.