A barebones kernel in Nim

I’ve been fascinated by operating systems for a very long time. For someone who genuinely loves low-level programming, they’re the lowest you can get in our modern age, barring a few microcontroller applications. So I’ve spent the occasional weeks over the past 20 or so years looking into the field, wondering if there’s a way to make my mark on it. At the same time, I’ve been looking at ways to write those low-level programs.

Combining those two threads of research has led me to create Nim Limine Barebones.

What is it?

It’s pretty simple. This is a port of the Limine Bare Bones tutorial kernel to the Nim programming language. It doesn’t do much; it’s literally the “Hello World” of OS development. But it can be used as the start of something much greater.

Why Nim?

I’ve looked at a lot of different languages that purport to be suitable for low-level “systems” programming. I settled on Nim because I wanted to learn something new, but also because every other option has a flaw.

  • C is the gold standard for OS work, but it’s really a horrible language. Especially when you don’t have the luxury of an operating system to protect you from, say, filling every byte of memory with garbage.

  • C++ is one of my favorite languages anyway, but using it on bare metal is harder than you might think. A freestanding implementation has to throw out most of the standard library (i.e., the bits that make C++ worth using), so you’re mostly left with C plus classes.

  • Rust might be a decent language, but its syntax is as ugly as the politics of its developers. I’d never use it for an unpaid project.

  • Go, from all I’ve read, requires a hefty runtime to get started, and Google has no inclination to change that. It’s also a language I find annoying for some irrational reason.

  • D is pretty much the opposite of Rust in both politics and syntax. It would be a great choice if not for a bit of runtime you just can’t get rid of. Oh, and the fact that nobody can seem to agree on what, exactly, the language should be.

  • Zig looks okay, and I found it extremely interesting when I delved into it a few months back. Alas, it’s just too immature for production use, and the latest revisions of the compiler have completely removed some necessary options for bare-metal development.

Nim isn’t perfect by any means, but what I’ve seen so far makes it look like a good “better C” that doesn’t require too many hoops to get the runtime out of the way. For application development, it wouldn’t beat out C++ for me—things like multiple inheritance are just too useful—but at the OS level? Sure beats trying to write my own std::vector. (Seriously. Where are the minimal STL implementations to go along with mlibc?)

Why Limine?

Most OS tutorials are centered on Multiboot. After all, it is kind of a standard. Here, though, I went with Limine. It’s a little more obscure, and much newer; the project is only a few months old here at the start of 2023, as it is intended to replace the older Stivale bootloader.

Limine has a lot of advantages, in my opinion. It’s entirely 64-bit. It sets up a call stack for you, which mostly cuts out the need for assembly in the boot phase. Framebuffers are sensible, there’s an integrated terminal that can work until your own is ready, and it’s just nice in general.

That said, it does have its annoyances. It requires a “higher half” kernel, and that makes paging a necessity sooner than it should be. But the page tables Limine gives you are intentionally sparse. And for this project in particular, dealing with an array of function pointers is just awful. Surely there’s a better way.

Conclusion

All told, I’m happy with what I wrote. It’s a good start, and it fills a niche that nobody else was really looking at. Yes, there’s another barebones Nim kernel out there, and I took inspiration from it. I like to think I’ve provided a better starting point for myself and anyone who would like to follow in my footsteps.

Wrapping up

(I have a ton of gifts to wrap, so this is what I’m going to do instead.)

We’re almost to the end of another year, and this one has been a ride. Lots of ups and downs, in both the literal and figurative senses, which seems appropriate. After all, I went into 2022 thinking it was the last full year I’d live, so why not go out with a bang?

Twelve months later…I’m not sure of anything anymore. In some ways, the few good things that have happened in my life have made it worse. Stasis is death, and I was dying. Now I’m living, but it’s hard to start that when you’ve waited until you’re almost 40. Part of me wants to get things done. Another part wants me to turn my back on all of it. I want to give of myself, yet I also want time for myself. It’s a battle most people deal with years, if not decades, before where I am now, but age doesn’t always bring wisdom.

Still, I set goals for myself, and I think it’s a good time to look at how I’ve fared with them. Then, I’m going to set a few more for 2023.

The Great Works

I put forth my four Great Works at the beginning of the year, and I would say that I accomplished most of them.

First, Alana, the site I’m building for my “real” job, is coming along. It’s hit a few roadblocks here and there, and my dev team (such as it is) is perpetually understaffed for the tasks we’ve been given. Despite that, it’s a real site, and it has real users. If there’s any one problem I can see, it’s that the roadmap has far too many items on it, and there’s very little rhyme or reason to them. The perils of having a boss with ADHD.

Second, I spent a lot of time early in the year working on Technetism. In the past few months, I’ve backed off a little bit. That’s because I feel that the philosophy is sketched out now, and it just needs some literature and a few adherents. We’ll get to it, but I can truly say that I have created a school of thought that reflects my view of the world. The rest is just filling in the gaps.

Third, I ran for office. Okay, I didn’t have much of a campaign, and my opponent even claimed I had dropped out of the race the week before the election, but my name was on the ballot. People talked to me, talked about me. My name was on the tickers at the bottom of all three local networks. Best of all, my mere presence forced my opponent to campaign, something she hasn’t had to do in a decade. I came away with 28% of the vote just by offering a choice. If I can do it, there’s hope for everyone.

Last of all, I have to admit that I mostly gave up on Iconic. It has notes and a rough outline of where I want to go, but I just couldn’t put in the effort. I still believe that visual communication is a noble goal, that METI should be pursued, and that there is someone out there waiting for our call. If I have time in 2023, I may even pick up the project again. For now, this has to stand as the one true failure of the Great Works, but it was always the long shot.

Next up

Of the few goals I have in mind for next year, only a couple are really relevant to PPC.

Foremost among these is The Prison of Ignorance. I need to go back and edit the book, adding what I’ve learned about technetism through its development. I’ll also have to slap on a preface, an afterword, and all that. Other than those trivial minutiae, my first nonfiction philosophical tract isn’t too far away from completion. So let’s get it done.

Getting into philosophy and politics has also rekindled my interest in history and the things that make our Western civilization the greatest that has ever existed. To that end, I plan to read at least 12 of the so-called Great Books. This is a list of over 300 of the most influential works humanity has ever produced, and I regret to say that I’ve only truly read a small fraction of those. I plan to fix that.

I haven’t done much writing at all this year, so I also want to rectify that situation in 2023. I’d like to get On the Stellar Sea finished in draft form, as well as Pitch Shift. (That will be the first book I’ve ever written where I’ve actually visited the setting! Can you believe that?) Releasing Homeward From Afar is on my to-do list, as well as putting as many of my books as possible on a store besides Amazon.

On the development front, I’ve recently had an itch that I can only scratch by going back to Pixeme. This was a project I started a few years ago, and even built out quite a bit, but never released. The gist is that it’s a site to help people learn languages by using pictures. I’ve refined the concept, my job has given me more experience working on bigger apps, and now I want to see if I can build something.

And that’s pretty much it. Sure, those aren’t the life-changing goals I’d attempted this year, but my life has changed enough as it is. For the time being, I’d like some stability. Evolution, not revolution. Above all, that’s what I ask of 2023.

Absolute zero

The news from the social media space is all about Elon Musk’s acquisition of Twitter and the changes he has made. Predictably, most opinions on his moves have followed their authors’ political leanings: those on the left hate everything he’s doing, while those on the right are unapologetic cheerleaders. Very rarely does anyone have a nuanced view on the topic, which is, alas, entirely fitting with modern discourse.

I like to think of myself as an exception to that rule. Yes, Musk is making good moves at Twitter, clearing out some of the detritus and indeed trash that had accumulated over the platform’s fifteen years of existence. But he is not infallible, and a few of his public announcements, plus the implications of some of his policy moves, paint a very grim picture for the future of the West’s #2 social media platform.

Elephant in the room

Let’s start with the most recent media scandal attached to Musk: the repeal of Donald Trump’s permanent suspension. The ban itself was on questionable grounds, of course; the “official” reason given is that Trump lied about attending the inauguration on January 20, 2021. In reality, we know that hundreds of Twitter employees, indoctrinated by the dangerous ideology of globalism, were chomping at the bit to remove one of their few prominent and unabashed critics, and they used claims of “destroying democracy” and “denying the election” as their excuses to do so.

