Blog

Smart Pointers and Memory Ownership in C++ Libraries

I don’t often get deep into technical minutiae on this blog, preferring to write for a more general audience. Despite that, programming computers is still my day job, and the articles that do get into technical detail tend to get people interested: the article that dove deep into the type system I developed for my thesis got some recent attention from Hacker News, the article about how to extract messages from WeChat is consistently one of the pages with the most hits (presumably because it’s useful to some people), and I’ve even gotten some good feedback and attention to my unpolished and unedited programming languages notes from university, which I only barely ever publicized.

I’ve even gotten a bit of a reputation at work as someone who can explain things to people in a way that’s understandable. I’ve been trying to lean into that strength at my job, and while I’m doing that, I may as well bring some of that knowledge to the outside world as well, where appropriate.

All this to say: this article was adapted from something I wrote at work, in order to explain some subtleties about how smart pointers in modern C++1 work to people that only had experience with older C++. More specifically, this gets into how the way you use smart pointers should impact the design of libraries and their APIs.

  1. For the purposes of this article, we’ll assume that “modern C++” means C++11 and later, whereas “older C++” means everything before C++11. ↩︎

Read more…

Scenes from Silicon Valley

It’s been just over two years since I first moved to Silicon Valley.

Ever since I wrote Scenes from New York, I always intended to put together another collection of photos for the San Francisco Bay Area. But two years is a long time. For Scenes from New York, I had only been living there for nine months. The city was still new to me, and I could still comment on it as if I were an outsider.

But here, now, in California? I’ve gotten used to its quirks, its advantages, and its dysfunctions. That makes it harder to talk about this place objectively in a way that people from the outside would understand.

But still, I’m going to try anyway.

A panoramic image of San Francisco taken from Coit Tower, the tall towers of downtown SF visible on the left.
Read more…

The Hierarchy of Conflict

I’ve talked before about how negativity and criticism are crucial to growth and should be preserved. This time, I want to talk about conflict.

I’ve found that I have pretty differing reactions when I see or participate in conflict, depending on the situation.

If I see a couple bickering about whether or not they’re going to go out for dinner, I generally don’t have a good reaction. It tends to be a shallow argument, they’re probably hungry and in a bad emotional state, and ultimately one day eating in or out (usually) doesn’t matter.

There’s a more constructive version of this though.

Read more…

Caring

For a brief moment, the wireframe fibres constructing the world were visible. But in the blink of an eye, they vanished, and the man found himself in a comfortably decorated, warmly-lit room with a short, dark-haired woman who looked to be in her early thirties.

She smiled at him. “Welcome back. It’s good to see you again. How have you been?”

Read more…

The Chasm of Culture

If you know a bit about me, you’ll know that I grew up between multiple cultures: my mom’s side of the family lives entirely in Brazil, my dad’s side almost entirely in Portugal, and I myself grew up in Canada. Those three cultures have some pretty profound differences, from Brazil’s laissez-faire looseness, to Portugal’s focus on social rituals, to Canada’s more British-style aloofness and distance when compared to the other two.

I was exposed to all those cultures young enough that I internalized the different aspects of them. I grew up knowing that these different sides of my family and social groups acted and expected to be treated in different ways, and managed to find a way to center myself in the common ground between them while adjusting myself to fit them wherever necessary.

It’s led to a lifetime of feeling a bit like a misfit no matter where I go, but it’s also helped me have a broad perspective on a wide variety of different issues. I consider that outlook and perspective to be a very fundamental part of who I am today.

But even that kind of upbringing didn’t prepare me for the culture shock I would be exposed to when, as a kid, I moved from downtown Toronto to a semi-suburban neighbourhood in Halifax, Nova Scotia.

Read more…