An Algorithmic Lucidity

a blog

September 2016

Concerns II

(Previously.)

"I'm concerned about the socially-undesirable implications of the correlations documented in these published studies, which seem consistent with my own observations and personal experience."

(studying them) "Hey! These correlation coefficients are not equal to one! In fact, all of them are substantially less than one! How dare you try to construct predictive models about how the world works, when you yourself admit that your model won't assign literally all of its probability mass to the exact outcome?!"

(in despair, as if realizing that the nature of reasoning as an adaptation for arguing with conspecifics in imperfectly-deceptive social organisms implies that no one can ever have a serious, grown-up conversation about anything important) "Just kill meeeeeeeeeee"

Wicked Transcendence II

went to the genderqueer support/discussion group at the Pacific Center again; showed up early to change into my Pearl dress (it would be a waste to only wear it once) and surreptitiously slip a copy of Anne Lawrence into the library

I think I mostly enjoy being the token conservative/TERF (um, relatively speaking); I say that my pronouns are he/him "because I don't perceive myself as having a choice in the matter" and probably smashed the record for most uses of the phrase biological sex at one of these

Focusing on the Important Things

"Maybe this is already clear, but I think that you're in something of a negative feedback loop where unmet social needs are affecting your interpersonal behavior in ways that are interfere with social needs being met."

"I still think that's a positive feedback loop, technically."

Bayesomasochism

Physical pain is the worst thing in the world, and the work of effective altruists will not be done until the last nociceptor falls silent and not a single moment of suffering remains to be computed across our entire future light cone.

But the emotional pain of discovering that your cherished belief is false, that everything you've ever cared about is not only utterly unattainable, but may in fact not even be coherent?—yeah, I'm pretty sadomasochistic about that. That's rationality; that's what it feels like to be alive.

RustConf 2016 Travelogue

(Previously on An Algorithmic Lucidity.)

sfo_reflections

The other weekend, excited to learn more and connect with people about what's going on at the forefront of expressive, performant, data-race-free computing—and eager for a healthy diversion from the last two months of agonizing delirium induced by the world-shattering insight about how everything I've cared about for the past fourteen years turns out to be related in unexpected and terrifying ways that I can't talk about for reasons that I also can't talk about—I took Friday off from my dayjob and caught a Thursday night flight out of SFO to exotic Portland (... I, um, don't travel much) for RustConf!

The conference itself was on Saturday, but Friday featured special training sessions run by members of the Rust core team! I was registered for Niko Matsakis's afternoon session on lifetimes, but I arrived at the venue (the Luxury Collection Nines Hotel) early to get registered (I had never seen socks as conference swag before!) and hang out with folks and get a little bit of coding done: my coolest Rust project so far is a chess engine that I wrote this time last year (feel free to go ahead and give it a Star!) which I wanted the option to show off (Option<ShowOff>) to other conference attendees, but the pretty web application frontend had broken due to a recent bug and my JavaScript build pipeline having rotted. I fixed it just in time for the lifetimes training session to start.

Every reference (I kind of want to say ampersand) in Rust code has an associated lifetime, the region of the program that that reference is valid for. Lifetime annotations (appearing in angle brackets like generics and starting with an apostrophe; by convention, usually named consecutively from the start of the lowercase Latin alphabet: 'a, 'b, &c.) in function signatures are used to distinguish between the lifetimes of different reference arguments, but the compiler has lifetime ellision rules that cover the 90% use-cases, so you can actually write pretty substantial Rust programs without actually understanding the theory, which is both practically useful and eternally shameful (for a programmer who is satisfied with not understanding something is not long for this world). Hence the training. (Exercises from the training sessions are available online.)

rustconf_swag

The point of lifetime analysis is to ensure that all references point somewhere valid; you can't (can't, the compiler won't let you) have a reference to a thing that outlives the thing itself. When you return a reference from a function, you can't be referencing something created by that function, because any such thing would die at the end of the function as it goes out of scope: a reference in the return type has to be a reference to something owned by the caller that was passed as an argument, but if there was more than one reference argument, it's ambiguous which of the reference arguments has to be outlived by the returned reference, which is why you sometimes need explicit lifetime annotations ...

Um, it's complicated. (Maybe this is just one of those things no one knows how to teach, and you just have to pick it up by osmosis or spend a week auditing the relevant part of the compiler source??)

Lifetimes are currently bound to lexical scopes, which are sometimes much bigger than we actually want, bigger than we could get away with if the compiler was smarter, so sometimes the borrow checker will reject code that a human can see is actually safe. Borrowing is like a compile-time readers-writer lock; you can have many readers or at most one writer at the same time. Consequently, when running into a spurious ("spurious") borrow checker error, Matsakis recommends separating your code into distinct query and act operations. The result of the query must not be a reference into the thing you're operating on (that would be holding the reader lock!) but it can be a value, or an index into the thing that you use as a kind of pseudo-reference. (I was reminded of how I was looking up how to implement graphs back in March because I wanted to implement Bayes nets and someone recommended using indices into a Vec as pseudo-references, but I thought that was hideous, so I ended up using Rc and RefCell sort of like in Nick Cameron's tutorial.)

