Running old binaries has stayed possible with vintage gaming and computing communities’ hard work. Compiling old source code is less popular and often less possible than playing an old video game. But, at least Rust source code fares better than some.

But why even compile old code?

to fix

Well, what if you just want to fix something you left on the back burner for half a decade? That’s my current situation with SafetyBot, a chatbot to help perform System Theoretic Process Analysis, that was developed for ShmooCon2017 and then all but forgotten. If only I could get it to compile.

to learn

Old code will always be the predominant code on the internet, especially in things like reddit comments and posts, blogs, and stack overflow questions. For humans, as well as LLMs, it’s nice to have as much syntactic and conceptual coherence as possible. Nothing worse than finding the answer to your burning question on a 4 year old post, only to find out that the answer’s syntax has since become invalid.

to play

Old code can be fun. To remind ourselves of where we’ve been and how far we’ve come. It’s comforting to come home to an old book, like K&R C and see that you can still compile a lot of it verbatim.

#include <stdio.h>

main() {
    printf("hello, world\n");
}

background

ReasonML was almost too hot in 2017, it had just been released as a new syntax of OCaml the year before. I gravitated to it’s Javascript-esque syntax and decided to try it for some conference driven development. It worked, with a big lift from hcarty helping design the types and the structure of the thing.

One of the best arguments for the rust toolchain is that it is just cargo. Sure you can add build.rs (ask me why and why not), you can wrap cargo in other things (not my favorite), but at the end of the day, cargo is probably doing the dependency resolution and running the compiler and linker. The configuration is generally just in Cargo.toml.

And most importantly it seems to keep working. 6 years is ancient history when it comes to a lot of compiled code, especially code with dependencies. The dependency heaven is due to the crates.io team.

punchline

Building a ~6 year old rust project:

$ git clone
$ git clone git@github.com:endgameinc/xori.git
$ cd xori
$ cargo build
[... lots of compilation output ...]
warning: `xori` (bin "pesymbols") generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 17.45s
warning: the following packages contain code that will be rejected by a future version of Rust: xori v0.0.1 (/home/rseymour/Projects/xori)
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`
$ [... everything built fine! ...]

Building SafetyBot, a similar vintage ReasonML project:

error: build failed with exit code: 1
  build log:
    # esy-build-package: building: @opam/ocamlfind@opam:1.9.6
    # esy-build-package: pwd: /Users/rseymour/.esy/3/b/opam__s__ocamlfind-opam__c__1.9.6-92be3944
    # esy-build-package: running: 'patch' '--strip' '1' '--input' '0001-Harden-test-for-OCaml-5.patch'
    patch: **** patch file 0001-Harden-test-for-OCaml-5.patch not found: No such file or directory
    error: command failed: 'patch' '--strip' '1' '--input' '0001-Harden-test-for-OCaml-5.patch' (exited with 2)
    esy-build-package: exiting with errors above...
[... oops ...]

end matter

Chemical corrosion costs 3% of GDP yearly, just in first-order damage. Bit rot aka data decay, doesn’t cost as much since most code is either being run or simply isn’t cared about. This blog is a preliminary post revisiting Safety Bot which I envisioned and wrote with hcarty back at Endgame. My talk is up on youtube, but I’ll go into more detail later. For now, just note the pain of compiling old code in a language that moved fast and broke things.

footnote

There are converters for Reason syntax… I couldn’t get those to build either. 🥁

comments powered by Disqus