I work on the Protocol Buffers team at Google. I created upb (a small C protobuf implementation) and Bloaty (an ELF/Mach-O/PE/WASM binary size profiler).

Seattle, WA
Josh Haberman retweeted
This debugging technique should be common knowledge, but I run across it all the time. When an error message is confusing, by far the most practical method to figure it out is to: 1. copy the file to a new file, save the original 2. delete code until the message goes away 3. revert to the previous version that still produced the error 4. goto step 2, and delete something else 5. continue until you have the minimum piece of code that generates the error This usually clears up the understanding of the issue. The D "dustmite" program (created by crackerjack developer Vladimir Panteleev) can do this automatically. Recently, I was handed a program with a baffling error in it. I noticed it was loaded with templates, conditional compilation, irrelevant functions, and complex declarations. Deleting all that fluff out of it led directly to the problem. This is the most powerful debugging technique I know of. I use it all the time.
16
11
176
16,939
I'm getting more and more spam texts these days. I can imagine a future where texting platforms don't allow cold calls from unknown contacts without an extra token. The extra token could come from a mutual friend who shared the contact, or an in-person contact exchange.
2
312
Rust doesn't seem to have the concept of an internal/private crate. Any dependency of a public crate must also be publicly published on crates.io. There's no way to split a library into multiple crates in a way that is invisible to end users.
1
315
You can break a crate into private modules. But modules are allowed to have circular dependencies between them. So within a crate, there is no enforced discipline to prevent the crate from being arbitrarily tangled spaghetti.
1
228
I wish there was a way to factor code internally such that you can enforce a strict DAG shape when you want to.
175
File size of a trivial Python extension (Rust/pyo3): 401kB File size of the protobuf Python extension (C): 277kB The Rust extension has a single function that adds two numbers. The C extension implements all of protobuf. Both figures exclude debug info.
1
2
355
When I inspect the Rust extension, a lot of the file size seems to come from Gimli (DWARF parser), backtrace code, and addr2line. In other words, debugging functionality. Maybe this means that pyo3 will have amazing output when something goes wrong. Here's to hoping.
1
233
My biggest takeaway from Rust so far is that borrows should be relatively short-lived. While it is possible to put references in a long-lived struct, it creates spiraling complexity and is overall not worth it. Rust wants structs to own their members.
1
5
Unfortunately this makes it more difficult to avoid copies and allocations. I'm rewriting some code to use Vec+indexes instead of arenas+references. It's working ok, but Vec is less efficient than an arena in multiple ways.
1
I hear C is adding new stuff like lambdas. Here is what I'd rather see: - musttail for guaranteed tail calls (clang.llvm.org/docs/Attribut…) - arithmetic with overflow checking (gcc.gnu.org/onlinedocs/gcc/I…) - uint128_t (or at least _umul128()) Less sugar, more low level capabilities.
1
1
7
More ideas: - *printf() variants that are *not* affected by locale - setjmp()/longjmp() variants that do *not* touch the signal mask - qsort_r() - dtoa() (print shortest string that will round-trip a double)
1
3
This is a fleshed-out version of my previous Twitter thread on the same subject:
It appears that Rust's "Sync" trait is equivalent to the C++ concept of thread-compatible: abseil.io/blog/20180531-regu… Sync does *not* map to C++'s concept of thread-safe. Example: Vec is Sync, but would not be considered thread-safe in C++.
1
1
It appears that Rust's "Sync" trait is equivalent to the C++ concept of thread-compatible: abseil.io/blog/20180531-regu… Sync does *not* map to C++'s concept of thread-safe. Example: Vec is Sync, but would not be considered thread-safe in C++.
1
2
Thread-safe in C++ means "allows shared mutable access". But Rust forbids this at the language level. So it would be useless to implement a Rust type that implements the C++ concept of thread-safe.
1
2
You can create a Rust type that provides mutable operations that can be performed on a non-mutable reference. If you also made such a type Sync, that would be the best equivalent of a C++ thread-safe type.
2
The ELF/DWARF naming scheme makes for some odd Google results when you're looking for technical information. I'm implementing Fission / split DWARF for github.com/google/bloaty. When I Googled "dwarf skeleton" I did not get the results I was looking for.
8
What can souped-up GPUs offer systems programmers who don't do graphics or ML? The latest M1 Macs have me pondering this question. The only idea I've come up with so far: test/verify lock-free algorithms by trying every interleaving. Like TSAN on steroids.
2