Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
I Implemented /dev/printerfact in Rust (christine.website)
164 points by todsacerdoti on April 17, 2021 | hide | past | favorite | 88 comments


> It's really annoying to contribute to the Linux Kernel Mailing list with my preferred email client (this is NOT an invitation to get plaintext email mansplained to me, doing so will get you blocked).

Heh. I really wish the kernel list would detect that a post has valid text and html content and just throw away the html rather than rejecting the whole thing. Plain text is, sadly, not a first class feature of most non-terminal email clients these days.


Every single gui email client I tried out a few months ago let me send plain text email. Some would not send HTML email though.

I suspect the author of TFA is using a webmail client, but as they did not state which client they are using, I cannot be sure.


Both gmail and outlook (web version) can be configured to send text/plain, I have it set in such a way.


Surely in the preceding decades someone has written an explicit LKML client, that, rather than implementing email and encouraging you to post to LKML, specifically implements the much narrower spec of the locally acceptable post/patch formats. `git send-email` really cannot be the apex of open-source contribution tooling evolution, can it?


At the company I work for they invented a whole new process (yes, it's as bureaucratic as it sounds) for the two people who do Linux kernel development.

Because the LKML really doesn't like the standard corporate disclaimer (not just too long, but also not separated by "-- "), but company policy mandated it and company's mail server adds it automatically.

So these two colleagues got special IT treatment: the disclaimer is turned off, but they now got the obligation to manually add it whenever they mail somewhere external that is not LKML.

I certainly don't fault LKML, but I feel amused a little bit.


> this is NOT an invitation to get plaintext email mansplained to me

That person can reassure herself, there are just as many women know-it-all-better-than-you as there are men, arrogance and condescension are sadly not strictly male traits.

It tends to more often be guys in the tech world, sure, but then it's just https://xkcd.com/1138/


This reads like "I was not allowed to mansplain email, but at least I can mansplain mansplaining".


Classic kafkatrap. Not very interesting and, if anything, the desperation makes you a seem a little suspect.


So no counter argument then?


Would any woman kindly explain how you configure your email client to automatically send plain text emails to designated addresses? It seems sex is a filter here.


Odd to see this casual sexism thrown in at the end of a technical article. Imagine if I just randomly threw in how long women take to get ready or something at the end of a technical article. It would be completely bizarre and my sanity would probably be called into question.


Almost like this is something she's experienced before, and this is a preemptive attempt to stop it from happening.

Edit: for example, hn/item?id=26847629. "oh you probably have no idea how to do this, right? let me walk you through it"


Something anyone can do without sexist language. It's really not difficult.


I don't much care for the term "mansplained", but I think it's a stretch to say it's sexist language. It's a simple colloquialism that refers to a well-known phenomenon.


I can't think of a single bigoted pejorative your "simple colloqualism" statement would not also apply to.


Frankly I think this is a pretty good refutation of my comment.


Until they added that line I didn't know the gender of the person writing the article. Explaining something to someone who looks like they don't know something has nothing to do with gender. That they associate it with gender is on their end and shows their bias.


The phenomenon of fashionable buzzwords?


It's not. Sexism, like racism, is prejudice + power.


Shouldn't HN participants be better at math?


Can you link a dictionary definition for either of those words, please?


How convenient.


Really funny to see stuff like this on hackers news.

Liberals arts majors appropriate mathematical language in an attempt to appropriate mathematics' reputation. Why is racism "prejudice + power" in this philosophy rather than "prejudice AND power"? It's because liberal art majors know that the lay public is more likely to believe mathematical conclusions than e.g. psychology or sociology or critical race theory conclusions. So they wrap their race theory arguments in mathematical language in order to trade on mathematics' sterling reputation for rigour and correctness.

It's always funny to see things like this on hacker news because well... There are a lot of mathematicians here. We know what "plus" actually means, and well, there's no sense in which "plus" fits.


If you're being sarcastic, nice job, if not, this meme is old and needs to hurry up and cease to exist.


So when you use a word, it means just what you choose it to mean, and we don't know until you tell us?


OT question: do you have news.ycombinator.com DNS-mapped to `hn/`?


Nah, I just didn't think it was necessary to put the full url since it was in the same thread. Idk.


Do you honestly believe this is something only men do? You don’t think there’s even a chance that maybe the existence of the “mainsplaining” concept is self-reinforcing, since every instance of a man doing it will be further evidence it exists (confirmation bias), other cases will be ignored, and anyone who questions it is socially marked as incel or MRA-adjacent?


How do you know, and why do you care, about the sex of the commenter?

Also, how sad that an offer of teaching is rejected with such bitter contempt. I have absolutely relished the times in my life when someone has explained something to me. That's how I learn.


When you're typing, you don't have to press the Caps Lock key twice for every capital you want to type. You can simply hold the shift key to get a capital letter, instead – or get a real keyboard.


Nice try but giving me completely unrelated information out of the blue is not what is under discussion here. If you had corrected me grammar or something, I would have been thankful.

The biggest problem here is people treating others how they would be treated. That's right, the problem is people following the golden rule. People explain things because they themselves appreciate explanations. Maybe other people need to be more empathetic and understand that these explanations are coming from a good place.


When somebody says “please don't explain this to me again, because I know how to do it” and people explain it to them, that's clearly not following the Golden Rule.


Fuck furries. Block them on social media, preemptively if you can. You won’t miss much from walking away.

This my comment needs to be downvoted but because it must be said and this will be downvoted anyway I have no problem making their life silently harder. That is the way they are playing this game.


Please don't post in the flamewar style to HN.

Also, please follow the site guideline that asks you not to go on about downvotes—and all the other guidelines too: https://news.ycombinator.com/newsguidelines.html


> I really wish the kernel list would detect that a post has valid text and html content and just throw away the html

Because. https://stackoverflow.com/questions/1732348/regex-match-open...

Honestly, I am not trying to put on my old-man hat, but I despise anything other than plain text in email. I agree with the KML. Email should not have binaries, html, tags, etc... of course, M$ and others will happily render them, so why not, right?


Email can have multiple parallel payloads in different formats (see MIME). It's part of the spec, not a hack.

The OP is suggesting that if LKML gets multiple payloads where it can understand one of them it just selects the one it can understand. This is what other text-only clients do.

They're not suggesting parsing html into text (tangentially, if they were, there are much better approaches than the one you linked. One of the most commonly used ones is originally by Aaron Schwartz https://github.com/aaronsw/html2text )


I'm kinda curious which client makes writing plain text emails hard though.


Article author here. Gmail and Apple Mail (macOS/iOS/iPadOS). I had to install aerc on a server to subscribe and post to the list.


Hmm. I usually have no problem sending to lkml using iOS’s mail app. Gmail also works if I tell it to format as plain text, but the editor is all kinds of buggy in plain text mode.

FWIW, I don’t subscribe to lkml. Instead I point thunderbird at lore.kernel.org’s NNTP feed for the rare occasions in which I need to reply to an on-list message.

To the extent that the list’s rules make it hard to get feedback, I consider this a problem. The whole mailing list is in the middle or a giant migration, and I’ll see if I can convince the new overlords to be less strict. (I usually get Linux email directed to me via MAINTAINERS, so this issue doesn’t affect me personally too much. The x86 alias isn’t part of vger and does not have the text hangup, at least to my knowledge.)


Apple Mail has a drop down menu to convert the mail to plaintext. Format-->Make Plain Text, it's even got a hotkey CMD+SHIFT+T. You can even default it to be in plain text under Composing settings in the Preferences.


I don't post to this specific list, so there might be weird issues I'm not aware of but...

Gmail has the plain text option behind the 3dot menu in the bottom right corner. Apple Mail deserves to die a fiery death and I refuse to support it but "Format" -> "Make plain text" *may* send a plain text message, or not depending on the OS X lottery. You can force Apple Mail with "Preferences" -> "Composing" -> "Message Format" -> "Plain Text" to compose plain text messages. Or you can use an actual mail client.


> Or you can use an actual mail client.

An "actual mail client" is any mail client that speaks SMTP. This "use a real X" or "real programmers always do X this way" stuff is why many tech communities are considered hostile and toxic, especially to newcomers. It's childish in personal settings and unprofessional in work settings.

The funny thing is that most of the people who continue to hold these attitudes weren't even around or on the internet when it was slow and expensive to sling around rich text or binaries. I mean, I was born in the 80s and got an account with my local ISP in the early 90s, after spending a few years hanging out on BBSes playing door games (anyone remember Virtual Sysop?). I agree that binaries or anything other than plain text was a pain to deal with back then; I had a 2400 baud modem, and even when I managed to get something faster, the phone lines in my area were too noisy to give me anything faster than 19.2kbps. And I'm not some greybeard either; I wasn't around when 300 baud was state-of-the-art.

But we've moved on from that time. It feels like the height of arrogance and gatekeeping to look down on someone who just wants to be able to italicize or bold some text in their emails sometimes.


> But we've moved on from that time. It feels like the height of arrogance and gatekeeping to look down on someone who just wants to be able to italicize or bold some text in their emails sometimes.

does rich email formatting still make a mess on mailing lists? most clients send a plaintext part, sure, but is it well formatted?

i think it's okay for a team to have customs, and even engage in a little gatekeeping. it's not that much to ask considering how much effort goes in from long time contributors.

last i heard github was adding features to actually make it harder to submit drive by PRs because exhausted maintainers were finding themselves further exhausted by uninvested contributors making superfluous contributions. (for events or name recognition or whatever)

that said, disrespect is never a good thing.


> last i heard github was adding features to actually make it harder to submit drive by PRs because exhausted maintainers were finding themselves further exhausted by uninvested contributors making superfluous contributions.

Which features?


good question what, if anything, they actually added... but search hn history for "hacktoberfest" for background...


>>It feels like the height of arrogance and gatekeeping to look down on someone who just wants to be able to italicize or bold some text in their emails sometimes.

I really disagree with this part of your post. Plain text is just that, plain text. By definition there is no bold and no italics. We can talk about the the weird technical limitations and requirements for submitting inline patches all night if you like but I'm not sure what you are even complaining about aside from the technical limitations of plain text emails. If you think this is gatekeeping and it keeps you from expressing yourself I don't even know what to say.


> An "actual mail client" is any mail client that speaks This "use a real X" or "real programmers always do X this way" stuff is why many tech communities are considered hostile and toxic, especially to newcomers. It's childish in personal settings and unprofessional in work settings.

Isn't it perfectly justified in "use the right tool for a job" situations? If someone tells me not to hammer nails in with a pair of pliers, I'd hardly consider it "unprofessional" or "childish". If tool A requires you to use tool B for interoperability, I would imagine a reasonable person would simply use tool B, and not complain about people being "hostile" or "toxic" for suggesting to do so.


I use a client that does make it easy, but I shouldn't have to worry about this. Mailing lists are basically full of people who use email in an exceedingly specific way no one outside of mailing list enthuiasts do anymore. I use a graphical email client, as do my coworkers, as do our customers. We don't care about top vs. bottom replies, plain text vs. email, etc. - those who do have lost touch with the average email user.


> Or you can use an actual mail client.

For those of you wanting an explanation of what I meant here, this is a perfect example of it. I do actually have aerc installed now. I just think it's annoying that I had to change my perfectly good workflow that is enough to get me hired at large companies for this.

> (this is NOT an invitation to get plaintext email mansplained to me, doing so will get you blocked)


Was my comment mansplaining? I'm genuinely curious.

Apple Mail sucks and I'm always shocked how many people think it's "good enough". All the Apple apps are barely functional but fall short when it comes to replace groupware (or actual standard compliant clients. Don't even get me started what Apple Contacts does to vCard).

>>I just think it's annoying that I had to change my perfectly good workflow that is enough to get me hired at large companies for this.

I don't get what workflow you are talking about.


The translation/context of the passage in the article was "look, I know how to send plaintext email, I just wish I didn't have to jump through these hoops, so please don't come and try to teach me how to do it" and that is kind of what your comment does.


Which is why I asked what the issue was and the author replied he/she was using Gmail/Apple Mail. I can see using the lkml with Apple Mail being difficult since Apple Mail sucks but sending plain text mails with Gmail should just work and nobody should have to change their email client if they are fine with using Gmail.

Even not using lkml, it's a standard conforming mailing list that (presumably) will accept any plain text mail just fine and I do not see why anybody would need to install a separate email client like aerc just to use this mailing list. So, to me it read "I know how plaintext emails work but for some reason my workflow does not work so I changed it to include something else" and I was curious as to why... Curse me for asking? Curse me for damning Apple Mail? Idk... I guess curse me for being curious and trying to help a fellow nerd out while shitting on Apple Mail at the same time.


I don't want to make like, a federal case out of this, but since you're asking:

She said, in effect, "don't explain to me how to do plaintext email, I don't need/want that," and though your comment is in small part calling out Apple, it's mostly an explanation of how to do plaintext in Mail.app and Gmail, and then a suggestion to not use it because it's not "real." So it's largely a "let me show you how to do this right" kind of comment.


This might be out of date, but IIRC GMail, in plain text mode, will break lines at 72 or 80 characters or something like that, which will mangle inline patches. LKML's policy prefers (requires?) that you send patches inline and not as attachments.


I personally send patches with git send-email. I used to do it by fighting with Thunderbird until it worked, but that got old fast.

Now if only git format-patch could more usefully infer the base commit...


Which is pretty interesting. Apparently Outlook mangles inline patches for the lkml as well to the point that they are unusable and that would have been an interesting talking point in and of itself.

But apparently talking about this is not in scope of this post and trying to piece together the issues just gets you downvoted so... Thanks for your advice, I was not aware that Gmail clobbers plain text mails, I guess there is more to it then getting your mail client to send plain text email. Maybe some explanation of the subject would have been nice.


I am going to over-explain in detail in my reply. You may already know this but I know we have a lot of neuro-divergent folks, people who have difficulty understanding social interactions, and similar on HN so perhaps it will be of benefit. I am in no way trying to imply that you or anyone else isn't aware of these factors. Nor am I trying to claim that my explanations are the full and complete explanations.

In your first post you said:

>I don't post to this specific list, so there might be weird issues I'm not aware of

So right off the bat you are declaring "I do not have the same problem as the OP". This is in response to a post where the OP said "I know how to solve this problem, please do not offer me explanations". So you jump in with admittedly no experience with this specific issue where someone explicitly told you they don't want your input... to give your input. That in and of itself is rude behavior. Especially when this is something anyone with a moderate technical background can figure out with a Google search so it isn't likely to be unique or useful.

Even if you didn't intend it (and I'm sure you did not!) the implication is that she's non-technical so she either wouldn't know what to search for or would have a difficult time figuring out the instructions so your input will obviously save her time and effort. Because she is technical (as is obvious because she's talking about emailing the Linux Kernel mailing list which is an extremely geeky thing to be doing) and perfectly capable of solving the problem herself (as she indicated in the post) it can sometimes seem like you're being sexist by assuming otherwise. Obviously this is not the intent of everyone (or even most) people but the OP has no way of knowing that and has likely experienced similar behavior that was later proven to be driven by sexism. So it leaves her in a difficult spot: how many people who ignored my request not to explain the solution are doing it because they are rude, how many are doing it because they think "she's just a woman, she won't understand these things", and how many are doing it just to troll on purpose? And if she replies in a negative way is this one of the men who will start harassing her, trying to dox her, or stalk her to "put her in her place"? That's a small percentage of men who do that but she has no way of knowing which ones are the unhinged ones and which ones aren't.

The other major problem with this behavior is that it is exhausting when it happens frequently. It becomes tiring to have to politely explain yourself over and over. Any human on the planet in this situation - unless they have super-human levels of patience - will eventually stop offering fully qualified explanations. When women do this they are often perceived negatively or as having a bad personality if they try to enforce boundaries or request respect (see below about violence).

The reason it is called "mansplaining" is partially because it is something done by men more frequently because growing up girls are often socialized to be as quiet and unobtrusive as possible while a subset of boys are socialized to believe everyone should listen to their thoughts and opinions. Obviously that is not always the case. As a subject matter expert and man myself I don't have a big problem with the term because while I have had people "mansplain" how a product I work on works (incorrectly I might add) I have never had a woman attempt to do that... it is exclusively men who try this with me. Millions of people use it so it isn't a completely tiny sample size, but I do admit it is anecdotal.

As they grow up women are far more likely to have some random man they don't know get angry and physically grab them or threaten them if they tell the man they don't need his input or they want to be left alone. This is something I've witnessed happen to women many times while never having seen the opposite (a random woman a man does not know getting irate, in that man's face, screaming at him, or physically preventing him from leaving and/or hurting him because he politely told her he wasn't interested in her input. Emphasis on "random" person here, not someone known to the victim). How does this relate? One of the reasons women are socialized to always be nice, polite, and quiet is because of the risk of harassment or violence from random men she does not know. Do most men do this? No. But enough that it is quite common. If you really took the time to listen to the women you know (and didn't try to argue or excuse away the behavior) most of them would have at least a few stories like this. Then survey the men you know to find out how often they've had anything similar happen to them. Again emphasis on random strangers, not ex partners, coworkers, etc. (For my own pre-emption posting that you're a man and it happened to you once is not helpful. Obviously it happens, it is just far less common. It is still unacceptable regardless of gender).


