DEV Community

Nivethan
Nivethan

Posted on • Originally published at nivethan.dev

4 1

Programming Rust - 01

The book has come in! Programming Rust by Jim Blandy, Jason Orendorff and Leonora F.S. Tindall. Let's see how much I get through. No promises, it could just be the first page :)

The first step was installing rustup and I'm going to use my WSL2 Ubuntu. The only pain here was adding $HOME/.cargo/bin to my fish config file to get access to the rust commands. I wonder if there's a way to automate this where the rustup script checks which shell you're running and it will inject it in. There probably is a good reason for why it doesn't do that but does for bash. Once I got rust install, I created a new cargo project and everything looks to be compiling.

Time to open the book!

Interesting definition of systems programming as resource constrained programming. This is maybe why I want to learn rust, in my day job memory, cpu and storage is all basically infinite.

The opening of the chapter goes into undefined behavior and corrupting the call stack. Also mentions that struxnet used a bug in the true type parser in word processors to do its job. That's pretty cool. Safety and concurrency! Let's see where it takes me.

Something I learned in the first section was that return is reserved for early returns and that the idiomatic way of returning in rust is to simply have the expression at the end without a semicolon.

I can also write #[test] on top of a function and then run those functions with cargo test. That's pretty useful to know and definitely would have helped in other projects.

I really like the gcd example as it goes over many ideas like looping, throwing errors, references and dereferencing. I'm still on the first 10 pages! I'm going to have to start reading faster and only implement the parts that I care about to speed this up.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay