1. A Stable Modular ABI for Rust

    Before Swift Evolution, I had no idea what an ABI was. Today, even though I still get lost when it comes to the minutiae, I can at least follow along threads like this one without feeling too uncomfortable.

    It’s also eye-opening to see how different communities and companies prioritize different aspects of a programming language. Rust got async/await since version 1.39.0, released last November, but they have yet to stabilize the ABI. Apple went about it the other way around with Swift, given the importance of ABI stability for their platforms.

    A stable ABI would allow Rust libraries to be loaded by other languages (such as Swift), and would allow Rust to interop with libraries defined in other programming languages. […] However, a stable ABI is not all peaches and roses. Having to standardize the memory layout of data can limit the number of optimizations the compiler can perform.

    A modularized ABI would be optional while compiling. This modular ABI could be published as a versioned crate. If the ABI ever needs a backward-compatibility breaking change, the change could be made within Semver. Alternatively, a new ABI-compliant compiler backend could be developed, or the current compiler backend could be extended to support an ABI feature flag that would toggle ABI compliant builds.

  2. This Week I Learned #6

    Here are some of the things I learned this week, in the order I’ve noted them down.

    • How the MissingNo. sprite is rendered in Pokémon. If you are into retro games and programming, I highly recommend this channel.

    • The Scunthorpe problem is, according to Wikipedia, “the unintentional blocking of websites, e-mails, forum posts or search results by a spam filter or search engine because their text contains a string of letters that appear to have an obscene or otherwise unacceptable meaning.” Via Scunthorpe Sans.

    • How HTTP/3 and QUIC work. I hadn’t heard about QUIC until earlier this week and watching this talk by Daniel Stenberg was a perfect way to catch up. Thanks Alaa for the tip!

    # Programming

    • Global variables in Swift are lazy—it’s in the docs even. I don’t know how I ended up with the assumption that they are eagerly evaluated (thanks again, Kim!).
  3. As days keep getting longer here in Stockholm, I’ve been relying on the light appearance of macOS to avoid straining my eyes. One thing that caught me off guard is the dearth of decent-looking light themes for text-based applications. It’s almost as if developers have an overwhelming penchant for dark interfaces…

  4. This Week I Learned #5

    Here are some of the things I learned this week, in the order I’ve noted them down.

    • 自粛じしゅくつか (jishuku-tsukare). An expression that’s gaining momentum right now in Japanese media, meaning getting tired of voluntary confinement.

    # Programming

    • Visual explanations go a long way in demystifying tricky topics such as [floating numbers](Floating Point Visually Explained) and regular expressions.

    • JavaScript frameworks are costly, argues this well-researched piece by Tim Kadlec. One would think that performance tends to get better over time in technology, but that doesn’t seem to be the case in JS-land.

    • I picked up some LaTeX this week for writing mathematical notations and this cheatsheet came in quite handy.

  5. This Week I Learned #4

    Here are some of the things I learned this week, in the order I’ve noted them down.

    • The Blub Paradox (thanks Kim!). Coined by Paul Graham in his 2001 essay “Beating The Averages”, this concept refers to the inability of a programmer using a hypothetical mid-level language, called Blub, to:

      • Use a lower-level language due to lack of features they are familiar with in Blub.
      • Realize that they are looking at a higher-level language when they evaluate one.

      I have some reservations about this one, based on my own experience, but it’s a nice tidbit nonetheless.

    • I did some reading on flying machines this week and picked up a new word: ornithopter.

    • I almost feel ashamed for not knowing this one until this week1: deuteragonist and tritagonist.

    • This answer by Dave Abrahams to a Quora question about the most important things involved in delivering a great software library. If I had to pick only one, that would be “rigorously document“.

    • The .org TLD is saved!


    1. Not gonna lie, it’s a fairly prevalent feeling throughout these updates.
  6. This month I noticed a sudden influx of visitors to the We Need Chrome No More piece form last year—46k page views is way, way above the monthly average hovering around 1k. My self-hosted instance of Fathom shows some limited data about top referrers, but none of the numbers make sense, and I am totally fine with that.

    Website visitors, April 2020.

  7. Solutions, Problems, and Learning

    From a content creator perspective, it’s relatively easy to write about solutions. Tips and tricks. How to do X or Y. Lessons learned. In contrast, it’s significantly harder to write about problems—what’s at stake and why it’s worth the effort. Understanding a given problem to a level where it can be distilled requires much more rigor and experience than presenting solutions to said problem.

    From a learner perspective, especially in their early stages of the learning process, it is far more worthwhile to understand the problems, challenges, and tradeoffs than to build a repertoire of solutions. Doing the latter without the former might work in the short and mid-term, but on the long run it is very likely to hinder personal and professional growth. Fast food is an apt analogy.

    While this dichotomy makes learning certain topics particularly hard, it’s not unsurmountable. One has just to look hard enough.

  8. This Week I Learned #3

    Here are some of the things I learned this week, in the order I’ve noted them down.

    • The words ”esoteric” and ”niche” do not have the same connotations. I used the two interchangeably in the past, and that resulted in some really awkward sentences. Thanks anonymous reader for the tip!

    # Programming

    • How the layout algorithm works in SwiftUI stack views. Huge props to Adrian Zubarev for making that task easier for me. I will be sharing more about these findings, and the context that motivated them, in the near future.

    • Database normalization and normal forms, through various articles and resources, including this one. I’ve intentionally tried to stay as far as possible from databases for the past 10 years, but now I feel like I am missing out on a fundamental aspect of building server-side software.

    • After all these years, CSS is still fun.

  9. I’m genuinely excited to see Chris Krycho adopt the format I’ve been recently experimenting with on this microblog. I’ve learnt a lot from reading Chris’ essays and journal entries1, and I am looking forward to reading more of these.


    1. That’s also where I got the assumed audience idea from.
  10. This Week I Learned #2

    Here are some of the things I learned this week, in the order I’ve noted them down. This week I created a separate section for programming to keep things tidy.

    • Contact tracing. A joint initiative by Apple and Google to help health organizations throughout the world slow down the spread of COVID-19. This excellent entry on NSHipster is a good place to start if you’re interested in the nitty-gritty details. The official documentation itself can be found here.

    • Last week I mentioned free access to the ACM Digital Library during COVID-19. This week I stumbled upon this list of similar offers compiled by Michael Tsai.

    # Programming

    • The relationship between size, stride, and alignment in the memory layout of Swift types, thanks to this excellent article by Greg Heo.

    • In Swift Combine, you can filter out nil values using .compactMap { $0 } (reference). I was using filter(_:) before but that still requires force-unwrapping the value in subsequent operations.

  11. This Week I Learned #1

    Here are some of the things I learned this week, in the order I’ve noted them down:

    • Calm technology. A term coined by PARC researcher Mark Weiser in 1995, referring to technology that does not seek to become the center of attention when we use it. It’s there when we need it, and out of sight when we don’t. More on the topic here.

    • Eggcorn. A phrase or expression that resulted from intentionally or accidentally substituting one or more words from an expression with similar-sounding words (Wikipedia). For example:

      • Praying mantis -> preying mantis.
      • Cut to the chase -> cut to the cheese.
      • Acorn -> eggcorn (duh).
    • The entire ACM Digital Library is free to access until June 30th. There’s more to COVID-19 quarantine than Netflix 😉.

  12. Dear GitHub,

    Where is my official dark mode support at? My eyes would profusely thank you for it. And they will be joined by many, many others in doing that.

    Sincerely,

  13. GIF Hunt?

    Product Hunt

    While browsing Product Hunt yesterday, I couldn’t help but get a strong mid-90s, GeoCities-esque, vibe as I scrolled past the animated GIF thumbnails.

    I get it. This is how the attention economy works, and the Internet loves them GIFs. But when everything is screaming for your attention at the same time, the whole thing becomes a kitschy, obnoxious mess.

  14. More on Metasyntactic Variables

    My good friend Mikael Muszynski sent me this nugget about metasyntactic variables:

    I was reminded of the fact that companies which speak primarily in Swedish have their own metasyntactic variables!

    The code will generally be written in English, but instead of foo and bar, they have a clever system:

    “Apa” is the word for monkey [in Swedish], and not only is it a somewhat amusing word, it also happens to start with the letter “a”!

    So the pattern goes apa, bepa, cepa, depa

    Clever indeed.

  15. Margin Considered Harmful

    Max Stoiber on using margins in UI components:

    Margin breaks component encapsulation. A well-built component should not affect anything outside itself.

    It’s very hard to disagree with this statement if you’ve been involved in any capacity with creating reusable UI components. Baked-in margins can and will hinder component reuse across different adaptive layouts.

    A few years back, margins were the only way to create float-based grid layouts in CSS. Today, margin gymnastics are no longer necessary.

    Instead of margin I have started using spacer components, which move the responsibility of managing space to the parent-level.

    Implementation details aside, delegating the spacing between adjacent items to the wrapping component is the right approach. For instance, SwiftUI uses a similar API to the one suggested in the blog post:

    VStack(spacing: 8) {
      Text(”Item 1)
      Text(”Item 2)
      Text(”Item 3)
    }
  16. Full-Page Screenshots in MacOS Safari without Extensions

    Here’s a new trick I picked up this morning: you can take full-page screenshots of any Web page in Safari for macOS without using third-party extensions.

    Before trying this at home, make sure you have the Develop menu enabled. In case it’s not visible in the menu bar, head to Safari ▶ Preferences ▶ Advanced ▶ Show Develop menu in menu bar.

    Once that’s taken care of, follow these steps:

    1. Head to Develop ▶ Show Web Inspector or use the Option + Command + I shortcut.
    2. In the first Elements tab, look for the html tag in the source tree.
    3. Right-click the html tag and choose Capture Screenshot.
    4. Choose a destination and save the file. Append the .png extension to the name if you want preview to properly recognize it as an image.

    Bonus: You can capture any HTML tag in the source tree, not just the root element.

  17. Metasyntactic Variables

    You know those placeholder words used when writing tests or documentation for software programs? They are called metasyntactic variables, and today I picked up some brand new ones beside the usual foo, bar, baz, and qux: corge, grault, garply, waldo, fred, plugh, xyzzy, and thud (source). The last one is definitely a keeper.

    struct Thud: Thuddable { ... }

    I remember the first time I was introduced to toto—the most used metasyntatcic variable in French programming literature—and made fun of how silly and immature it sounded; a shortsighted take in retrospect.

  18. Going Indie

    Today was officially my first day as an indie. Even though the timing might be less than ideal, I can’t help but feel excited about it—especially whenever I take a gander at my meeting-free calendar.

    I have drafted some plans leading to this, but I didn’t have a global pandemic in any of them. Silly me.

    Then again, a quarantine is exactly what I need to start chiseling away at one or two behemoth projects that have been staring me down for the better part of last year.

    Wish me luck. And f☆ck COVID-19.

  19. I am slowly starting to appreciate the versatility of the CSS Grid layout module. For instance, in this commit I replaced a flex grid that required finicky media queries and margin gymnastics with essentially three lines of code using grid. Here is a variable-free version of what I ended up with:

    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
    grid-gap: 1rem;

    The result can be seen here. Not only this achieves the exact same result as my previous flex solution, but it is cleaner and doesn’t use any media queries. Sign me up!

  20. Using Key Paths for Deduplicating Swift Arrays

    Today I needed to remove redundant elements from a Swift array based on the value of a specific property. After some foraging, I came across this post where Antoine extends Sequence to handle the more generic case of deduplicating elements that conform to Hashable.

    public extension Sequence where Iterator.Element: Hashable {
      func deduplicated() -> [Iterator.Element] {
        var seen = Set<Iterator.Element>()
        return filter { seen.insert($0).inserted }
      }
    }

    For my use case, I needed a bit more control over how the elements get deduplicated. Since I am only interested in comparing a single property, I resorted to key paths since they lend themselves quite well to this usage.

    public extension Sequence {
      func deduplicated<T>(
        by keyPath: KeyPath<Iterator.Element, T>
      ) -> [Iterator.Element] where T: Hashable {
        var seen = [T: Iterator.Element]()
    
        return filter { element in
          let key = element[keyPath: keyPath]
    
          if seen[key] == nil {
            seen[key] = element
            return true
          } else {
            return false
          }
        }
      }
    }

    And here is an excerpt from the code where I am using this extension.

    struct Game: Codable, Hashable {
      var name: String
      var releaseDates: [Date]
      /* ... */
    }
    
    /*
      The API reponse returns a list of non-unique games separated.
      by release date, but for this view we only want a single instance.
      of each game.
    */
    
    let games: [Game] = /* ... */
    let deduplicatedGames = games.deduplicated(by: \.name)
    

    For the name, I chose to not go with unique because it describes the elements of the sequence rather than the sequence itself. I instead took some hints from Rust’s similar-but-not-quite Vec::dedup.