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).
@lemire In my experience with fast FFI APIs, VMs will often have an option like this. For example, in Dart you can mark a function as a "leaf" https://t.co/5ImYEto3DJ
@LewisCTech The compiler should absolutely enforce it, but an escape hatch "import private" seems entirely reasonable. Companies/projects can ban it as they see fit.
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.
@filpizlo I came to this conclusion when I wanted to systematically fuzz a C API. I thought hard about what kind of annotations (lifetime, mutability, etc) that you'd need to specify when a set of calls was valid.
Eventually I realized I had reinvented parts of Rust.
@filpizlo Yes, the pattern only works to fuzz safe APIs. Once there's a call to an unsafe API, all bets are off.
This limits the places where this technique can be applied. But in cases where you can wrap the unsafe API in a safe one, I think it's a pretty powerful technique.
@filpizlo A safe Rust API formally defines the set of allowable uses, so you can just generate arbitrary programs that call safe APIs and any resulting UB is a bug by definition.
@filpizlo The most important thing you get IMO is that safe APIs can conceptually be fuzzed systematically.
You can't systematically fuzz C APIs, because a crash could just mean you were holding it wrong (ie. violating invariants that were communicated informally in comments).
@zack_overflow In that article we show that this technique can nearly match some hand-written assembly Mike had posted as an example of how efficient hand-written assembly can be.
@zack_overflow That's not the end of the story though! Later a colleague and I developed a technique for getting better code out of the compiler for interpreter main loops: https://t.co/bvrdL1vs47
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.
@sophiajturner "What if instead of having to track every piece of memory's lifetime separately, we let groups of related allocations share a lifetime?"
When I read this it sounds exactly like an arena.
@sophiajturner This seems like it could potentially address one of my biggest pain points with Rust -- lack of good arena support: https://t.co/Vg60BfCvg2
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 https://t.co/1MO6kmo5hr. There's no way to split a library into multiple crates in a way that is invisible to end users.
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.