The facts are clear. Trump won the 2020 election, and only massive, systemic fraud in at least 7 states ever cast any doubt on that. The idea that a dementia patient who spent most of 2020 hiding in his basement, who can barely form a coherent sentence, and who wasn’t even the most popular candidate from his own party could legitimately earn the most votes in any US election would be laughable if it didn’t make such a mockery of America. Add in the documented cases of illegal ballot harvesting, the mysterious vote dumps that—despite probability theory and common sense—somehow went 100% for Biden, and the thousands of whistle-blowers that have come forth, and you see that the most vocal claim of the anti-Trump mob at Twitter, that of “election denial”, is mere projection.

Anyone sane can see this for what it is. Just as with the manufactured pandemic, Twitter banned those who spoke against the narrative. Democracy itself was at stake in the 2020 elections. Never mind that the United States isn’t a democracy; it’s a republic, as it has been since 1776. And of course someone who was cheated out of his victory is going to complain about it!

“Oh, but what about the January 6 insurrection?” you might ask, because that’s the other reason given for deplatforming Trump and his supporters. But think back to that day. There was no insurrection by the people. Those who gathered in Washington were exercising their First Amendment rights of free speech, peaceful assembly, and petitioning the government for a redress of grievances. In this case, the grievance was election fraud, and there was no redress. The insurrection was by those who cowardly hid from their constituents, then waited until the dead of night to violate their oaths of office.

All that is old news, but those who wanted to silence Donald Trump—and who have, for nearly two years, succeeded—will have to face the consequences of their decision. That they are so terrified of even the idea he may be able to speak freely is telling, and it gives us a question to ask of any would-be censor. If they’re right, what are they afraid of?

Canary in the coalmine

Authoritarians the world over, in any era, have always feared two things more than any other: an armed populace and free speech. Social media has no way of defending oneself except through words, so only the second is of relevance in this case. But it is very relevant.

Free speech is the cornerstone of liberal society. When we are allowed to speak, to write, and to record without fear of reprisal from the state, we can achieve great things. Yet freedom of speech has been under assault almost since the concept was first formalized, and social media has become one of the biggest hindrances to this inalienable liberty. Entire topics are banned from discussion on Twitter, Facebook, and every other major platform. In recent months, those who wish to exercise their rights have been kicked off social media, removed from their web hosts or cloud providers, purged from global DNS servers, and even barred from using credit cards.

Those in favor of such extraordinary methods of silencing dissent always fall back to the same tired responses. “Freedom of speech isn’t freedom from consequences,” they’ll say. “Hate speech isn’t free speech.”

Both of these are incorrect. The entire point of free speech is that you are protected from consequences, specifically government retribution. Now, with banks and global corporations effectively functioning as additional branches of government, we are faced with the very real threat of non-state actors who have state-level powers, and they should be treated as such. Every social media platform, every payment processor, and so on must be held to the same standards of the social contract that we expect from Washington.

If Twitter is to be the public square, then it must allow the protections of a public square, such as the First Amendment’s right to free speech, the Fourth’s right of privacy, the Sixth’s right to a fair trial, and the Eighth’s freedom from cruel and unusual punishment. All but the most extreme would accept that the death penalty is not justified as punishment for an insult, so why should a “permanent suspension” be any different? Yes, Twitter can act as a corporation and private club, banning anyone for anything, but then they lose all claim to being public. An open society is entirely at odds with unilateral decisions of guilt and innocence.

After announcing Donald Trump’s reinstatement on Twitter, Elon Musk was asked if Alex Jones would be next. He replied flatly and unequivocally, “No.” This single word speaks volumes. Musk usually has a witty (or at least sarcastic) retort, but here there was none. And there was no room for interpretation, either.

How, then, can we reconcile that statement with Musk’s claims that he supports free speech? Alex Jones didn’t commit fraud, didn’t use true threats, and incite others to commit crimes—along with obscenity, the only categories of speech seen as unprotected by the First Amendment. Conspiracy theories are not illegal, nor is sharing one’s opinions on them. Whatever you think of his comments about Sandy Hook, he has the same right to express them as anyone. And he should have the same platform for that expression as those spreading the lie that an experimental gene therapy is safe for toddlers.

The solution

Elon Musk isn’t the answer. His reign at Twitter will make a lot of noise, but ultimately will change very little. Yes, he may end the silencing of mainstream conservative voices, but what does that accomplish? The site is still a dictatorship, not a place for open discussion, and nothing about Musk’s public statements says that will be any different under his watch. There will still be people who aren’t allowed to participate due to their views on the sensitive topic of the day. Indeed, in some cases the censorship will get worse: Kathy Griffin was suspended for impersonation, which is protected as parody (as long as there is no intent to defraud) in any free society.

No, the real solution is to create a social network where there is neither censorship nor centralization. That solution already exists in the form of the fediverse: a network of servers who share a common protocol and communicate with each other. In theory, one user on the fediverse can talk to any other, and can see posts of his own choosing, no matter their source. (In practice, it doesn’t quite work that way, because too many server admins simply block other servers whose policies allow anything close to free speech, thus breaking the idea of federation.)

This is the way forward. It’s the way email worked until Google got its hands on it. It’s how Usenet was the top method of disseminating news for nearly two decades. And it’s how we can get back to an internet where all are equally free to express their opinions.

No quarter

A recent article on the far-left site The Atlantic asks for a “pandemic amnesty”, and the very idea leaves me so enraged that I have to comment on it. This post is directed at people like that post’s author, not my general reader. Bear that in mind as you read.


You stole two years of my life over a bad cold. You forced me to put everything on hold because of your fears at best, your thirst for power at worst. Your mandates and machinations took me to the brink of suicide multiple times, left me broken in such a way that I still haven’t even found all the pieces, much less started to put them back together.

Lest you think this is about me, know that my story is not unique. You left thousands to die alone, left millions more wanting to, if not wishing they had. You tore holes in our social fabric. You set education back a generation by closing schools, destroyed public trust in doctors, the media, and government. You ostracized anyone who dared speak against you, calling us deniers, indeed murderers. You strove to see us not merely thrown in jail for beliefs you deemed heretical, but removed from society altogether. You sought to deny us our livelihoods if we didn’t bend the knee to your mad depopulation schemes. And now you want us to forgive you?

No.

What you did to us—to the whole world—is unforgivable. Every virus death after April 2020, when we knew that ivermectin and hydroxychloroquine were safe and effective treatments, is blood on your hands. Likewise every death from your gene therapy disguised as a vaccine, every lockdown-induced suicide, every senior who died alone because you wouldn’t allow families to visit, every child who can’t read at his grade level, every toddler whose development has been stunted because he never had the chance to see facial expressions, every American fired for refusing to get the deadly shot, and every couple who may never have the chance to reproduce.

All those are your fault. Anyone who took an unbiased look at the data two and a half years ago could see that this virus was nothing major. Yes, it was novel, and that was cause for concern. After all, it was made in a lab, so of course it was novel! Once our immune systems had a chance to learn about it, however, that novelty wore off, and we were left with a particularly pernicious case of the common cold.

Early on, we knew this. The Diamond Princess provided the perfect case study, and its numbers matched the actual data you tried to hide from us: 2 out of every 3 people infected showed no symptoms, about 0.15% of cases were fatal, and children were almost completely immune. The weaker (but easier to spread) strains like Omicron are even less cause for concern. Certainly no reason to shut down schools and small businesses.

Instead of amnesty, then, why don’t we talk about reparations? That’s what you deserve. You should be paying for the damage you caused us as individuals and society as a whole. Pay for the funerals of everyone your fear-mongering killed. Pay back the hospital bills of those injured by your so-called vaccines, and the unemployment benefits for those who were unjustly fired for refusing them. Pay for therapy: psychiatric therapy for the millions who now suffer from crippling depression and anxiety, speech therapy for the children who are finally allowed to learn visual cues again, couples therapy for the marriages strained to the breaking point. Pay for surrogates and sperm donors for the people your shots sterilized. Pay for the cancer treatments that had to be put off.

