Skip to content

Aloso's Blog

Effects in Rust (and Koka)

What is an effect system? According to Wikipedia, it is a formal system that describes the computational effects of computer programs, such as side effects. It is also an extension of a type system, and allows you to statically verify that your program is sound with regard to effects.

If you want to fully understand this concept, I recommend you to learn Koka. It is a beautiful language with a powerful, yet easy to understand effect system. This blog post includes Koka snippets, but they should be easy to understand without prior knowledge.

We don't need revenge

Mob justice is when a person suspected to be a criminal is beaten by a group of people or crowd with clubs, stones, machetes, or anything they can lay their hands on — Wikipedia

Is this what the Rust community wants?

If you don’t know what I mean, I’m talking about this Reddit thread, which asks for courage and accountability from the Rust project leadership. That sounds reasonable, who doesn’t want the leaders to be accountable? The problem is in how they want to achieve it: By asking Rust project members to “name and shame” the people who messed up. But what happens then?

A zero-overhead linked list in Rust

Let’s implement an immutable, singly-linked list. Singly-linked means that each node contains a reference to the next node, but not vice versa. To make this data structure really performant, let’s use plain references instead of heap-allocated types. This would be dangerous in memory-unsafe languages like C, because it could easily cause vulnerabilities because of dangling pointers, but Rust’s lifetimes protect us from this. We’ll see what this means in a moment.

Rusts Module System Explained

The Rust programming language can be confusing for beginners, and the module system is one part that causes frustration particularly often. There are quite a few blog posts out there trying to explain the module system in a simple way, but I often have the feeling that they over-simplify things. So here’s my take—a more detailed explanation of the module system.

This post assumes that you can write at least a “hello world” Rust program. It’s a rather long read, so get comfortable, maybe with a cup of tea, hot chocolate, or whatever your heart desires 😊

Implementing RAII guards in Rust

As you probably know, Rust doesn’t have automatic garbage collection. Instead, it relies on destructors to clean up memory, and these destructor calls are automatically inserted in the appropriate places at compile time. And since Rust uses traits for everything, destructors use a trait as well: The Drop trait.

This has the benefit that Drop can be implemented to do anything, not just cleaning up memory: It can also release a file descriptor, close a network socket, cancel an in-flight HTTP request, and much more. Whenever you acquire some sort of resource, and want to release it when you’re done with it, the Drop trait is your friend.

Rust's Universes

This post describes a curious feature of Rust: Namespaces, also called universes. Note that Rust’s namespaces are nothing like namespaces in languages such as TypeScript or C#; they are also unrelated to all of space and time, although there are certainly parallels.

Creating an Iterator in Rust

When I woke up today, I thought, what a great day to start a blog! So here we are. Before we take off, just a short introduction: I’m Ludwig, I’m a CS student from Germany, and I love Rust. Since this blog is about Rust, I hope you do too!

This post is about a core concept in Rust, iterators. If you don’t know what iterators are, please read the chapter about iterators in the Rust book first.