Library of Trantor
The plan needs to go on.
Welcome, wanderer of the Internet. You have stumbled upon the scribbles of one commonly referred to by fellows as shimmy1996, or rather, my blog. "Shimmy Xu" is just my mundane name.
Aside from HTTPS, you can also find this blog on the following alternate planes of existence:
|Atom||For timeline, posts, hoots, and comments|
5672 AC27 2669 A07A BD28 0896 ACC6 C791 312C F84D
All contents on this site are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA 4.0).
Yes, I finished the Advent of Code this year! Aside from the problems being easier (for me) than 2019, I'm also using Go for this year's challenge and I find it to be particularly suited for this type of endeavor.
This year's puzzles mostly involve string parsing and finding efficient data structures. Majority of the logic flow are pretty straight forward and there's little need for sophisticated algorithms.
For string parsing, regex, which Go has built-in support for, is definitely the way to go. The abundance of parsing related problems means using only basic string manipulation could be rather painful, and I've definitely seen my share of horrible blobs of find/substr/trim.
Most of the time, slices and maps are all I needed. Go has multiple return values but no tuples, whose usage, I find, is largely replaced by either arrays or structs. Versatility of these data structures are actually increased due to the language's encouragement to use constants instead of enums: storing all information as ints opens up the door to some shortcuts and less conversion between types. Surely they don't give you the peace of mind type checked enums provide, but (ab)using them in short programs does provide the odd walking-on-a-knife-edge (or not-wearing-pants-during-Zoom-call) kind of satisfaction.
Imperative programs are easy to write in Go, mostly because of the language's plain and simple control flows and lack of mixed paradigms. There's no need to worry about whether we should use an STL algorithm or chained iterator methods: just write the loop. Reasonable mutability behaviors also helps: whether it's changing a map while looping through it or passing a struct containing a slice to another function, I can get the language to do what I mean without checking the specification line by line.
There's the ZOI rule about how the only reasonable numbers are zero, one, and infinity. Quite a few other languages I know, such as Python, C++, and Rust, all seem to hinge on the extreme ends of the spectrum in pursuit of consistency: everything follows the same rules and users can dictate what the syntax means as much as the base language. Go definitely has more exceptions (without supporting it) and "one" moments: built-in containers are magically generic, their methods can have variable number of return values, and everything else is denied the privilege of being eligible to be iterated over.
While just a quick comparison without touching other traits of Go (say interfaces or goroutines, but you don't really need them for Advent of Code), I do find Go's choices peculiar and interesting: everything is, well, just its own thing.
Rooftops are covered in patches of white this morning. All the billboards have lost their typical splendor to the gloomy sky. Even the street lamps' orange glow failed to add any warmth to the car-free roads. Spots of light from a handful of building windows, however, do appear extra dazzling.
What a year. It feels like space-time has a higher viscosity than usual—dense enough to reduce sunlight to just an ivory ambiance—given how eventful the past 300-or-so days have been.
I'm actually glad that the first day of 2021 still feels like any day in 2020. Not very much should physically change simply because of a number flip, not to mention a rather arbitrary one, but perhaps it's exactly for the lack of change that we need to forge something new, something that gives an adrenaline kick, no matter how small.
Ugh, fine. I see no harm in giving in to this cheap psychological trick every once in a while.
Happy New Year, we made it.
I'm not cutting myself any more slacks this time around.
Run 550 miles.Run 205 miles and cycle 865 miles (2.5x).
- ☑ Write 14 blog posts.
- ☑ No donuts.
- ☐ Dive into Go and C++20.
- ☐ Set up proper backup workflow.
- ☐ Read non-technical books.
Because of COVID-19, I have stopped running outdoors since early March. After a few months of hiatus, I got a bike and a trainer in June and started cycling indoors instead. The 2.5x scaling factor is based on the speed differences between cycling and running. Working out in a more controlled environment is very enjoyable. Aside from easy access to fueling and shielding from the weather, being able to watch anime/listen to seiyuu radio while riding is a game changer. Behold, technology!
Blogging about the blog itself still takes up a sizable portion of my posts (and is a frustratingly self-defeating practice), but I did at least accumulated quite the amount of hoots: these fleeting thoughts aren't organized enough to be its own post, but still interesting enough that I want to write it down. I also use hoots to house my replies to other blogs and the rather cumbersome process of which makes me realize how little I really have to say most of the time. Not to color my still largely manual approach superior, but I do think there is some merit in eliminating low-effort-high-noise contents, both for myself and others.
Ah, donuts, the honey glazed shackles of guilt, the deep-fried cuffs of indulgence. While I would like to attribute this to my will of steel, it is COVID-19 that got the better of such temptations. My laziness and excitement for bunker life eliminated any chances of late night Dunkin' visits. Guess it's time to turn up the dial.
Writing Go was quite the mindless fun exercise. Finding an effective way to learn the C++20 features proved to be harder.
<format> is the straightforward one and pretty much works as you'd expect (no compiler supports the standard version yet, so checkout the original).
<ranges> is similar to Rust's iterator methods and allows chaining, too. Maybe I should update my enumerate() with C++ post.
<concepts> seems like the logical solution to the problems SFINAE tried to solve, but I don't have a good context to test out its prowess yet. On a related note, Zig's compile-time function approach to generics is also intriguing.
3 copies, check. 2 different media, check. 1 offsite backup, not yet. I'm also counting Syncthing copies here, and whether they can be relied upon as full fledged backups is debatable. Still some way to go here.
Technically, I did read non-technical books; I didn't finish any (not counting manga at least). The truth is, aside from those I read purely for entertainment, I am not so sure about what to read. Most non-fiction books look like success stories marinated in flattery and survivor-ship bias. Fictions, on the other hand, just don't attract me that much: knowing another story to tell isn't as exciting as learning a new algorithm for me. Gee that sounded harsh. Do I really think my blog posts fare any better? Anyways, before admitting defeat, I will give this a more serious attempt this year.
2021: Days of Future Past
The ongoing pandemic sparkled nostalgia like never before. People look back at the "normal days" with fondness that I find repulsive. Not that I'm completely immune to the atmosphere though, just that it rubs me in the opposite way: I find myself grew more assertive than before. After all, doesn't everyone secretly think they are above average and thus know better, especially after reading the news? At the same time, the voice of reason tells me to suppress this urge before it turns into arrogance, or even worse, ignorance. Perhaps I should learn to let these out in the form of blog posts, like EWDs, except non-technical.
On a positive note, my transition to wake-up-at-5-sleep-before-10 schedule is a resounding success. The lockdown WFH actually helped in that I have more leeway to adjust my sleep schedule. Now I have plenty of time for exercise every morning or even the option of another two—or three if I'm really pushing it—hours of sleep. Given how I was able to clock in the last 100 miles of rides within the winter holidays, I'll bump the target mileage up a bit this year.
The schedule change also made me realize how unproductive the few hours before bed really is for me: after a day of work and much needed dinner, I don't feel motivated enough to exercise or focus on anything for an extended period of time. Since I started beancount-ing in 2020, I'm now looking to apply a similar methodology to my time. I've been testing out Toggl Track to log how I spend the larger chunks of my day and how many minutes in between slipped away with me blanking out watching YouTube. In particular, I figured having a crude "Strava for reading" system would also make my reading goals easier to achieve. As for which books to read, I'm thinking classic fictions.
After donuts, my challenge this year is to abstain from cookies, which can frequently be found in my work place lunch bags. It's strange how exponentially more attractive cookies are to their ingredients, i.e. sticks of butter and bags of sugar, the latter of which would have been sickening to consume directly.
I wonder if this is an age thing: at some point, human's auditory perception would just click with the sound of electric guitars, making it impossible to resist. I'm looking to sink more time into learning the instrument and be good enough to play a song or two by end of 2021.
The generation after Z is named Alpha, which makes no sense at all. To hell with inconsistent naming. To hell with COVID-19 (for other reasons, of course).
Un de ces matins disparaissent
Le soleil brillera toujours.
twixter -> twoxter -> twixt3r -> twIVter -> twixter (in typical movie sequal naming fashion).
Reading through the latest Go generic proposal, I felt ok at the beginning, but increasingly uneasy as I scroll along to find the long list of restrictions and edge cases. It's clear that the dev team is actually painstakingly trying to fit a generics implementation (almost exactly as people have asked for) into the language. Perhaps because Go seemed like such an opinionated language, I was not actually expecting such an serious attempt at all: I would have expected Go generics to simply involve a handful of special interface types from standard library that are somehow unboxed (have one less layer of pointer redirection) and we still write for-loops instead of map-reduces.
It's one of those cases where I applaud the effort, but I'm not convinced that a suitable solution can be achieved (like The Rise of Skywalker). The proposed generics system eats into Go's originally quite orthogonal feature set and reading through all the caveats of how it would interact with other parts of Go already feels similar in length as the entire Go spec. On the other hand, generics and interface types obviously overlap in functionality and while there are restrictions in place to discourage a Go version of "almost always
auto" from happening, having to think about which one to (not) use takes away some of Go's appeal for me.
Ugh, this is such an arduous yet unrewarding path to go down. Maybe Go team's
.async moment would eventually come and we would all love the solution, but then again, I really don't mind writing generics-free Go that much.
As sketchy as Brave can seem at times, it has built-in support for IPFS now! The fact that we end up relying on
ipns:// URI schemes is a bit funny, but hey, this is still great news.
TIL unlike concrete, steel bridge surfaces will turn piled-up snow into ice, so don't attempt to challenge them with your bicycle. Ouch.
They do make motorcycle helments with shark fins!
The weather has finally warmed up. Snow on the streets are starting to melt away. No more worrying about slipping off while cycling. Makes you want to write some neat borrow-checked auto-formatted Rust doesn't it!