Then, maybe we can start talking about forgiveness.

Novel Month: End of an era

I’m not doing Nanowrimo this year. It pains me to say that, because it’s been a staple of November for over a quarter of my life. It was always something I looked forward to, something I eagerly anticipated before it happened, enjoyed while it was going on, and prided myself on completing. Not to mention the fact that my writing pushes resulted in some of my best work. Nocturne came out of Nanowrimo, for example.

This time around, I just can’t. When I wrapped up last year, I was in a very dark place. I couldn’t imagine taking the time to write another novel. Now that the time is upon us, I don’t have the time to take! My schedule is packed now. A full-time job, a full-time relationship, the imminent election and inevitable fallout, and the usual holiday rush have all conspired to make 50,000 words in a month impossible for me.

Even if I did want to try, though, so many of my books are incomplete that I feel starting something from scratch would do them a disservice. The fifth Orphans of the Stars novel still needs about 6 chapters. Otherworld #22 isn’t quite halfway done. I’ve left Endless Forms to languish for almost two years at this point, only a few chapters into its fourth book. I’d rather finish those first, and then work on Hidden Hills #3, Gateway #2, the Modern Minds shorts, or the Occupation Trilogy.

Yes, I still have a ton of ideas for stories, and a few of those are really great. It’s just the wrong time for them, unfortunately. It sucks, but…well, I won this thing ten years in a row. How many other authors can say that?

39

Not too long ago, I thought—even expected—that this would be the last birthday I’d have the chance to celebrate. Why bother living to see 40 if you have nothing to live for? So, at some point I decided that I wouldn’t. That, if things didn’t turn around, then I had no reason to make it to 40.

Now, I’m a year away from that milestone, beginning the last year of my 30s, and I’m cautiously optimistic that I’m turning a corner for the better. The reason I don’t have any big, fancy post for my birthday this year is because I just haven’t had time to write much of anything lately. The work never ends, against all odds. Even better that that, however, is that I’m spending the week of my 39th birthday with the woman I love.

I brought her home, and we’ll stay here, together, for a few days. Then, I’ll take her back to her home just outside Nashville, where we’ll stay the rest of the week. Together.

That’s what had been missing from my life for so long. I was always in it for me and me alone, because there wasn’t anyone else. No girlfriends, no friends at all. A family who, for the most part, was oblivious. As an agnostic (and now a technetic) I didn’t have that surety of faith so many around me could claim. No, it was just me, alone against an uncaring world.

Now, the world still doesn’t care, but she does. And that makes this a very happy birthday indeed.

Not for everyone

I’ve written a few times about what I call the “democratization” of development. Specifically, I’ve explored how giving ordinary people access to development tools (game engines, programming libraries, and so on) that used to be restricted only to large corporations benefits all of us.

Because it does. The indie gaming scene is the only place real innovation in games still takes place. Open-source software runs the world, even if you never see it. These wouldn’t be possible if we lived in the bad old days of the 90s and early 2000s, when a decent compiler and IDE cost as much as a new computer, when even the “family-friendly” console manufacturer’s answer to “how do I start making games?” told you to go to college.

We’re better than that now. And even though some of the biggest causes (Github, Minecraft, Firefox) have fallen to —rather, joined—the dark forces of wokeness, the legacy they built while they were still on the side of good remains. For all intents and purposes, programming is open to everyone.


The next question one might as is a natural follow-on to that statement. Programming is open to all, but should it be? Or is there something to be said for gatekeeping? After all, we’ve seen what democratization and inclusivity have done to RPGs. We’ve seen the massive drop in average literary quality that came with the opening of the Kindle Store.

Of course, I could never agree with that. If not for the world of open source, I wouldn’t be where I am today. If I’d had to save up to buy every single development tool I ever used, well, I wouldn’t have used very many of them. Billions of people around the world can understand where I’m coming from. Many of them live in worse poverty than I ever have, but they all have the same opportunity to learn this craft; one of my coworkers lives in Nigeria, and what person who grew up in the 80s and 90s would ever expect that?

From the financial standpoint, then, democratization is undeniably a good thing. From the social perspective, it’s the same. Yes, we have trouble. Straight white men are being pushed out of tech circles everywhere you look. Those who stay are muffled into impotence by “code of conduct” censorship regimes. But programming doesn’t require a community. It creates them. And those of us who truly create through code have the power to determine who we want inhabiting our communities.

Despite the numerous problems allowing the whole world into development has caused, then, I still wouldn’t want to go back. We’d just be giving up too much.


Another question I would expect one to ask is who should learn to code. It’s a valid question, as the very phrase “learn to code” has become kind of a buzzword—merely saying it became a bannable offense on Twitter, so you know it has some positive effect. Philosophically, it cuts to the heart of democracy in a way few people understand. After all, if everyone has an opportunity, does everyone also have the responsibility?

One reason this question came to mind was because of a disagreement I had with my boss a couple of weeks ago. He insists that development is little more than physical labor, on par with, say, a factory or assembly line job. As a developer myself, I feel what I do is more of a craft, a skilled trade that is mostly mental. I don’t just write code; I solve problems. This difference of opinion is, in a sense, a different way of looking at the fundamental question, because an unskilled job is something anyone can learn how to do.

I do believe that everybody should learn about programming. Computers are such a fundamental part of modern life that we are doing ourselves a disservice if we don’t understand at least how they do what they do. For the same reason, I think everyone needs a basic understanding of how a lot of other things work: internal combustion engines, power plants (of all kinds), radios, electronic circuits, indoor plumbing, and so on. Rather than teaching our children about make-believe genders, wouldn’t this be a better use of compulsory education?

That said, while we all need some knowledge, I recognize that not everyone has the ability to use that knowledge as a professional developer would. This is the crux of my disagreement. My boss thinks “developer” is a title, something you can train for and take on, the same as a sales manager.

I, on the other hand, see from personal experience that not everyone has that mindset. I’ve tried to teach programming to a few people, and it doesn’t stick. They’ve all said the same thing when I asked why: “My brain just doesn’t work that way.” And that’s really what it is. Some people are just wired differently. We have a different way of looking at the world.

You can’t chalk it up to intelligence. My brother is very smart, but he completely zones out the minute one of his favorite Youtube personalities starts talking code. Yet I’ve seen people who would struggle to reach the average in an IQ test write some masterful programs.

You can’t say it’s a mental disorder. I have only two of those: anxiety and depression. Neither are universal among programmers, though we collectively cover a huge swath of disorderly mentality. Many of the top developers truly are on the autism spectrum. One of the best who ever lived, Terry Davis, was a paranoid schizophrenic. But there are plenty who are, by all accounts, perfectly normal. I consider myself an average programmer, and I’d say I’m also near the mean in terms of mental health.

You can’t claim it’s because of demographics. Yes, I’m an American man, and most of the programmers you might know by name are the same. That’s only fair, as the US effectively invented the field, and it became male-dominated early on. (Not always, however. The inventor of COBOL was a woman, as was the first programmer who ever lived.) Yet there are great developers all over the world, and they come in all shapes and sizes. Russia’s hackers are famous…or infamous. Japan has given us some of the most talented and most devoted devs you’ll ever meet. And many great tools are being made in the Republic of China, even as the hardware they’re running on comes from the Communist usurpers on the mainland.

No, there’s something in the way certain people think that makes them good or bad at programming. And that’s fine. There’s nothing wrong with having our differences. I know I’m hopeless at, say, drawing. I’m too squeamish to ever be a doctor or a hunter. I recognize this, and I recognize that some people might just have a problem ever learning how to code. I still believe they should understand the fundamentals, if only because that would give them a better view of the world they live in. But I can respect their wishes to never go beyond that introduction.

In the end, it’s good that development has become democratized. Whether or not everyone uses the gifts we have been given, it’s better for all of us that they are there. When programming was reserved for the elite, only those who had that status could participate. But the programmer’s mindset is not limited to the rich, the college-educated, or the Westerner. It can show up anywhere, in anyone. Much like a fantasy gift of magical talent or the Force in Star Wars, our power does not come from our upbringing. It’s a part of who we are, so it’s good that we all have the chance to discover, train, and harness it.