There were a couple of pre-conf community events scheduled for Friday night: a Chef/Habitat meetup, and a hack night for the new Tokio async IO project. I decided to only go to the hack night and wander around downtown Portland for the few hours after the lifetimes session and before the hack night. Some people were protesting prison labor practices at an AT&T store. On a whim, I visited the famous Powell's City of Books—it's very large and has rooms mostly named after colors!—the math section is in the Pearl room! On a further whim, I bought a book! You can't prove that the book isn't completely unrelated to the world-shattering insight that has been eating my life for two months! Then it was time to hack on Tokio ("... I'm on my way; in my brand new auto, it's not so far away").

So, I don't really understand Tokio. I think it's supposed to provide a new, better high-level async IO story for Rust? After procuring some help from the knowledgable hackers around me ("Cargo sucks! ... just getting your attention"), I was at least able to run some example code (there were some dependency problems), and I submitted a pull request suggesting that the appropriate cargo run --example command be mentioned in the README. Out of despair and determination to get something nontrivial done at hack night, I submitted a pull request for vector iteration to rulinalg, the linear-algebra library that I was already familiar with from having contributed to its code before it got pulled out of rusty-machine. (My pull request has some lifetime annotations in it, but even after the afternoon's training, I still felt like I was just imitating examples and slapping tick-a on things.)

The next day was the actual conference! I got to meet my hero Julia Evans and she gave me a paper (!) zine.

Matsakis and Aaron Turon gave the opening keynote on the remarkable year Rust has had: 175 new features have been stablized, and we have more exciting new features on nightly, like specialization, impl Trait, ?, custom derive, and (now shining brightly in orbit) MIR.

There were some technical difficulties getting the projectors hooked up to the laptop for the next talk. Steve Klabnik said that the break was brought to us by Apple, who is not sponsoring us, but really wants us to have a long break between talks. "They should have written it in Rust!" I shouted (as if someone had to say it); Steve shrugged.

compiler_says_no

The projector issue got fixed and Liz Baille, developer at Tilde and graphic-novelist, gave a really funny talk in the form of an "illustrated adventure guide" to Rust ("You might have noticed how clean and beautiful Rustlandia is, and you might have also noticed that there are no garbage cans anywhere").

Geoffroy Couprie spoke about getting Rust code into the VLC media player: rewriting existing C code is hard, he says, but it's doable in Rust today.

Suchin Gururangan and Colin O'Brien spoke about a machine-learning classifier that they built to detect posts about the Rust video game that were erroneously posted to our /r/rust subreddit instead of /r/PlayRust. ("Ability to copy/duplicate maps" was a cute example of a post title the classifier wasn't very confident about—maps could be game maps or hashmaps!)

Without Boats is working on notty, a new terminal that aims to improve on the reigning standards (much of which ossified in the days of line printers) with better Unicode support and the ability to display images. Boats says that notty uses many more traits than is usual for the Rust ecosystem. For example, consider a write method for writing something into a terminal's grid, which could either be a normal character, an extra-wide character, a combining modifier character, or an image. The original, intuitive solution was for write to take an enum (with variants Char, WideChar, CharModifier, and Image) that matches on the thing being written, but that was problematic because the method quickly became enormous, and each kind of data had to take a &mut reference to the struct representing the entire grid. Whereas after a refactoring, there is instead a Writer trait that gets implemented each type of writable thing. Boats followed up with a case study about separating a terminal into panels ("Let's say you're using a text editor like Vim, or the other one") and finished with an exhortation to "MAKE RUST TRAIT AGAIN".

Alex Crichton gave a talk titled "Back to the Fututes". Maybe I don't have much to say about this one for the same reason I didn't get much done at the Tokio hack night??

Raph Levien gave a talk about Xi, a modern editor dedicated to being performant (as operationalized by never blocking). It uses ropes and the fact that strings under concatenation are a monoid. Levien says that regex-based highlighting is not the future because actual lexing is faster, and that people should stop sneering at him for using JSON-RPC, which is really well-optimized and readily available ("You talk about batteries included; this is a AA battery, not a CR123A").

