RSSAmplifier

Blog

Pascal's Scribbles

Recent content on Pascal's Scribbles

deterministic.spaceRSS feed ↗62 posts

Latest posts

Readleif

This post introduces Readleif, a read-later and listen-later app for iOS and macOS that I built this summer. The main ideas: No account, no subscription, no server, a library to browse rather than an inbox to clear, and when listening, content blocks that don’t read well aloud get a summary on the fly. I’ve started on a first version, but it’s at best beta quality right now. And…

Using Rust typestates for BCF writing

If you’ve ever needed to produce a typed binary format where the header constrains what the body can contain, you’ve probably written validation code that runs at runtime and hoped your tests cover the edge cases. With Rust, you can turn this into compile errors (my favorite!) using typestates and phantom types. These patterns generalize well beyond any single format. I’ve…

Niches for integer types in Rust

While working on seqair (see my post here ), I also wrote a bunch of wrapper types for the domain we work in. One example is Base (a DNA base), which is a fairly straightforward enum. Another is Pos , a position in a DNA sequence, which I’d like to talk about here. The value range for a position is effectively u31 . We only support the positions that the BAM file format supports, which store…

Seqair, my Rust-native take on htslib

This post introduces seqair , a new Rust library for bioinformatics formats I’ve been working on. We’ll look in detail at one of my main design choices here, a columnar store for iterating BAM data, and talk about how I tried to create nice Rust APIs. Rastair , the project I’ve been working on, reads and writes a lot of file formats. SAM/BAM/CRAM input, VCF/BCF output, reference…

Still blogging

I published three posts on this blog just in April. Before that, I’ve published 3 posts since May 2020. Going back to freelance work and having an interesting bioinformatics project made me want to write again, and it feels good. But this blog had to feel a bit nicer first! This site has been around since 2016 1 , and it was always just Markdown files in a git repo. Let’s update the…

Random Forest ML on GPU

In my recent post on Rastair , we looked at some performance best-practices and optimizations for Rastair , a bioinformatics tool that I’m currently working on. One of the slowest parts of the tool is running machine-learning inference on a Random Forest model. In this post, I want to describe what we use ML for, and how we moved inference to a GPU compute shader to make it fast. Context…

Using CSS vars to style SVG symbols

Styling SVG symbols that are defined using <symbol id="x"> and included using <use href="#x"> . SVG symbol sprites In a web frontend project I&rsquo;m working on, we need to show a lot of icons in different configurations on a drawing. The symbols are SVGs exported from Figma and they have different layers that can be styled and enabled depending on the symbol&rsquo;s status. E.g., we want to set…

Notes on Rastair, a variant and methylation caller

In the last year, I&rsquo;ve had the pleasure to work on Rastair , a bioinformatics project by Benjamin Schuster-Böckler from the Ludwig Institute for Cancer Research at the University of Oxford. It is a command-line application written in Rust that has excellent performance and a rich feature set. As of now in April 2026, we just released versions 2.0 and 2.1, so I wanted to take some time to…

Rust BufWriter and LZ4 Compression

Recently, I&rsquo;ve been working on a Rust project again. It deals with bioinformatics data, which can be quite large, so I got to play with profiling and optimizing the code. I&rsquo;ve done some of this in past, but this time it was actually useful. In this post, I want to talk about a small optimization in working with LZ4 compression that made a big difference in runtime performance. This…

The Rust features that make Bevy’s systems work

Bevy is a game engine written in Rust that is known for featuring a very ergonomic entity-component-system. In the ECS pattern entities are unique things (e.g. objects in a game world) that are made up of components . Systems process these entities and control the behavior of the application. What makes Bevy’s API so elegant is that users can write regular functions in Rust, and Bevy will know how…

How Bevy uses Rust traits for labeling

Out of curiosity I&rsquo;ve recently started following the development of Bevy , a game engine written in Rust . Today I want to talk about how Bevy uses Rust traits to let users very conveniently label elements. Note: The implementation we arrive at is actually very generic &ndash; you can easily apply it to any other Rust project. How to bevy Bevy really wants you to use its…

Long-form Texts on Interesting Details of Computers

It seems especially recently I’ve come across more and more long-form texts (think: hour-long blog posts; free books; series of posts). I especially like the ones that go into the very fine details of some niche topic and maybe also ramble a bit about completely unrelated but highly entertaining asides. And while I will probably never have enough time to read them all, I decided to at least…

Cheap tricks for high-performance Rust

So you&rsquo;re writing Rust but it&rsquo;s not fast enough? Even though you&rsquo;re using cargo build --release ? Here&rsquo;s some small things you can do to increase the runtime speed of a Rust project – practically without changing any code! Please remember that the following suggestions do not replace actual profiling and optimizations! I also think it goes without saying that the only way…

