Woz gets some coverage in Steven Levy’s “Hackers: heroes of the computer revolution’from 1984, and he updated it in 2014. I try to reread it every year or so.
It’s fun to consider how C devolves into assembler. In my mind, C and its derivatives dissolve into 68K assembler as I’m writing or debugging. Thinking about code this way lets me get a feel for how all the bits all fit together.
It seems like a lost art to think that way. It’s disturbing to me how many candidates couldn’t write Hello World and compile it from the command line.
Everyone should spend some time with godbolt.org or better, the -save-temps compiler flag, to see how changes affect your generated code. Right now. I’ll wait. (Shakes cane at kids)
In the kernel developer world on the other hand, it's still very common to think about how the C code one writes translates into assembly. (Honestly, I think C should not be used much outside developing kernels anyway, and even there it's just legacy, but that's just personal opinion.)
But it's rough, and dangerous. Optimizers do a lot these days, and I really mean a lot. Besides completely mangling your program order, which includes shoving entire blocks of code into places that you might not have guessed, they also do such things as leveraging undefined behavior for optimizations (what the article is partly about), or replacing entire bits of code by function calls. (A compiler might make code out of your memcpy(), and vice versa; the latter can be especially surprising.)
If you care about the assembly representation of your C code (which kernel developers often do), you will spend a lot of time with the "volatile" keyword, compiler barriers, and some obscure "__attribute__"s.
But I agree, even with those caveats in mind, it's a very useful skill to imagine your C code as what it translates to (even if that representation is just a simplified model of what the compiler will actually do).
that is a poor way to handle UB as it introduces bugs (which are UB themselves). If a compiler detects UB, it should flag an error so the source code gets changed. compilers (or any software really) should never be maliciously compliant.
That's not what I mean. The C standard contains some rules that exist for the sole purpose of providing better optimization, and some of these rules give raise to undefined behavior. The compiler leverages undefined behavior by allowing optimizations to not have to care about code that exhibits such undefined behavior.
If compilers did not take advantage of this, then a lot of behavior would not have to be undefined in the first place. Undefined behavior isn't conjured up from a magical place, it was deliberately specified for a reason.
The subject of the linked article, strict aliasing, is a prime example of exactly that: Surprisingly strict rules for aliasing, giving compilers the opportunity to better optimize code that follows these rules, at the risk of breaking code that does not follow the rules in arbitrary and perhaps unintuitive ways.
Now, these particular rules are controversial, and the article acknowledges this:
If you read this document, you may find to your horror an awful lot of C code, probably code you have written, is UB and therefore broken. However just because something is technically UB doesn’t mean compilers will take advantage of that and try to break your code. Most compilers want to compile your code and not try to break it. Given that almost no one understands these rules, compilers give programmers a lot of leeway. A lot of code that technically breaks these rules will in reality never cause a problem, because any compiler crazy enough to assume all code is always in 100% compliance with these rules would essentially be deemed broken by its users. If you are using fwrite to fill out a structure, you are just fine. No reasonable compiler would ever break that code. The issue is not that implementations don’t give users leeway, the issue is that it’s unclear how much leeway is given.
Nevertheless, there are many other rules that are much more readily accepted where similar things are taking place.
>The compiler leverages undefined behavior by allowing optimizations to not have to care about code that exhibits such undefined behavior.
that's pure maliciousness. if the programmer has written code that exhibits undefined behavior, it should be flagged as an error so it can be changed to code that does not exhibit undefined behavior.
programs need to have one unambiguous meaning, and it should be the meaning intended by the programmer. if meanings can be detected as ambiguous or as not what the programmer intended, that should be flagged, not magically swept under the carpet because it's "faster".
The compiler generally cannot know when the program runs into undefined behavior, because of the halting problem. For detecting undefined behavior at runtime, there’s UBSan. It’s good, but it makes things slower.
or to put it another way, divide by zero is undefined behavior. do you think it should be trapped? or just optimized away so the program can get more quickly back to defined behavior...
I kind of share this feeling (I knew 68K assembler before learning C), but having spent ~30 years writing C, publishing some open source software in C, reading comp.lang.c and draft standards, as well as answering many C questions on Stack Overflow back when it was cool, let me tell you: it's not a good model any more (if it ever was). :)
C is specified against an abstract (not virtual) machine, and it matters.
All the talk about how undefined behaviors give the compiler right to shuffle and/or remove code really break the analogy with assembler, where most things become Exactly What You Say.
(Edited to add: Sorry, too long of a post here. I didn’t bother to renew my domain this year)
A timely piece I can relate to. currently starting my second week in a (US) hospital oncology ward after my 11th cycle of chemo. I was first diagnosed with stage iv colon cancer and after chemo, surgery, resections and stubbornness was NED from 2018 to 2025. The return is inoperable and I was given “six months to a year”.
I asked if I’d be in pain when death came, and he said that I wouldn’t likely be - it would just be feeling more and more tired. That’s basically what’s been happening.
The chemo itself hasn’t given me direct side effects like skin lesions or mouth sores, nor much nausea. The secondary effects on my kidneys (which were already doing poorly before this started) and liver (cirrhosis) plus the metastases in lymph nodes and lung leads to edema. Diuretics helped but flushed out my potassium, so there several months where they trying to balance those electrolytes.
Anyway, a lot of my swelling was reduced (and they took 4L from two rounds of draining my lungs) but for some ungodly reason my scrotal sack decided it wanted to play too, and became the size and consistency of one of those half size basketballs you can win at fairs. it’s so bad that I actually requested a catheter. The swelling makes walking or anything else really painful.
The oncology wing I’m in doesn’t seem soaked in the kind of depressing, institutional green malaise of slightly older hospitals but it isn’t a “nice place” to die (I don’t expect to do that this visit in any case). The older woman (70?) two doors down though - seems to be in constant pain and in and out of lucidity, shouting at everyone. Usually a phrase gets stuck on repeat for a few hours - the most heartbreaking was “mommy get my mommy I’m sorry mommy I’m a bad girl mommy stop it” yelled loudly for hours.
This is a generic hospital though. Memorial Sloan-Kettering in NYC has a patient day lounge and lots of projects for child patients and patients families. Still not even approaching the quality described
Sorry, rambling. Probably my way of compartmentalizing the anxiety.
The other thing I wanted to say is that I really liked Christopher Hitchens “Mortality” and that Terry Pratchett’s very relatable death character shows up in all of his books. My favorite quote is from “Small Gods” as Death comes for the protagonist at the very end:
> “Ah. There really is a desert. Does everyone get this?” said Brutha. WHO KNOWS? “And what is at the end of the desert?” JUDGMENT. Brutha considered this. “Which end?” Death grinned and stepped aside.
Maybe I’m not afraid of death because as a devout atheist - well yea, we all get to do that at some point.
The quote that really has stuck with me was also from Pratchett:
"What can the harvest hope for, if not for the care of the reaper man?"
This caught me in two ways:
1. Death is the release. Whatever suffering you're undergoing, it won't follow you into whatever comes next, even if that is absolute oblivion. The relief would be welcome, I assume. So that's at least one positive way to look at it.
But moreso:
2. Everyone's death is individual and special. The process of getting to it is different for everyone, and the journey is just as much a part of the process as the destination. It isn't something to fear, because you cannot stop it, but it is something to consider as you move through your life.
Cancer is the fucking devil. I, myself, have been lucky enough to avoid it for now, but we spent the last year with my father and lymphoma. It's a fucking nightmare of cancer treatment and chasing side effects from the cancer treatments until the end. He chose to die with hospice on the family farm; it wasn't the most dignified death due to the symptoms of his cancer, but it was peaceful and with family/friends. So that's something.
His treatment didn't really bother me, and his process didn't really depress me; it was the people like the older lady in your write-up that really stuck with me. In his first month on the cancer floor, his across the hall neighbor was just like that. Her only lucid moments were either screaming in pain, or nonsense phrases on repeat from what I assume was her childhood.
Terrifying.
I hope that your life goes well all the way to the end. I genuinely do not know what to say other than that.
The only reason I disagree is that L&L jumps in with some very well established characters that had been built up earlier. But I do love his (historically accurate by lore?) description of elves. He put a lot of research into re-establishing the myths and lore of his little corner of the world.
(Along those lines I would also recommend Susanna Clarke’s “Jonathan Strange & Mr Norell” which builds its own parallel history set in the early 1800s Britain, with Fairies taking the same role as elves in discworld.
I think Susannah Clarke is the only living author I can think of who would inspire the same enthusiasm from me upon news of a new book from them. Alas, she is not quite as prolific as PTerry :)
Mustn't grumble though, it's not like Jonathan Strange was a pamphlet!
I love discworld and prosetyilize its virtues when and where I can, but two thoughts about this:
1 - why not both?
2 - via MST3K “If you're wondering how he eats & breathes, And other science facts...(la! la! la!) Then repeat to yourself its just a show, I should really just relax...”
I’m no longer NED from Stage IV colon cancer (first DX 2014), and now it’s returned and inoperable. I was given an option to add Cetuximab which I’d had previously- but the side effects from that were so bad for me that it absolutely isn’t worth it to me to add a few months, but live in misery.
This is absolutely the way. My interviews are conversations with someone that I want to work closely with, and while leet code might be an interesting lunch conversation it’s not going to be part of any of our day to day work (c/c++/swift/obj-c)
“Instead of monitoring volcanoes, what Congress should be monitoring is the eruption of spending in Washington, D.C." - Governor Bobby Jindal, Feb 24 2009 in his party response to Obama first address to congress.
“Monitor my Beer” - Mount Redoubt in Alaska, March 22, 2009, erupted.
The Wikipedia page details some of the effects of the eruption (air travel, oil production, etc) and like any. such natural disaster multiple government agencies were involved in recovery.
I always end up thinking about this when republicans pick stupid examples of government waste. Best of luck to you.
When you’re refactoring a system (which is really what he’s claiming to want to do) you don’t just delete the repository and start with main(). You figure out where the edges are, how they fit together, where are the Chesterton Fences and how can we protect them until they’re understood. A/B unit testing.
This takes a non-zero amount of time and it takes careful consideration by subject experts.
I can’t really speak to your hopefulness of good intentions - as a parent that relies on government agencies to help my special needs child with the tools she needs, I see no hope here.
What does success look like? How long should the chaos and pain last before you’re beyond hope? Will there be remuneration for people that are materially hurt by this scorched earth policy? How will you be hurt, personally?
I generally agree with you, but I have worked with many balls of mud that actually can not be understood even with experts and research without an unreasonable amount of time. Things like a program that runs in a database that was bought from a vendor that has since gone out of business, and the program ostensibly formats some rows and puts them into another table, but we don't know and can't know if anything else is actually using it because observability is not a part of this product, and we can't reach anybody who actually was involved in making it or setting it up. In these cases, a scream test is easier, faster, and more effective than "proper" research. And nearly the entire system is built on these inscrutable processes that nobody understands.
Sometimes it involves people, too. I did consulting work at a company that maintained an entire department of dozens of people who did nothing but mechanically opened spreadsheets that were dropped into a share, copied a specific set of rows from them into another spreadsheet, and then copied that spreadsheet into another share. It turned out the entire process was redundant, because what it was built to temporarily fix had already been permanently fixed elsewhere, and they still kept growing this useless department for years. Happily, the majority of these people were reassigned rather than fired.
For a collection agency, breaking these things is temporary pain. For a government, it can be deadly for constituents.
> I can’t really speak to your hopefulness of good intentions - as a parent that relies on government agencies to help my special needs child with the tools she needs, I see no hope here.
I am really sorry to hear that. It's not a good position to be in. I have a trans child myself, and I am also worried about being able to care for them in an environment that is increasingly hostile. I've spent weeks of this past month depressed and panicked over the current "governance". I'm just trying to cope, and sometimes that involves a bit of denial.
> What does success look like?
Don't get me wrong here. No success is possible. If their intentions are good, they're still destroying things that will kill people and take decades to repair. There will likely be no remuneration. I'm just hoping for the outcome that is least bad. I have zero hope of anything good resulting.