dubdromic

Lorn + Dolor

Zero Bounce.

LeBrock's Real Thing

This album is great. It's synthwave with an 80s hair metal singer. Sign me up.

Fleabag

Man I love this show. It's funny and heartbreaking and disgusting and a perfect example of how hard it is to navigate life sometimes. It can all make sense and still not work out! And that's okay.

Kipling

I picked up the pocket version containing most of Kipling's poems. Just full of fantastic verse.

Down to Gehenna or up to the Throne, He travels the fastest who travels alone. – The Winners

Ship me somewheres east of Suez, where the best is like the worst, Where there ain't no Ten Commandments an' a man can raise a thirst; For the temple-bells are callin', an' it's there that I would be – By the old Moulemein Pagoda, looking lazy at the sea – Mandalay

Part 1.

I was able to make minor progress on the Cribbage game. It's been a few weeks since I had looked at it – turns out a global pandemic can be distracting. The code I left is just series of enums and a Card struct.

The goal for this round was simple: build an all function that returns all 52 cards and print the result. So, as a list:

  • Be able to informatively print a Card struct
  • Iterate across all ranks and suits to build a list of Card structs (we basically want the Cartesian product)
  • Write a test or two proving out the above behaviors

This is roughly what I came up with for the “give me all the cards” function:

 pub fn all() -> Vec<Card> {
     let mut cards = Vec::new();
     for suit in SUITS.iter() {
         for rank in RANKS.iter() {
             let card = Card::new(*rank, *suit);
             cards.push(card)
         }
     }
     return cards
 }

So far so normal.

I did run into an interesting case: std::fmt::Display. I tried to implement it for the Card struct to make printing easier. This:

impl std::fmt::Display for Card {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.to_string())
    }
}

For some reason, this hilariously explodes with a stack overflow. It's probably something silly. For now, I'm just doing println!("{}", card.to_string()); I'll come back around to this next time so I can understand what's going on.

Some minor notes:

  • Via Elixir, I'm used to assert; assert_eq! has better output when something goes wrong.
  • My mod test blocks have a user super::*; call; this is required (?) for it to compile but I get warnings from cargo build about an unused import. I've even tried specifically calling use super::Card and it still complains about it being unused.
  • I'm trying out VS Code instead of vanilla vim. Per usual, the vim emulation is “weak”...it supports everything I use within a single editor window but when you pull in a terminal or side panel the shortcuts just bail. Having various cargo tasks available via shortcut is nice.

That's it for now.

#technology

I decided to start learning Rust and wanted to try something I’ve never done: write about it while learning.

The Idea

  • Start out with some basic reading
  • Use my favorite card game, cribbage, as a template for working out basic algorithms, data structures, and general syntax

Notes while reading

  • Oof, I’m gonna have to get used to static typing again.
  • References and borrowing are wacky! It’s intuitive in the “follow the scope” sense but I’m going to have to just work with it more.
  • Lifetimes are a clever way to get around “the compiler can’t figure this out” cases, if not clunky syntax-wise.
  • I love how common it is to have a “strings are hard” section in any programming language tutorial. By “love” I mean “hate”.
  • match makes sense but feels weak compared to Elixir’s pattern matching.
  • The Rust book is very good so far. I stopped on the chapter about testing; I’ll have to pick up the rest later.

Working with code

I didn’t get very far today. This is an abbreviated excerpt:

struct Card {
  rank: Rank,
  suit: Suit
}

enum Rank {
  Two,
  Three,
  # etc
  King,
  Ace
}

enum Suit {
  Hearts,
  Spades,
  Diamonds,
  Clubs
}

impl Card {
  fn new(rank: Rank, suit: Suit) -> Card {
    Card {
      rank,
      suit
    }
  }
}

Some notes on this:

  • Tests are confusing; they effectively recommend setting up a mod test block in each file for the unit tests. I like the idea of keeping them close to what they test, but I’ve had trouble lining up the various use and mod calls to get it wired up.
  • The compiler messages are extremely good.
  • The documentation on the difference between a binary and library project are kind of strange? Maybe I’m missing it, I need to just set up both.
  • Convention over configuration! Stuff like mod referring to the file name, rustfmt, etc.
  • Compile directives are...janky. Stuff like #[derive(Debug)] and #[test] feel bolted on.