Be careful. Writing out steps to send email in the way the maintainers of the Linux kernel desire might be deemed as manspaining. You wouldn’t want to get blocked, would you?


The author already explained upthread that she knows how to do that and has a working setup to do so. But that process is onerous because LKML’s workflow is technologically backwards. (That’s my claim, not hers.) Assuming that someone with that kind of technical chops is too incompetent to Google “plain text gmail” is pretty disrespectful.


> Email should not have binaries, html, tags, etc.

That's like saying postal mail should only allow you to send letters typed on a typewriter.

This "email should be plaintext only" idea was reasonable when bandwidth was limited and metered and expensive. While that's still the case in some parts of the world, most of us here are not in that situation. If you, personally, want to reject emails that have attachments or are not plaintext, you're free to do so, of course, but don't suggest that the rest of us are doing it wrong.


I enjoy christines style of writing very much. I can only recommend it to anyone out there interested in dev ops, rust or nix. Her narrative style and different characters may be a bit jarring at first, but I got used to it pretty fast.


On the other hand, I found this style of writing detestable.

> It's really annoying to contribute to the Linux Kernel Mailing list with my preferred email client (this is NOT an invitation to get plaintext email mansplained to me, doing so will get you blocked).

Get over it. The maintainers of the project have to keep in mind tens of thousands of contributors from all walks of life and I wouldn’t miss a single thing by being blocked by this author.


