Quick bytes - using UDP in Rust

This is the first post where I’m doing “quick bytes” of simple examples with Rust. This is both a way for me to keep track of some basic usage of various Rust-isms, but also a way for me to share that in case it’s helpful. I could just leave these as notes in my Obsidian vault, but why not share! UDP The User Datagram Protocol (UDP) is the lesser known sibling of the Transmission Control Protocol (TCP). The simple difference is TCP is guaranteed and UDP is not. What I mean is, UDP is like “fire and forget” and TCP has a whole retry mechanism. There are of course other differences, but that’s what I see as key to understand. UDP is also used for “multicast” where a packet is broadcast to multiple recipients. ...

April 1, 2025 · 3 min · Ray Suliteanu

Using Java's New Gatherer Interface

As a preview in JDK 23 and about to be final in the upcoming JDK 24, Java has added a capability to its Stream API to create new collectors using a new interface called Gatherer. Java has had a Collector API for a while now, but the Gatherer interface addresses some limitations, including the issue that there was no way to tell a Collector that processing was complete. If there were still some data the Collector was processing, this data was lost. You will see an example of this later. ...

March 1, 2025 · 8 min · Ray Suliteanu

Learning Git Internals with Rust - Part 6

In this blog I continue my journey with Rust and Git, focusing on creating the last two object types in Git — the tree and the commit. As you may recall from previous post in this series, a tree object represents a single level of a directory tree, with the file’s name, permissions and object hash. A commit object is what most people are familiar with, and it contains references (via object hashes) to a tree for files in the commit, a reference to the parent commit if any (e.g. the very first commit in a repo has no parent), the name of the author and committer (which are allowed to be different) and finally the commit message. If you sign your commit, this ends up as text in the comment. ...

October 7, 2024 · 8 min · Ray Suliteanu

Learning Git Internals with Rust - Part 5

In this latest blog on Git internals with Rust, I will focus on the ls-tree command in Git. You can find the earlier posts here: Part 1 — git init Part 2 — git hash-object Part 3 — refactoring Part 4 — git cat-file The ls-tree command is similar to doing an ls in a terminal emulator. It lists the contents of tree objects in Git. The Git object model looks like this (copied from Part 2) ...

October 6, 2024 · 14 min · Ray Suliteanu

Learning Git Internals with Rust - Part 4

In this post we’ll cover the Git cat-file command. Previous posts in this series are Part 1 — git init Part 2 — git hash-object Part 3 — refactoring The Git cat-file command let’s you dump the contents of a Git object. You cannot view Git object files directly since they are compressed as well as having headers, as we saw in the second post on hash-object. The cat-file command is essentially the inverse of the hash-object command. ...

August 25, 2024 · 8 min · Ray Suliteanu

Learning Git Internals with Rust - Part 3

In this post we continue our journey with Rust and Git. If you haven’t read the previous posts, you can find them here Part 1 — git init Part 2 — git hash-object At the end of Part 2 I said the next blog would be on cat-file. Sorry for the bait and switch, but I wanted to do this refactoring, so I snuck this in. We’ll definitely get to cat-file next time. While this post is mostly standalone, there are aspects of the prior posts that will probably help to understand this post better. ...

August 20, 2024 · 4 min · Ray Suliteanu

Learning Git Internals with Rust - Part 2

This post continues from where I left off in the first post that covered creating a new empty repository. You can read it here. To briefly summarize the goal of this series of posts, I am on a journey to learn Rust and for me the best way is doing “real” stuff. In this case I’m looking at the internals of Git, by implementing some of the many commands available. After the first post I am able to create a new repository. Let’s start to look at what Git stores and how it does so. As we saw in the first post, after git init we have a directory .git/objects. Content is stored in files under that base objects directory by using a SHA-1 hash of the contents being stored. Git provides a command git hash-object which allows generating the hash based on content, and optionally writing that file to .git/objects. However, that doesn’t mean that git hash-object is just a fancy wrapper around sha1sum or similar tools. ...

July 30, 2024 · 6 min · Ray Suliteanu

Learning Git Internals with Rust

Have you ever wondered how Git does what it does? What happens when you do a commit? You can read about some of this in the Git Book free online, like in Chapter 10 on Git Internals. But it doesn’t give you all the details, as I discovered. And I wanted another interesting “project” to help me on my continuing journey learning Rust. So why not poke around under the Git hood? ...

July 26, 2024 · 13 min · Ray Suliteanu

Text Parsing in Rust with Nom

As soon as you want to do anything non-trivial with respect to parsing text using Rust (or any language) you should use some kind of parser… Text parsing in Rust with Nom As soon as you want to do anything non-trivial with respect to parsing text using Rust (or any language) you should use some kind of parser implementation. Writing a working parser for anything but the most trivial content is non-trivial. Unless you want to learn parsers (perhaps you’re taking a compiler course), better to use an existing tool/framework. ...

July 11, 2024 · 8 min · Ray Suliteanu

Using thread locals in Rust

As I continue my journey learning Rust, I thought I’d share some learning related to multithreading and thread locals. I came across an interesting new site called CodeCrafters. The site is another learning site supporting multiple programming languages, but they focus on specific “challenges” with specific tasks to accomplish for each challenge. I’ve worked through a few of them, and I used threads and thread locals on the HTTP server challenge. ...

June 14, 2024 · 4 min · Ray Suliteanu