That’s all for now!

#technology

I've been writing code using vim for almost 20 years at this point. Its keybindings are my default; it's in my blood. When I first started using vim there was a minimal plugin ecosystem...you could find things on vim.org but in general it was sink or swim. I'm thankful for that, since it forced me to aggressively climb vim's learning curve (turns out :help is actually helpful).

As time passed, I gradually added plugins for various functions – fuzzy finding, grepping, themes, VCS, etc. At one point, my .vimrc was many hundreds of lines long...and it was still largely configuration (vs functions or code I'd written). It was clunky, difficult to make portable, and felt like a mental weight any time I had to interact with it.

So, a few years ago, I decided to “reset”. Delete my artisinally-crafted dotfile and start over. Let the tools do the work instead of trying to get vim to do everything.

It's been a fantastic experience.

This is my entire .vimrc as of March 2020:

syntax off
set number
set relativenumber
set colorcolumn=100
set hidden
set autoindent
set wildmenu
set wildignore+=*/_build/*,*/deps/*,*/.git/*
set path=**
set expandtab
set ts=2
set sw=2
set sts=2
nnoremap ,f :find 
nnoremap ,b :buffer 
highlight LineNr ctermfg=grey
highlight CursorLineNr ctermfg=grey

This is much closer to vanilla vim; if you exclude cosmetic configuration, it's only 13 lines. I can almost type it from memory. Which solves the portability and performance implications of plugins.

Simplifying my vim setup has had another advantage: it's slowed me down as a programmer. :find requires you to think through simple regex. No syntax highlighting means you have to read the code. Using autojump for navigation means you have to stop and switch tools to get around. Initially this drove me a little crazy but a few really great things have come out of it:

  • It's become easier to be thoughtful about what I need to do before doing it. Since the barrier for entry is “higher” – things take longer – it's forced me to think through what I actually need to do before just stabbing around in the dark.
  • I no longer plan out a code change against the code itself. Navigation is more difficult, so it's become easier to write out a solution first then apply it once the problem is solved. Anecdotally, this has allowed me to eliminate broken or incomplete solutions earlier in the process.
  • I've had to become more familiar with grep, git, find, and Bash. Part of me wishes I didn't have to do this – you can get 95% of the way there with simpler tools – but I appreciate having to grow and being more capable when encountering an edge case.

So that's my vim setup. I'm not suggesting it's for everyone! I know very good programmers that have vim set up with all kinds of bells and whistles. But it's surprised me with something that is for everyone: slowing down. Haste makes waste, as they say.

#technology #vim

I like to keep track of the random things that I find interesting right now; these are often transient, but it's neat to have a record.

White Bat by He Is Legend

White Bat album cover

I'm a little bit obsessed with this album. I've listened to it more or less non stop since November.

Some highlights, in my opinion, are “Eye Teeth” and “Boogiewoman”. The whole album is aggressive and punchy and has groove and is well written.

Tahuya ORV Park

I stumbled on an ORV park while out riding on President's Day. It's a giant pile of ATV trails with the occasional single track. Fantastic riding, I can't wait to go back.

Breath of the Wild speedrunning

I stumbled upon an “All Main Quests” run of Breath of the Wild. It was fascinating, if only because of the skill required.

Food

Some interesting eats recently:

  • A ham and swiss sandwich with arugula and avocado; really super tasty, the avocado nicely offsets the bitterness of the arugula
  • MSM Deli's Italian Cold Cut; it's huge, it's delicious, it's MSM
  • Rachel Ray's Chicken Chipotle Chili; my mom turned me on to this. It's amazing and reheats really well.

I've never been much of a writer. I keep a journal – irregularly – and a day-to-day work log for my job. Other than that, I don't write...and I'd like to change that.

This blog, for whatever it's worth, is an effort to that effect.

My initial ideas for this:

  • Post about things I find interesting right now; it will be nice to have a place with a record of the various things I come across
  • Have a place to yap about my hobbies
  • Write about general technical subjects

As an aside, I picked write.as as a platform because I appreciate it's stance on longevity. We should have to pay for services; it establishes the expectation that the services aren't going to sell me or go away (“It's been an incredible journey...”).

The goal is to post something once a week. It could be one sentence or an entire book. Just something.

#personal #writing

Enter your email to subscribe to updates.