> "Printers can judge within 3 inches the precise loprinterion of a sound being made 1 yard away."

> Printer facts were originally made by a very stoned person that had access to the Cat Facts API and sed. As such instances like indiprintere are features.

I love this.


It took me a sadly too-long time to realize that this had nothing to do with any printer API.

Like, I read the whole post, and all the comments here on HN. And only _then_ did it dawn on me.


Author of the post here, I love those kinds of slow burns. I'm really glad you managed to experience one.


> Printers have been domestiprintered for half as long as scanners have been.


> Printer facts were originally made by a very stoned person that had access to the Cat Facts API and sed. As such instances like indiprintere are features.


https://printerfacts.cetacean.club/ Follow the various links. See if you can jump to the same conclusion as me regarding who forgot to anchor their regexes when playing with Cat Facts 8)


It's a feature.


Note that the source JSON data is corrupted. Basically somebody has some UTF-8 encoded data but they've told a machine it is Latin-1 (ISO-8859-1) and then it has produced the Unicode escaped output as-if that was true, so for example where there should be a single Unicode codepoint for a dash, there is instead three nonsensical Unicode codepoints for Latin-1 characters you didn't mean.

You could probably fix that inside the driver, but likely the owner of the JSON file should just fix it to not be gibberish.


I love this so much! It’s a really helpful demonstration of how to do Kernel stuff in Rust with Nix, using a ridiculous shitpost idea, and it’s written in a very enjoyable way. I’m just annoyed that I hadn’t run across their blog before now.


this is one of my favorite Nix blogs out there! the NixOS systemd timer one was great - I used it when I had to make my first timer and it was the best resource out there.

The narrative style made it a fun read too. Feels like someone explaining things to me personally off the cuff.


Author of the post here. That's the style I try to go for, that balance of serious, shitpost and interesting side notes you'd get from DMing a particularly sarcastic coworker that means well on Slack. The Mara interludes add into this because it allows some blending in of the Socratic method to make some more complicated things something closer to a dialogue. I have plans to take this further though. If you have any suggestions on how I should skew these plans please let me know.


Is Mara meant to be Mara Bos of Rust twitter shitposting fame? It almost fits.


I have never heard of that person. Mara's name comes from a DnD like session for a trollish character. In hindsight it's quite ironic that Mara is now used to help explain things.


Nice article. But I'm sad about how some morons reacted about the last paragraph.


How does this /dev/printerfacts react to partial reads? Does it mix multiple facts?


If your buffer is too small it will just fail. It ends the file after a fact is returned. I think I forgot to shout that out in the article. Oops.


Ah yes because `write_slice` fails. That's actually nice and quite ergonomic with the ?.

Well, thanks for the quick intro for how to actually use this new rust-in-kernel stuff and also for showing how to easily test it with nix. That's a great article, so thank you for sharing!


the use of the neopets-like characters is kind of distracting


I know I am being pedantic, but it is a bit weird to editorialize "How I Implemented /dev/printerfact in Rust" to "I Implemented...", make the author come off a little more boastful than they intended to.


The author implemented /dev/printerfact. Someone else came up with printerfact. If someone said they implemented /dev/null I wouldn't think they came up with the concept of null.

Also printerfact was implemented by a high person with sed and a list of cat facts. While excellent, it's not an incredible achievement we need to defend the integrity of.


HN strips out prefix ‘How’s by default. I guess that was applied here as well...



These titles you linked are re-edited to add the "How" back.


"I reimplemented" might be better


Author of the article here, I think "I Implemented" is the least wrong way to phrase it. I didn't reimplement it because it didn't exist before I implemented it.


Didn't realize it was only a web thing before - that's fair.

Edit: I hadn't had my coffee yet, reading comprehension wasn't yet active. :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: