featured.jpg

Phoenix Park

A Stroll Down (Muscle) Memory Lane

Went out with Womanfriend to Phoenix Park for a walk in the evening after work. It was a longer than usual walk, clocking at about 14,000 paces on my pedometer, the longest since the lockdown happened. I can tell that the body isn't used to long walks any more, as our legs were sore on the trek back home.

Hopefully after more easing measures, we will resume a better walking/exercise routine to keep fit.

More Dev Work

Still working on my notification app. It's gotten to a point where I can detect file changes, pattern match a log line to an event, and send out a message via Telegram to inform me that my service is up and ready.

I've gotten more familiar with a few more things with Rust along the way, especially the new little nuances with scoping with braces being a deliberate thing, as we need to tell the borrow-checker that certain things aren't used an be out of scope already. It is a new thing to get used to, compared with plain ol’ C where it's mostly only used for shadowing code constructs.

There's a lot about the ergonomics of Rust that I like with developing in it, such as sensible import strategies, (compared to the asinine scheme of package naming by reversing DNS strings by word in Java), central online package lookups, and automatic linking of libraries.

Those little quality of life things for systems programming is AMAZING. It used to be the case, in order to compile something, you'll need to manually download source libraries, tinker with the compile flags, mess with Autotools, Makefile and get the linker to link to version ‘X’ instead of ‘Y’ of the library, etc, etc.

Then you have the platform-specific part of things, where the source wouldn't work/compile the same way if you are on Windows/Linux/MacOS or that whether if you're on x86/x86_64/ARM, etc. All these platform malarky mostly goes away with Rust.

Say I wanted to detect file changes. In Linux, you'll have to mess around with inotify, on Mac FSEvent and on Windows ReadDirectoryChangesW, the last which isn't an API that I'm even familiar with. All these things, you get for free by just doing a Cargo import of ‘notify’.

For a Systems developer, that's nothing short of amazing. Most of the portability concerns that you need to deal in with ‘C’, GONE.

Not to say that it all works seamlessly, of course. Sometimes Rust does fall apart with that illusion. For example, the library ‘mac-notification-sys’ on my machine fails with:

   Compiling mac-notification-sys v0.2.0
   Compiling quote v1.0.5
   Compiling backtrace v0.3.48
error: failed to run custom build command for `mac-notification-sys v0.2.0`

Caused by:
  process didn't exit successfully: `/var/folders/xs/txn5d44s7g1_kp8x7nnbm7v1q7bpmn/T/cargo-installND8mVh/release/build/mac-notification-sys-6f2bb99115214ad4/build-script-build` (exit code: 1)
--- stdout
TARGET = Some("x86_64-apple-darwin")
HOST = Some("x86_64-apple-darwin")

...

cargo:warning=objc/notify.h:1:9: fatal error: could not build module 'Foundation'
cargo:warning=#import <Foundation/Foundation.h>
cargo:warning= ~~~~~~~^
cargo:warning=15 errors generated.
exit code: 1

I didn't dig further with trying to work out whether if it's XCode being the issue, or that somehow the linker is configured wrongly by the project. But someone out there providing a library that does this transparently, and cargo being an easy general lookup for libraries without going to the browser, search for a library, figure out if it's canonical, then building it, and deal with issues of where to link/store the associated libraries with your application in order to be able to ship your binary out the door, is a big win. It certainly takes a lot of the grind out of application development, certainly for systems folks for sure.

Vincent Liu avatar
Vincent Liu
Part man, part machine. Or at least when I sit in front of a computer... here is where I pen my thoughts.