220 results for "":
Aiming for correctness with types
The Nature weekly journal of science was first published in 1869. And after one and a half century, it has finally completed one cycle of carcinization, by publishing an article about the Rust programming language.
It’s a really good article.
What I liked about this article is that it didn’t just talk about performance, or even just memory safety - it also talked about correctness.
Day 12 (Advent of Code 2020)
Time for the Day 12 problem!
In this problem, we have a ship. And we have navigation instructions:
- Action
Nmeans to movenorthby the given value. - Action
Smeans to movesouthby the given value. - Action
Emeans to moveeastby the given value. - Action
Wmeans to movewestby the given value. - Action
Lmeans to turnleftthe given number of degrees. - Action
Rmeans to turnrightthe given number of degrees.
Parsing and serializing ICMP packets with cookie-factory.
In the last part, we’ve finally parsed some IPv4 packets. We even found a way to filter only IPv4 packets that contain ICMP packets.
There’s one thing we haven’t done though, and that’s verify their checksum. Folks could be sending us invalid IPv4 packets and we’d be parsing them like a fool!
This series is getting quite long, so let’s jump right into it.
Generating a docker image with nix
There it is. The final installment.
Over the course of this series, we’ve built a very useful Rust web service that shows us colored ASCII art cats, and we’ve packaged it with docker, and deployed it to https://fly.io.
We did all that without using nix at all, and then in the last few chapters,
we’ve learned to use nix, and now it’s time to tell docker build goodbye,
along with this whole-ass Dockerfile:
Futures Nostalgia
Up until recently, hyper was my favorite Rust HTTP framework. It’s low-level, but that gives you a lot of control over what happens.
Here’s what a sample hyper application would look like:
$ cargo new nostalgia
Created binary (application) `nostalgia` package
$ cd nostalgia
$ cargo add hyper@0.14 --features "http1 tcp server"
Updating 'https://github.com/rust-lang/crates.io-index' index
Adding hyper v0.14 to dependencies with features: ["http1", "tcp", "server"]
$ cargo add tokio@1 --features "full"
Updating 'https://github.com/rust-lang/crates.io-index' index
Adding tokio v1 to dependencies with features: ["full"]
Having fun with ooc
Unfortunately, the ooc language could have better documentation. In the meantime, I’d like to blog about about some features that might not be very well-known.
Nested functions
Here’s a program that prints 1, 3, 5, 7, 9:
import structs/ArrayList
main: func {
list := ArrayList<Int> new()
addIfOdd := func (i: Int) {
if (i % 2 != 0) list add(i)
}
for (i in 0..10) {
addIfOdd(i)
}
list map(|i| i toString()) join(", ") println()
}
Extra credit
We’ve achieved our goals already with this series: we have a web service written in Rust, built into a Docker image with nix, with a nice dev shell, that we can deploy to fly.io.
But there’s always room for improvement, and so I wanted to talk about a few things we didn’t bother doing in the previous chapters.
Making clash-geoip available in the dev shell
When rustc explodes
One could say I have a bit of an obsession with build times.
I believe having a “tight feedback loop” is extremely valuable: when I work on a large codebase, I want to be able to make small incremental changes and check very often that things are going as expected.
Especially if I’m working on a project that needs to move quickly: say, the product for an early-stage startup, or a side-project for which I only ever get to do 1-hour work bursts at most.
Building poppler for Windows
I know what you’re thinking: haven’t we strayed from the whole “content pipeline” theme in this series?
Well… fair. But compiling and distributing software is part of software engineering, and unless you’re in specific circles, I see that taught a lot less than the “just write code and stuff happens” part.
Technically it’s release engineering, but who’s keeping track.
More ELF relocations
In our last installment of
“Making our own executable packer”, we did some code cleanups. We got rid of
a bunch of unsafe code, and found a way to represent memory-mapped data
structures safely.
But that article was merely a break in our otherwise colorful saga of “trying
to get as many executables to run with our own dynamic loader”. The last thing
we got running was the ifunc-nolibc program.