Hello world in Rust

I’m tinkering with Rust. Here’s how I started.

Rust has a classic “pipe curl to shell” installer: curl https://sh.rustup.rs -sSf | sh. The installer works out what platform I’m on. It downloads some stuff and puts it in /Users/jim/.cargo. “Cargo” is Rust’s package manager. It added export PATH="$HOME/.cargo/bin:$PATH" to my ~/.bash_profile, so now I have access to some binaries there, including cargo (the package manager), rustup (a Rust version manager, so you don’t have to run that curl-to-shell installer every time) and rustc, the Rust compiler.

To test rustc, I created hello.rs:

fn main() {
    println!("Hello World!");
$ rustc hello.rs
$ ./hello
Hello World!

We can compare this file to the equivalent in C:

#include <stdio.h>
int main() {
  printf("Hello world!\n");
  return 0;

The Rust binary has an overhead of around 420K. I don’t know what’s in there!

Both binaries depend on /usr/lib/libSystem.B.dylib, the macOS system library. This provides, amongst other things, the C standard library. The Rust binary has one other dependency, /usr/lib/libresolv.9.dylib. This provides a DNS client, includable in C with resolv.h, linkable in C with -lresolv, and documented in man 3 resolver. It’s not clear why the Rust binary depends on this.

I just released Vidrio, a free app for macOS and Windows to make your screen-sharing awesomely holographic. Vidrio shows your webcam video on your screen, just like a mirror. Then you just share or record your screen with Zoom, QuickTime, or any other app. Vidrio makes your presentations effortlessly engaging, showing your gestures, gazes, and expressions. #1 on Product Hunt. Available for macOS and Windows.

With Vidrio

With generic competitor

More by Jim

Tagged . All content copyright James Fisher 2017. This post is not associated with my employer. Found an error? Edit this page.