Return-type based dispatch

One surprising feature of type inference in languages like Rust is defining functions with generic return types. The idea is that by specifying at some later point in the code which type you want your function to return, the compiler can go back and fill in the blanks. For example, let&rsquo;s have a look at this function: fn new < T : Default > () -> T { T :: default () } You pick the output It…

Notes on proper systemd services

Despite my best efforts, I end up logging into Linux servers and checking how they&rsquo;re doing way too often. In recent projects I&rsquo;ve also been responsible for adding way too many .service files and making sure they work. All of that was based on a vague understanding of how systemd works, without ever really looking into the finer details and the constant feeling that there are a lot of…

How to order Rust code

Note: This post is about how I arrange the code I write in Rust. If you wanted to &ldquo;order&rdquo; Rust code in the &ldquo;hire someone to write code&rdquo; sense, you should still keep on reading as this is excellent material for a job interview. (Not the opinion I present but having an opinion on the topic.) Arrange code to be in the suggested reading order I try to order the…

Rust 2019

The Rust project is asking for blog posts about what the community would like to see happen with Rust in 2019. I originally wanted to write this post before Christmas, but instead I took some time off to meditate on what exactly I wanted to write (mostly by laying in bed, sick). In the meantime, a lot of people have written their Rust 2019 posts. For example, I really liked fitzgen&rsquo;s post ,…

Serve archived static files over HTTP

Say you want to store a huge number of very small files that you will only access over HTTP. For example: You are using rustdoc to render the documentation of a library. Without much work you&rsquo;ll end up with about 100k HTML files that are about 10kB each. As it turns out, this number of small files is very annoying for any kind of file system performance. Best case: making copies/backups is…

The Secret Life of Cows

A lot of people at RustFest Paris mentioned Cows &ndash; which may be surprising if you&rsquo;ve never seen std::borrow::Cow ! Cow in this context stands for &ldquo;Clone on Write&rdquo; and is a type that allows you to reuse data if it is not modified. Somehow, these bovine super powers of Rust&rsquo;s standard library appear to be a well-kept secret even though they are not new . This post will…

quicli - The ideas behind my small Rust CLI framework

I recently wrote a new Rust crate: quicli . As the name might suggest, it gives you a way of quickly writing CLI programs in Rust. This post is about the ideas and underlying philosophies behind this project. Note: If you found this because you were looking for quicli itself, have a look at quicli&rsquo;s Getting Started guide ! Some history I&rsquo;ve been writing CLI tools in Rust for a while…

Rust 2018

Instead of fireflowers , this year the Rust Team made a public call for blogposts , asking the community to write posts that reflect on Rust in 2017 and what they wish for Rust in 2018. What follows are some of the things I personally see as important, and that I&rsquo;d love to prioritize on in the following months. As another Pascal wrote, if I had more time, I&rsquo;d have written a shorter…

Passing Functions as Parameters in Ruby

As someone who likes writing code in a functional style, I really enjoy passing functions as arguments. Whether in Rust or in JavaScript, first-class functions are very useful. Sadly, as naming a function/method in Ruby is the same as calling it with zero parameters, this at first seems impossible to do. What you can do is pass closures blocks methods. E.g., Array#map really likes being called…

Conferences 2018

I&rsquo;ll be at various conferences throughout the year 2018. If you want to hang out before/at/after, let me know! These are conferences I have on my list so far: Date Name Location Attending? Feb 3 FOSDEM Brüssel Speaker Mar 3 .concat() Salzburg Maybe Apr 21 JsUnconf Hamburg Maybe Spring RustFest Paris Yes Jun 2 JSConf EU Berlin Nope Jul 19 ScotlandJS Edinburgh CFP: Mar 1

Learning Programming Concepts by Jumping in at the Deep End

There are many different ways to learn something; one that I enjoy from time to time is what I&rsquo;d call the &ldquo;jump in at the deep end&rdquo;: Look at the solution to a problem and study each of its details until you understand all the concepts. This is in contrast to a tutorial-style learning where you learn one thing after another and gradually build more complex things. I like the…

5 Tips for Writing Small CLI Tools in Rust

Rust is a great language to write small command line tools in. While it gives you some tools for common tasks, allows nice abstractions, it also has a type system and approach to API design that lead you to write robust code. Let me show you some techniques to make this a nice experience. Update (Jan 2018): I published a crate (Rust library) that contains a lot of what this post describes: quicli…

Diesel.rs Trick: Treat View as Table

Diesel is a type-safe query builder for Rust. Its goal is to give you an idiomatic interface for interacting with your database so it&rsquo;s easy to write highly performant and correct queries. But SQL is quite a complex beast, and sadly, this also makes Diesel an inherently complex tool. On the implementation side, one of the most complex parts of Diesel is the association handling. We take…

Conferences 2017

I&rsquo;ll be at various conferences throughout the year 2017. If you want to hang out before/at/after, let me know! Bobkonf – Berlin February 24, I&rsquo;ll be in town Th—Mo ClojureD – Berlin February 25, I&rsquo;ll be in town Th—Mo RustFest – Kyiv April 30, I&rsquo;ll be in town Fr–Mo I gave a talk there and you can watch the recording ! NightlyBuild – Cologne September 1, I&rsquo;ll be in town…

How to implement a trait for &str and &[&str]

Rust has a pretty powerful type system, but some things are not that easy to express. Follow me on a journey where we try to implement a bit of method overloading by using traits with funny constraints and discover some interesting ways to convince Rust that everything is fine. tl;dr &ldquo;Man this is some type system abuse if I I&rsquo;ve ever seen it. I absolutely love it! It&rsquo;ll be useful…

Rust Concurrency Libraries

A short overview. I/O Model data flow with futures Let tokio &rsquo;s event loop handle non-blocking I/O Use libraries built on tokio that implement the protocols you need Parallel processing Use rayon to make your iterators use all CPU cores Use crossbeam &rsquo;s scoped threads to manually execute things in parallel Data structures Use crossbeam &rsquo;s data lock-free data structures if you…

A way to customize Rust error messages

Rust&rsquo;s error messages are pretty amazing. There is no way to format library-specific errors, though. I&rsquo;m suggesting a way to implement this on stable Rust. Precursor If you have never seen one of the error messages Rust gives you, here are some (in real life, they are even in color): error[E0507]: cannot move out of indexed content --> tests/migration_generate.rs:42:21 | 42 | let…

Idea: cargo-giftwrap - giving the gift awesome Rust libraries

Here are some things in Rust&rsquo;s ecosystem that I really like: The awesome people Well documented libraries by awesome people Automation to help awesome people focus on awesome stuff I would like to add something to that. My thoughts so far Good practices for crates Elegant APIs in Rust Doc string style Writing guides with doc tests cargo-giftwrap My idea is this: A new cargo giftwrap 1…

Programming Wisdom

[The] length of a variable name should be proportional to its scope. I come across this from time to time. This quote is by stirner in this HackerNews thread . Make illegal states unrepresentable This is what type systems are for: Statically preventing things from being wrong. I first saw this in this &ldquo;F# for fun and profit&rdquo; post of the same title. You should read it if you…

Teaching libraries through good documentation

How do you teach people how to use a complex framework or library 1 ? Here&rsquo;s what comes to mind: Tutorials (guides), API documentation, great error messages, or forums/chats. Maybe video tutorials, and books, too. Since guides are one of the most effective ways to get people started, I&rsquo;ve been musing about them for a while. Guides Recently, Sergio Benitez released the Rocket web…

Programming cross-pollination with Rust and Ruby

I hear a lot of people new to Rust are Ruby programmers. I&rsquo;m kinda the opposite. While I&rsquo;ve been semi-involved with Ruby (mostly Rails) projects from time to time since at least 2011, I&rsquo;ve never been that much into Ruby the language. Rust, on the other handy, I&rsquo;ve been loving since 2014. Now, I&rsquo;ve been writing Ruby for a new Rails project for the last 6 month and want…

Pascal vs. USB-C

Update: Got the laptop, and some adapters. Updated the post below with concrete tests and benchmarks where appropriate. I&rsquo;m gonna buy a 15″ MacBook with 4 Thunderbolt 3 Ports because (a) I need new laptop, (b) I want to continue to use macOS (without hassle), and (c) I really like the premise of USB-C with alternate modes and Thunderbolt 3 with 40Gb/s. Sadly, that means that I&rsquo;ll need…

No biggie Markdown slideshows

Some time ago I forked biggie , a small tool to generate a slideshow from markdown. It&rsquo;s called &ldquo;biggie&rdquo; because the slides&rsquo; text is shown as big as the screen allows. Now, let&rsquo;s make it even easier to generate slideshows from arbitrary Markdown sources! Idea Go to killercup.github.io/no-biggie Enter URL to Gist or Github file Get biggie-style slideshow Tech notes…

Trait Driven Development in Rust

Actually, the title is a lie: We are just focusing on traits here, but writing Rust can also easily be Test Driven, or Data Driven, or Documentation Driven, or [A-Z][a-z]* Driven. As with almost any language, Rust contains a lot of concepts that can be mixed and which you can focus on. I think traits are the most interesting and most powerful 1 . Instead of doing things the usual OOP way and…

Zero-cost abstractions in web frontend dev

