212 results for "":
Rust modules vs files
A while back, I asked on Twitter what people found confusing in Rust, and one of the top topics was “how the module system maps to files”.
I remember struggling with that a lot when I first started Rust, so I’ll try to explain it in a way that makes sense to me.
Important note
All that follows is written for Rust 2021 edition. I have no interest in learning (or teaching) the ins and outs of the previous version, especially because it was a lot more confusing to me.
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"]
Three gamedev surprises
Despite their peaceful appearance, game developers actually lead thrilling lives! Here are three things I learned (or re-learned) about yesterday that I’d like to share with you, in the form of assumptions that revealed false.
VSync is relatively straightforward. Right?
As an obsessive-compulsive, bipolar, perfectionist game dev, getting your game to run smoothly on all kinds of operating systems, graphics cards, and drivers combination is something of a holy grail. Many look for it, but let’s be honest here, it never really turns out as expected.
Day 6 (Advent of Code 2022)
Today I am joining you from the relative discomfort of my living room (since my better half has commandeered the home office due to Way Too Many Calls) to tackle the day 6 challenge, which I’m excited about: maybe despite, maybe because of, the low-grade fever I’m under.
Part 1
Our input is a jumble of letters, and we’re supposed to find the position of the first substring that’s “four different characters”.
A dynamic linker murder mystery
I write a ton of articles about rust. And in those articles, the main focus is about writing Rust code that compiles. Once it compiles, well, we’re basically in the clear! Especially if it compiles to a single executable, that’s made up entirely of Rust code.
That works great for short tutorials, or one-off explorations.
Unfortunately, “in the real world”, our code often has to share the stage with other code. And Rust is great at that. Compiling Go code to a static library, for example, is relatively finnicky. It insists on being built with GCC (and no other compiler), and linked with GNU ld (and no other linker).
Day 3 (Advent of Code 2022)
Part 1
I’m not sure where the day 3 challenge is going, because the problem statement for the first part is kinda convoluted.
As usual we have an input, like this:
vJrwpWtwJgWrhcsFMMfFFhFp
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
PmmdzqPrVvPwwTWBwg
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
ttgJtRGJQctTZtZT
CrZsJsPPZsGzwwsLwLmpwMDw
Each line represents the contents of a “rucksack”, divided in two halves (which are called “compartments”), so for line 1:
Profiling linkers
In the wake of Why is my Rust build so
slow?, developers from the mold
and
lld
linkers reached
out,
wondering why using their linker didn’t make a big difference.
Of course the answer was “there’s just not that much linking to do”, and so any
difference between mold
and lld
was within a second. GNU ld was lagging way
behind, at four seconds or so.
Between libcore and libstd
You’re still here! Fantastic.
I have good news, and bad news. The good news is, we’re actually going to make an executable packer now!
Hurray!
I know right? No lie, we’re actually really going to start working on the final product from this point onwards.
What uhhh what about the previous fourteen parts?
Ah, yes, the previous fourteen parts. Well, we had fun, didn’t we? And we learned a lot about ELF, how it’s basically a database format that different tools look at in different ways, how it’s mapped in memory (more or less), what we really need to set up before starting up another executable, all that good stuff.
All color is best-effort
I do not come to you with answers today, but rather some observations and a lot of questions.
The weird glitch
Recently I was editing some video and I noticed this:
Not what the finger is pointing at — the dots.
Here are the separate layers this image is made up of: the background is a stock image I’ve licensed from Envato Elements:
Because I use it as a background image, I’ve cranked down the exposition in the Color tab: