More from David Heinemeier Hansson
There'll always be more emails in need of reply, more meetings to attend, and more updates to read. A person can fill the entire workweek with these tasks over and over again. But to stay sane and sharp, you must pay yourself first by doing the work that actually means something to you. I feel this acutely as someone responsible to employees, customers, followers, and readers. I could do nothing all day but check up on projects, people, and posts, but my brain would quickly check out if it was just doing that. So quite frequently, I just don't. Don't check in, don't check up, and instead dive into the work that checks my own intellectual boxes. Programming for the love of it. Experimenting for the hell of it. Researching for the fun of it. In another age, I might have been tempted to apologize for such privilege, but screw that. Privilege is wonderful. You should do your best to earn more of it. Even if you have to carve it out of the bare rocks around you. Ironically, the best way to do that is also to choose to always pay yourself first, however little at first. By solving your own problems, tickling your own interests, chasing your own curiosity. That's where you'll find the motivation to elevate your talent. To turn interest into competency. And once you've developed some competency, you'll be rewarded with more privilege to build it further. This is the virtuous circle of merit. There'll always be an endless list of work that could be done. You'll never get through it all and onto your own priorities, if you continue to put them at the bottom.
The first Rails World in Amsterdam was a roaring success back in 2023. Tickets sold out in 45 minutes, the atmosphere was electric, and The Rails Foundation set a new standard for conference execution in the Ruby community. So when we decided to return to the Dutch Capital for the third edition of the conference this year, the expectations were towering. And yet, Amanda Perino, our executive director and event organizer extraordinaire, managed to outdo herself, and produced an even better show this year. The venue we returned to was already at capacity the first time around, but Amanda managed to fit a third more attendees by literally using slimmer chairs! And I didn't hear any complaints the folks who had to sit a little closer together in order for more people to enjoy the gathering. The increased capacity didn't come close to satisfy the increased demand, though. This year, tickets sold out in less than two minutes. Crazy. But for the 800+ people who managed to secure a pass, I'm sure it felt worth the refresh-the-website scramble to buy a ticket. And, as in years past, Amanda's recording crew managed to turn around post-production on my keynote in less than 24 hours, so anyone disappointed with missing out on a ticket could at least be in the loop on all the awesome new Rails stuff we were releasing up to and during the conference. Every other session was recorded too, and will soon be on the Rails YouTube channel. You can't stream the atmosphere, the enthusiasm, and the genuine love of Ruby on Rails, though. I was once again blown away by just how many incredible people and stories we have in this ecosystem. From entrepreneurs who've built million (or billion!) dollar businesses on Rails, to programmers who've been around the framework for decades, to people who just picked it up this year. It was a thrill to meet all of them, to take hundreds of selfies, and to talk about Ruby, Rails, and the Omarchy expansion pack for hours on the hallway track! I've basically stopped doing prepared presentations at conferences, but Rails World is the one exception. I really try my best to put on a good show, present the highlights of what we've been working on in the past year at 37signals, and transfer the never-ending enthusiasm I continue to feel for this framework, this programming language, and this ecosystem. True, I may occasionally curse that commitment in the weeks leading up to the conference, but the responsibility is always rewarded during and after the execution with a deep sense of satisfaction. Not everyone is so lucky as I've been to find their life's work early in their career, and see it continue to blossom over the decades. I'm eternally grateful that I have. Of course, there's been ups and downs over the years — nothing is ever just a straight line of excitement up and to the right! — but we're oh-so-clearly on the up-up-up part of that curve at the moment. I don't know whether it's just the wind or the whims, but Rails is enjoying an influx of a new generation of programmers at the moment. No doubt it helps when I get to wax poetically about Ruby for an hour with Lex Fridman in front of an audience of millions. No doubt Shopify's continued success eating the world of ecommerce helps. No doubt the stability, professionalism, and execution from The Rails Foundation is an aid. There are many auxiliary reasons why we're riding a wave at the moment, but key to it all is also that Ruby on Rails is simply really, really good! Next year, with RailsConf finished, it's time to return to the US. Amanda has picked a great spot in Austin, we're planning to dramatically expand the capacity, but I also fully expect that demand will continue to rise, especially in the most prosperous and successful market for Rails. Thanks again to all The Rails Foundation members who believed in the vision for a new institution back in 2022. It looks like a no-brainer to join such a venture now, given the success of Rails World and everything else, but it actually took guts to sign on back then. I approached quite a few companies at that time who could see the value, but couldn't find the courage to support our work, as our industry was still held hostage to a band of bad ideas and terrible ideologies. All that nonsense is thankfully now long gone in the Rails world. We're enjoying a period of peak unity, excitement, progress, and determination to continue to push for end-to-end problem solving, open source, and freedom. I can't tell you how happy it makes me feel when I hear from yet another programmer who credits Ruby on Rails with finding joy and beauty in the writing web applications because of what I started over 22 years ago. It may sound trite, but it's true: It's an honor and a privilege. I hope to carry this meaningful burden for as long as my intellectual legs still let me stand. See you next year in Austin? I hope so!
Omarchy has been improving at a furious pace. Since it was first released on June 26, I've pushed out 18(!) new releases together with a rapidly growing community of collaborators, users, and new-to-Linux enthusiasts. We have about 3,500 early adopters on the Omarchy Discord, 250 pull requests processed, and one heck of an awesome Arch + Hyprland Linux environment to show for it! The latest release is 1.11.0, and it brings an entirely overhauled control menu to the experience. Now everything is controlled through a single, unified system that makes it super fast to operate Omarchy's settings and options through the keyboard. It's exactly the kind of hands-off-the-mouse operation that I've always wanted, and with Linux, I've been able to build it just to my tastes. It's a delight. There's really something special going on in Linux at the moment. Arch has been around for twenty years, but with Hyprland on top, it's been catapulted in front of an entirely new audience. Folks who'd never thought that open source could be able to deliver a desktop experience worth giving up Windows or macOS for. Of course, Linux isn't for everyone. It's still an adventure! An awesome, teach-you-about-computers adventure, but not everyone is into computer adventures. Plenty of people are content with a computer appliance where they never have to look under the hood. All good. Microsoft and Apple have those people covered. But the world is a big place! And in that big place, there are a growing number of computer enthusiasts who've grown very disillusioned with both Microsoft and Apple. Folks who could be enticed to give Linux a look, if the barrier was a little lower and the benefits a little clearer. Those are the folks I'm building Omarchy for.
I've never seen so many developers curious about leaving the Mac and giving Linux a go. Something has really changed in the last few years. Maybe Linux just got better? Maybe powerful mini PCs made it easier? Maybe Apple just fumbled their relationship with developers one too many times? Maybe it's all of it. But whatever the reason, the vibe shift is noticeable. This is why the future is so hard to predict! People have been joking about "The Year of Linux on the Desktop" since the late 90s. Just like self-driving cars were supposed to be a thing back in 2017. And now, in the year of our Lord 2025, it seems like we're getting both! I also wouldn't underestimate the cultural influence of a few key people. PewDiePie sharing his journey into Arch and Hyprland with his 110 million followers is important. ThePrimeagen moving to Arch and Hyprland is important. Typecraft teaching beginners how to build an Arch and Hyprland setup from scratch is important (and who I just spoke to about Omarchy). Gabe Newell's Steam Deck being built on Arch and pushing Proton to over 20,000 compatible Linux games is important. You'll notice a trend here, which is that Arch Linux, a notoriously "difficult" distribution, is at the center of much of this new engagement. Despite the fact that it's been around since 2003! There's nothing new about Arch, but there's something new about the circles of people it's engaging. I've put Arch at the center of Omarchy too. Originally just because that was what Hyprland recommended. Then, after living with the wonders of 90,000+ packages on the community-driven AUR package repository, for its own sake. It's really good! But while Arch (and Hyprland) are having a moment amongst a new crowd, it's also "just" Linux at its core. And Linux really is the star of the show. The perfect, free, and open alternative that was just sitting around waiting for developers to finally have had enough of the commercial offerings from Apple and Microsoft. Now obviously there's a taste of "new vegan sees vegans everywhere" here. You start talking about Linux, and you'll hear from folks already in the community or those considering the move too. It's easy to confuse what you'd like to be true with what is actually true. And it's definitely true that Linux is still a niche operating system on the desktop. Even among developers. Apple and Microsoft sit on the lion's share of the market share. But the mind share? They've been losing that fast. The window is open for a major shift to happen. First gradually, then suddenly. It feels like morning in Linux land!
Over the years, I've learned not to question inspiration. To simply let it drive when it shows up with a full tank. Quite often, I don't exactly know where we're going or even why we're going, but it's repeatedly taken me to just the right place at just the right time, so now I just hop in and say: Let's go! Case in point: Arch + Hyprland. It's been over a year since I created Omakub to smooth out my own exit path from macOS to Linux, and in the process, helped thousands of others enjoy a beautiful, preconfigured, and relatively familiar desktop experience with Ubuntu. And I continue to think this is an excellent choice for Linux, especially for first-time Mac and Windows defectors. But this weekend, I just happened to be home alone, and the hype around Arch + Hyprland got the better of me. While Ubuntu is all about being a friendly place for newcomers to Linux, Arch + Hyprland is the exact opposite: It's Linux on hard mode! At least that's the reputation, and there's certainly something to that. The Arch ISO literally just dumps you into a terminal with scarcely any direction. Just getting on the Wi-Fi requires learning the arcane command-line options for the iwctl terminal configurator. But besides iwctl, it's actually not that bad anymore. We now have a cheat code for installing Arch in the form of archinstall. It's a terminal interface for getting all the bits like picking a disk and creating the first user done in the correct order, without having to set aside an entire evening just to get the OS installed. So it didn't take long to get Arch up and running. That doesn't get you much further, though! By default, Arch is about as minimal as it gets. There's no default graphical interface. There are no niceties. Not even wget or curl by default! It really is just a bare-bones installation of Linux. But on the other hand, Arch is blessed with the AUR — a Wikipedia-style, community-maintained package management system that seems to have literally every piece of software ever released on Linux, and always in the latest version. A quarter of Omakub is trying to work around the fact that helpful tools like Alacritty or LazyGit or whatever rarely have official packages for Ubuntu, so you're left doing a lot of manual scripting to get everything a developer would want from a modern Linux setup. Not so with the AUR! So that's Arch. But Hyprland is even more hilarious. It's a tiling window manager with something as rare in the Linux world as a keen focus on aesthetics! It looks like it was written by visual artists rather than neckbeards. And it's at the core of the modern r/unixporn Linux ricing subculture. That's not the funny part, though. The funny part is how ridiculously atomized the entire thing is. Hyprland comes with absolutely nothing out of the box. No login screen, no menu bar, no notification system, no file manager, no visual settings application. Just a text-based configuration file, a wiki, and an outline on a map for how to design your own adventure. This means that if you're interested in running Hyprland, and you intend to set it all up from scratch, you're probably signing up for at least a good 10+ hours — just to install and configure everything! Now, there are some precompiled setup scripts out there already, but most of them still require you to do a ton of manual legwork before you reach that beautiful summit of a complete system. So while the downside of Arch + Hyprland is that literally every last detail requires you to make a choice and a config file to move on, it's also its upside: you can change EVERYTHING! And the core window tiling magic of Hyprland is one of the most intoxicating ways of using a computer that I've ever experienced. It looks amazing; it feels amazing (if you prefer using a keyboard instead of a mouse!). I've poured hours and hours into this quest over the weekend, and yet I'm still not even done with my first Arch + Hyprland build! My login screen looks like shit. I haven't decided on a final menu bar configuration. But what is working — the basic tiling flow and look — is so nice that the inspiration keeps driving the project forward. Which, of course, I've already decided to codify. I'm not going through all this work to set up a beautiful, preconfigured, fully-functional, out-of-the-box Arch + Hyprland combo and then not share it with anyone who's curious (and might not have 10–20 hours for this kind of side quest available in their schedule). So of course I registered a domain and found a way to draw some ASCII art: Omarchy is on the way!
More in programming
by Roy Keur The hidden attribute has always been an odd way of hiding elements. It allows a developer to hide elements with HTML and this by itself has been a source of debate since it was introduced. A couple of years ago, this attribute was already discussed over here, but what has been predicted as the future has turned into a reality today. hidden is no longer truly hidden since the introduction of until-found as a new value for this attribute. From the beginning, we were promised in the specs that when you add hidden to an element, you make it hidden from all presentations. Since until-found has been implemented, I feel a bit lied to, as this new value seems to break that promise. I would say it is a good idea to revisit this nefarious attribute to see what has actually changed and what we can learn from it. Hiding important content with display:none (and hidden) has shortcomings Let's start with a brief reminder of why hidden="until-found" was introduced in the first place. The very basics are that hidden applies display: none to an element, as defined in the user agent stylesheet, but using display: none can lead to some shortcomings. Some years ago, various news media found it a good idea to cut stories on their websites in two parts by inserting a 'Continue reading' button at some point in their articles, especially on mobile devices. Below is a simplified snippet of how this concept is applied today: <p> You could either take a boat or fly to Lorem Ipsum Island, but the flights are all cancelled due to a lack of available aircraft, so you will have to take a boat. </p> <button type="button" aria-expanded="false"> Continue reading this article </button> <p data-readmore-hidden="1" style="display: none;"> You can either use a catamaran, which takes one hour and fifteen minutes with departure time at 11:30, or take the slower cruise ship which takes two hours and 30 minutes, with departure time at 9:30. </p> Note: the original code in this snippet uses display: none, not hidden, and I have retained this. In the chapter about the specs later on, I will discuss why display: none might indeed be a better choice than hidden in this context. If you want to search for "departure time" in this snippet, you have got two choices: either read the whole article or use the in-browser find-in-page functionality that can for instance be triggered by pressing CMD+F or CTRL+F on a keyboard. If you try to use find-in-page, however, you will get zero (0) results. Why? If you hide content with display: none, you render it not only invisible and inaccessible to the user, but also to the user agent and that is what tries to search for any matches. What also will not work with hidden content is linking to a page anchor (think of website.test/some-page#paragraph-1) and using text fragments in the URL to highlight text (think of website.test/some-page#:~:text=departure%20time). How hidden="until-found" fixes these shortcomings To make hidden content searchable by the user agent, we can now use hidden="until-found", which uses content-visibility: hidden instead of display: none. By using content-visibility, the element keeps its box, but its contents are not rendered, and the browser retains its state (for example, scroll positions) instead of throwing it away like display: none does. It allows a browser to tell content that should really be hidden apart from content that is hidden but should still be searchable. Note: just using content-visibility on an element by itself does not make the element searchable. Using hidden="until-found" does. Also, it is worth mentioning that using until-found still does not make content available to screen readers: hidden is meant to hide content from all presentations (see below) and a user agent is not a presentation. In practice, hidden="until-found" works like this: when a user searches for a term with find-in-page or text fragments, the browser searches through all searchable content. In case of a match, the browser triggers an associated beforematch event on the element that contains the match and hidden="until-found" will be removed from the element, before scrolling to the newly revealed match. The removed attribute will not be re-added to the element, even when closing find-in-page, so the element will not be hidden again in the currently active browser session. Notes on what specs state about hidden The specs state the following about the hidden attribute: "if something is marked hidden, it is hidden from all presentations, including, for instance, screen readers". It is fairly strict on what you should use hidden for. Using hidden on elements that "could legitimately be shown in another presentation" (for example, in a tabs pattern) is deemed 'incorrect' because "the tabbed interface is merely a kind of overflow presentation", explaining you could "equally well" have "one big page with a scrollbar". I tend to agree with the principle of this statement from a vision of "(information on) the internet should be available to all" and "important information should not be hidden anyway", but what if when we do want to temporarily hide content? We should apparently not use hidden, but should we also not use display: none since that is essentially what hidden does? That would be strange, as we all use display: none to hide elements in all kinds of use-cases, such as this previous snippet, but also accordions, tabs, header navigation menus, etc. Even a closed native <dialog> uses display: none internally. Is that supposed to be different, then? The mysterious Hidden state Interestingly, the specs also state (no pun intended) this: "User agents should not render elements that are in the Hidden state". This state is what sets hidden apart from display: none semantically: applying display: none to an element does not give an element the Hidden state. This Hidden state is only relevant for the browser, as it is the browser that uses this state to determine the relevance of the content. A user will not notice the visible difference between hidden and display: none. There can be cases, however, where states do get relevant for the user. I will talk about such a case in the final chapter of this article. So, elements with the hidden attribute get the Hidden state, but didn't until-found explicitly enable user agents to actually make elements visible? Perhaps surprisingly, elements with hidden="until-found" do not get the Hidden state. Instead, a special Hidden Until Found state is introduced, which allows an element to be accessible to find-in-page and fragment navigation, although conditionally an element "needs to be affected by layout containment" (essentially if display is not none, contents or inline). It appears hidden="until-found" is more different from hidden than I thought. Comparison with <details> hidden="until-found" works similarly to <details>. Both use content-visibility to hide content. However, <details> was not meant to work like this when it was introduced. Its original purpose was simply to allow a user to toggle the visibility of content without having to resort to using JavaScript or CSS and its original implementation worked with a display: none toggle too. Only when content-visibility arrived in browsers was display: none replaced by it. Notable differences to hidden="until-found" are that you will be able to collapse <details> natively after a match has caused it to expand and <details> has user interface additions like a (native) marker, suggesting there is hidden content to expand, while hidden="until-found" does not give any visual clues. An accordion use-case with hidden="until-found" Let us make an accordion where we can search in collapsed content, using hidden="until-found". As a base, we can take this Accordion Example in the ARIA Authoring Practices Guide. That example already makes use of hidden="" – the attribute the specs kind of told us not to use here! – to hide content, so to make the content available for find-in-page is as simple as adding until-found as a value to that same attribute. Consider the following HTML snippet, where JavaScript has been omitted for brevity: <div id="accordionGroup" class="accordion"> <h3> <button type="button" aria-expanded="false" class="accordion-trigger" aria-controls="sect1" id="accordion1id"> <span class="accordion-title"> Some title <span class="accordion-icon"></span> </span> </button> </h3> <div id="sect1" role="region" aria-labelledby="accordion1id" class="accordion-panel" hidden="until-found"> Some hidden content. </div> </div> Here we manage to more or less replicate <details>, as we can expand the content by searching inside the hidden content, while also being able to collapse it, but there are notable differences. Firstly, headings keep their semantic meaning consistently. <details> has a limitation Scott O'Hara elaborates on in more detail, but the core issue here is that when you place a heading inside the compulsory <summary>, browsers and screen readers could interpret this heading as presentational, which messes up the intended semantics of the page. Secondly, we do need JavaScript to control the visibility state of the content and the state of aria-expanded. Using JavaScript allows us to let hidden="until-found" truly shine here, as we can listen for the beforematch event to fire and use that to toggle the visibility state. Interestingly, just like how you can't just place content-visibility: hidden somewhere and an element will be searchable for the user agent, you cannot just place a beforematch event listener on an element with visually clipped content and expect it to fire. You must use hidden="until-found" for this to work. About browser support Chromium has shipped hidden="until-found" since 2022 (Chrome 102), Firefox followed in February 2026 (Firefox 148), and Safari 26.2 (December 2025) shipped it as well, together with the beforematch event. Safari's support still counts as partial because it does not yet scroll to the revealed match (WebKit bug 304174). If a browser does not support until-found, it falls back to using display: none, as if it were a plain hidden attribute, which makes this a neat progressive enhancement. Instead of using the regular fallback, I would rather show the content by default by applying display: block. The same principle applies when JavaScript is disabled, except here we need to additionally declare content-visibility: visible. With JavaScript disabled, consider hiding the toggle button too, as the content will be visible anyway. Nowadays applying CSS when JavaScript is disabled is easy, since @media (scripting: none) is widely available. A cursed thought experiment In case <details> is not a viable option, we need to use JavaScript and that means a screen reader user will need to use a button to toggle the visibility of hidden content, whether it has until-found or not. There are ways to work around this need to toggle. I have come up with a cursed way of implementing hidden="until-found" by actually not hiding its contents by default. Consider this CSS snippet: [hidden='until-found'] { content-visibility: visible; display: block; contain: strict; contain-intrinsic-height: 1px; } Some key points here: content-visibility: visible is applied to override the default browser implementation of hidden="until-found"; display: block is applied to override any odd [hidden] { display: none } in case of a normalise/reset file; contain-intrinsic-height must be at least 1px, as otherwise NVDA or the in-browser speech functionality will not announce the hidden content. Compared to a regular accordion where you deliberately hide content and render it inaccessible, here, the mindset is the opposite. Content is accessible by default, albeit visually hidden; it is accessible to screen readers without the need to toggle (I was able to verify this with recent versions of VoiceOver, NVDA and JAWS); one can browser-search within the hidden content; one can interact with interactive elements (links, buttons) within the hidden content and by adding a focusin event listener, you can even toggle the visibility state when a user focuses on such an item. Below is a snippet that implements this experiment. It is simplified to leave only the relevant parts in, including a minimum bit of JavaScript to make the toggle work both on click (on the button), on beforematch and on focusin. See the Pen Hidden until-found in use as an accordion by Roy (@roye7777777) on CodePen. There is much to think of here, but there are a few things I want to mention. The toggle button is still present, even when the visually hidden content is accessible to screen readers. It will still toggle the visibility. For screen reader users, this makes no difference, since all content is readily available to them. To then still find a button that suggests an element is still collapsed, while it actually is not, is wrong and one reason not to use this altogether. You could try to hide the button from screen reader users, but there is not much you can do, really. Applying aria-hidden="true" onto a button is wrong as hiding a focusable element from assistive technology is an accessibility failure in itself. Also: what would happen if you use a screen reader in combination with a magnifier? Content could probably be announced, but the user would not be able to see where this text is coming from, since it is visually hidden. Although it is not uncommon to see this in practice (particularly in these 'read more' articles), it is potentially confusing. Final notes on reader mode There's one more thing I mentioned earlier in this article that I want to discuss, and it is the Hidden state. Browsers have a reader mode functionality these days, and their intention is to make content-heavy articles easier to read with less noise. Those who have been testing with this know that reader mode in each browser behaves differently. Each browser engine has a different implementation of this non-standardised concept, and their specific rules and guidelines are often undocumented. Unlike print or noscript, there is not something like a media query to override a certain undesired state within reader mode and I suppose this restrictiveness is intentional to keep it as clean as possible (read: to prevent developers spamming reader mode with noise anyway). Rules of thumb for reader mode are generally: let the HTML be semantically correct, have enough content for reader mode to become active, and most importantly in this context: any hidden content will stay hidden. Any element with the hidden attribute set, even with until-found as its value and even when overridden with display: block, will always be hidden in reader mode. To me, when using specifically hidden="until-found" and <details>, this principle feels wrong. I expect content in hidden="until-found" and <details> to be visible in reader mode. Yes, these elements are hidden, but they all can natively become visible and that ability, together with this special so-called Hidden Until Found state, has been implemented in browsers for a reason after all! Why would in a group of <details> all <details> be hidden except for the first as it contains an open attribute? I hope this behaviour will change in browsers in the future, or at least there will be an option where one can express a desire to show a collapsible element in reader mode. So, important to remember here is this: if you were to use hidden="until-found" in a content-heavy article, you deny users the ability to read all content in reader mode. There is no way to work around this without resorting to duplicating content and rendering it invisible differently by means of opacity: 0, clipping, positioning it out of view or whatever nonsense, as then this duplicated content is semantically not hidden. Now that is hell!
A former Amazon engineer sees signs that the ‘six-pager’ documents used to promote good decision making are increasingly AI-generated and AI-read, and warns it’s not a positive development.
In October 2026 Jenni was acquired by Digital Science. A personal reflection on four years as founding designer, from $4k to $730k in monthly revenue.
In 1978, the ACM published an algorithm by Robert Morris for counting large numbers of events in small registers. It uses one byte to keep track of the approximate logarithm of the count, and randomly increments the logarithm with a probability that scales with the value of the count. You can tune the range and precision of the counter by adjusting the base of the logarithm. Morris suggests pre-calculating a table of probabilities so that no difficult calculations are needed at runtime. Recently I learned from emsenn about a 2009 paper by Miklós Csűrös titled approximate counting with a floating-point counter. It changes Morris’s algorithm to use a binary log-linear counter instead of a pure logarithm. It reminded me of my hg64 log-linear histograms, so I thought it would be fun to implement, especially since the algorithm can be made shorter and faster. representing a counter We need to choose the number of bits to use for the exponent and mantissa of each approximate floating point counter. Typically the exponent will be 5 or 6 bits, corresponding to an unpacked exact counter of 32 or 64 bits. The mantissa will typically be the rest of an 8 or 16 bit integer (though languages such as Zig and C23 allow more adventurous integer sizes). I’ll call the approximate counter type usmol and the unpacked counter type ubig. #define EXPBITS 5 #define SIGBITS 3 typedef unsigned _BitInt(EXPBITS+SIGBITS) usmol; typedef uint32_t ubig; static_assert(sizeof(ubig) * 8 == 1 << EXPBITS, "ubig must match EXPBITS"); It’s straightforward to extract the exponent and mantissa from a usmol counter. Unpacking a usmol into a ubig is slightly tricky. Like hg64 and IEEE754, normal numbers (with a nonzero exponent) have an implicit leading bit, and denormal numbers (exponent is zero) do not. The effect is that small counts are represented exactly in a usmol (up to 2*MANTISSA, covering denormal numbers and exponent == 1), and larger counts are shifted by the exponent. (I don’t need the inverse conversion here, but it is used by hg64 to map a sample to a histogram bucket, truncating the value by shifting right.) #define MANTISSA (1 << SIGBITS) static inline ubig exponent(usmol approx) { return(ubig)(approx / MANTISSA); } static inline ubig mantissa(usmol approx) { return(ubig)(approx % MANTISSA); } static inline ubig unpack(usmol approx) { ubig e = exponent(approx) - 1; ubig m = mantissa(approx) | MANTISSA; return(approx < MANTISSA ? approx : m << e); } bumping a counter Because binary floating point uses logarithms in base 2, we need the probability of incrementing the counter to scale with 2^-e. Specifically, we want the probability of increasing the counter to be 100% when its exponent is 0 or 1, 50% when the exponent is 2, 25% when it is 3, etc. Csűrös does this by getting a random bit e times in a loop and incrementing the counter if they are all zero. A more efficient way to do this on a computer is to get a ubig word full of random bits and count the leading or trailing zeroes. There are a variety of bit scan functions that differ in how they number bits and what they do when the word is entirely zero. The POSIX ffs() family has the advantage of no undefined behaviour, but it weirdly counts from one. However this oddity turns out to match the way denormal numbers give our exponent an off-by-one bias. So for instance, when our exponent is 2 and we want a 50% probability, we want ffs() to return 2 or more. OK, that determines when to increment the mantissa given a particular exponent. But how does the exponent get incremented? Like Csűrös, we put the exponent immediately to the left of the mantissa; when the mantissa overflows, it rolls over to zero and the exponent ticks up. No special cases are needed. The resulting code is short: usmol bump(rng_t *rng, usmol approx) { ubig r = ubig_random(rng); ubig z = (ubig)ffsll((long long)r); ubig e = exponent(approx); return(approx + (z >= e)); } considerations Morris allows you to smoothly tune the allowable range and precision of a counter by adjusting the base of the logarithm. By contrast, Csűrös has very lumpy 2^2^n choice of ranges; that isn’t necessarily bad because it’s normal for programmers to have to choose between uint32_t and uint64_t. Morris uses a lookup table to determine the probability of incrementing, which is tolerable for an 8 bit counter, but it can get large for wider counters. Csűrös just uses a few instructions and bigger counters don’t need much more. So I don’t think either algorithm is clearly better than the other, except that Csűrös has the winning fun factor of bithacking a bespoke floating point format.
Parallelize discovery and execution, but serialize judgement.