One of the most amazing features of compilers is their ability to not just transform code into machine-readable things but also to optimize away abstractions . Languages like C++ and Rust advertise something called &ldquo;zero-cost abstractions&rdquo;: In general, C++ implementations obey the zero-overhead principle: What you don’t use, you don’t pay for […]. And further: What you do use, you…

Rust IDE Features Wishlist

Some ideas for editor/IDE features to make working on Rust code more pleasant. Reading code Go to definition Show where a function is used Show documentation Show type on hover Writing code Show errors/warnings inline (including those from external lints like clippy ) Autocomplete (stand-alone tool: racer ) Automatic code formatting (using rustfmt ) Insert the usual boilerplate code for impl s…

I <3 plain text files

I really enjoy working with plain text files. More software should work with plain text files. It obviously depends on what kind/amount of information you want to store, but I think for a lot of use cases text files are a very good solution. Version control everything Text files can easily be put into a git repository to be versioned, compared, tracked, and shared. I have not seen a database…

Research paper organization

I have a directory full of research papers I have read or want to read. They are all named [last name of primary author][year][first word in title].{pdf,bib} (there is a PDF and BibTeX file for each publication). This works quite well, as this is the same naming schema that Google Scholar uses in their BibTeX citations. I want to expand this, though. Some time ago I starting writing a simple GUI…

README-driven Development

Like most other (\w)DD techniques 1 , &ldquo;README-driven Development&rdquo; wants to guide your approach to software development. This approach works best for small, self-contained projects or libraries, whose API surface is no larger than what fits on a bunch of post-it notes. And of course for projects that you might not want to write right now but just thought about in the shower that seemed…

Machine Readable Inline Markdown Code Documentation

In Rust RFC 1713 , a set of documentation &rsquo;tags&rsquo; is proposed, to document functions in a similar fashion to e.g. JavaDoc or JSDoc. I recently saw that Swift uses plain Markdown for documentation. Xcode is able to parse this and show contextual information based on it. Since Rust&rsquo;s current documentation conventions already wants you to use common names for Markdown headlines to…

Rust's ownership and borrowing in 150 words

Recently, I wrote on reddit that a Rust book won&rsquo;t become obsolete in the next years if it focused on explaining concepts instead of current APIs. At basically the same time, I tried to explain some of Rust&rsquo;s concepts to a friend. I think I came up with a quite concise description (maybe even explanation) of &ldquo;ownership and borrowing&rdquo; (the concept that differentiates Rust…

Rich diffs of rendered HTML

Have you ever seen the way Github allows you to see rendered diffs for code they can render as HTML? Like this &ldquo;rich&rdquo; diff , as they call it? For some reason I wanted something similar (probably for Silicon Zucchini ), but couldn&rsquo;t find a good library that did that nicely. Now I have a nice idea how to implement this. &ldquo;Virtual DOM&rdquo; is a nice abstraction of how to…

A sane admin panel for Silicon Zucchini

When I first wrote about Silicon Zucchini (the code name for my statically-typed CMS, see also this note ), I mentioned that the JSON schema files that are used to validate the content data could also be used to generate an editor interface. I&rsquo;ve been thinking about this some more. What&rsquo;s the admin interface Currently, I think three views are enough for a good admin interface for…

Hidden treasures of the Rust ecosystem

The secret life of std You can call "text".parse::<T>() on all types T that impl std::str::FromStr for T You can .collect() into a Result<T, E> where T: FromIterator Formatting syntax (as in format!("{:#?}", vec!["lorem"]) ) is really powerful (it includes compile-time left pad!), you should read the fmt docs . Wonders of Rust documentation The Little Book of Rust Macros by Daniel Keep Rust Design…

Compile-time website checking

I want a static site generator that enforces a bunch of rules at compile-time so whole classes of errors cannot occur. Similar to my ideas from last year . Compile-time checks All templates define their input data structures (e.g. as JSON schema) Optional fields can only be accessed in an if clause or with explicit defaults, else the compilation will panic (like (implicitly?) calling Rust&rsquo;s…

Virtual DOM for CLI and libui

Among other things , I want to easily write UIs in Rust. (What I describe below could also be done in any other language though.) Virtual DOM Dealing with a virtual DOM (instead of directly manipulating the real DOM) was popularized by React.js . Advantages are: Developer declares what UI components should be shown, renderer determines good way to update your UI (clever diffing) Works nicely with…

Elegant Library APIs in Rust

The existence of libraries with nice, user-friendly interfaces is one of the most important factors when choosing a programming language. Here are some tips on how to write libraries with nice APIs in Rust. (Many of the points also apply to other languages.) You can also watch my talk at Rustfest 2017 about this! Update 2017-04-27: Since writing that post, @brson of the Rust Libs Team has…