Josh Triplett gave a talk about what he learned about the Rust RFC process in the course of adding untagged unions (and the hope that they provide) to the language. There was a bit of feedback from the sound systems as Triplett began to speak about the application that motivated his interest in Rust: virtual machines, which are used for containment and isolation ("which would be useful in audio systems as well"—laughter from the audience). Buffer overflows were written about in 1972, first exploited in the wild in 1988, and we're still talking about them in 2016. Rust is interesting because it's actually a credible replacement for C++. Tagged unions (we call them enums) are ubiquitous in Rust, but it's useful to have untagged unions for interfacing with C code that uses them; currently, you need an unsafe block and nasty things like mem::transmute to deal with C unions, and we'd prefer to have a safe construct for this. Unfortunately, Rust's backwards-compatibility guarantees mean we can't strictly use union as a keyword, because there could be existing code that uses it as a variable binding. But it turns out that it's possible to make the parser smart enough to recognize union as a "contextual keyword": we can use it like a keyword because its position in the syntax tree is sufficient to distinguish it from union being used as a variable. The discussion threads on RFCs can get kind of unwieldy, so people make summary posts that describe the state of the debate so far. Implementation isn't part of the RFC process (although it can happen in parallel, with the understanding that the RFC can change); a tracking issue for implementation is opened when the RFC is approved. Untagged unions are now available in Nightly Rust behind a feature flag!

Finally, Julia Evans gave a talk on "Learning Systems Programming With Rust" and how Rust makes improbable programs possible (you could write correct C, but you won't).

And that was RustConf! The next day, since my flight wasn't until evening, I also walked across some kind of bridge and visited PDX Maker Faire since I happened to be in town and someone I met on the internet was there to show off this duplicate of a set piece from the Stranger Things television series that they made with an Arduino.

My flight back to SFO was delayed a few hours due to some sort of technical difficulties in Chicago. As I sat waiting at the gate, beginning to draft this post and trying not to let my soul be consumed by the world-shattering abyss induced by cruel apprehension of patterns that innocents were not meant to see, I felt a deep sense of gratitude that I should have the privilege to participate in such a brilliant, welcoming community as that which surrounds the Rust programming language and its mission to bring systems programming to the masses in this 21st century!

The Roark–Quirrell Effect

Education increases altruism up to a point (as you increasingly understand that other people are real too and have moral value for the same reasons you do even if you don't experience it from the first person), until you accumulate so many seemingly unique insights that the entire rest of the world looks so abominably stupid that you no longer want to waste a single precious dollar or minute on the concerns of these creatures that can't even see the Really Obvious Thing.

(Or, maybe this is just a form of mental illness specific to high-psychoticism males that can be cured with the appropriate drugs. We'll find out!)

The World By Gaslight

In the oneiric methodlessness of my nightmare, I am a lieutenant commander posted to the Glomar Explorer; I am pacing the deck while opining that taking the correct, minority position in a scientific controversy necessarily feels just like early-onset dementia (which I can't help but notice makes a perfect pairing with a late-onset case of the other d------ia word).

Something is wrong with the ship's computer. Before I can figure out whether it has to do with HTTP Strict Transport Security or the Accelerated Graphics Port (it has to be one or the other), we sink, and I drown.

Is There Affirmative Action for Incompetent Crossplay?

So I was at San Francisco Comic Con the other day. I don't think I find conventions themselves to be as fun as a lot of other people seem to (I didn't even last all of Saturday at BABSCon 'fourteen and 'fifteen before getting ponied out and BARTing home, and didn't even bother attending this year), but I had never cosplayed before, and had been thinking lately that I have exactly the right body type to play Pearl from Obnoxious Bad Decision Chil—I mean, Steven Universe, on account of being my being tall, thin, white, and having a big nose. (She's even pretty flat-chested!) So I ordered the Pearl dress from Hot Topic (I maybe should've gotten the XXXL instead of merely the XXL), a pink (really should be more peach, but close enough) wig, yellow gym shorts, and pink socks; improvised a gem from medical tape and the bowl of a plastic spoon; and set off Saturday morning to catch the train to the city and a short walk to the San Francisco Marriot Marquis.

The con itself was about what you'd expect, with the usual events and the usual vendor hall. The part that I found striking (enough so that I'm bothering to blog about it) was just how many compliments and photo requests I got for my costume, wholly disproportionate to its actual quality. (I enjoyed the opportunity to ham it up, proclaiming "We are the Crystal Gems!" or singing a few bars from the extended theme during photo ops.) Since this was my first time cosplaying, I don't have calibration, so it's quite possible that I got the ordinary amount of positive attention given costume quality and character popularity, but I suspect that there was something more than that going on having to do with gendered cultural expectations.

Femininity in males is stigmatized more than masculinity in females; that's why I changed in the bathroom at the con rather than wear a dress on the train, and why I don't feel like including any photos in this post despite having shared them on Facebook (visibility settings: "Custom: Friends; Except: Family") and sent them in for the next Beach City Bugle cosplay compilation post. So incompetent MtF crossdressing is "loud" relative to men playing male characters, women playing anyone, and the competent crossdressers (who were clockable on the timescale of ten seconds, but didn't instantly read as "man in a dress" the way I did), and loud things that would be stigmatized in everyday life (probably even everyday life in the Bay Area) are celebrated at Comic Con. Thus, "man Pearl is best Pearl," as I was told by a young woman (who was cosplaying a male character), even after I insistently pointed out that the other Pearl was way better than me.