Neopolitan C

A new city of code on a cosmopolitan foundation.

Penned on the 12th day of February, 2021. It was a Friday.

The honeybadger ventures out to new lands, where new discoveries and hardships await. About a year prior to this, a certain Justine was digging about, and discovered a polyglot buried in the numerology of Unix, System V and the IBM PC. She quickly refined this into a Cosmopolitan C library, and the rest was history.

But the Cosmopolitan polyglot was truly an old world gem. Our honeybadger sought something fresh and new, and on his journey westward the potentialities appeared in a shimmering bath of light. Adjusting his hat and crossing his heart, he knew the light and set his sights on it. He saw the future of a great new library – a chance not only to start from scratch, but to make something greater than anyone imagined possible – and he felt the duty in his heart to make it so. This is the future that he realised.


Some time in 2019, I began work on a scratch-built libc surrogate that, for lack of a better name, I called “unilib”. It was put under the Aquefir name, and I took great care of its structure and quality. unilib was similar in purpose to GLib, but with better attention paid to handling very old platforms, chiefly the IBM PC and the Nintendo Game Boy Advance. It is also a strictly ANSI C library, adhering to the standard as laid out by the ANSI committee in 1989. Call me old-fashioned, but I love the language as it originally was. Most of the “rough edges” I find quite beneficial from a hygiene standpoint. Later features have shown to be superfluous at best, one way or another.

Around the beginning of 2021, I discovered Justine Tunney’s work on her APE format and libc implementation supporting it, and I recognised it for the incredible research work on ABIs that it is. It has been awkward for me to apply, given that it is strongly tied to the x86 ISA and I have actively cared for targeting ARM. Despite that, I knew that the one big feature API that Cosmopolitan was lacking was a good way to handle graphics. Neopolitan C is a step on the path to making that happen.

For years I have had in pre-planning a graphics innovation called OAM, and have not created it yet as I need to work out what exactly it depends on first. Cosmopolitan C provides a wonderful generalisation of all the great x86 operating systems, and this generalisation is needed to avoid spending so much more time targeting those as separate platforms. However, Cosmopolitan provides the well-established C libraries most of these platforms can share – it does not try to give any sort of new interface with better design. This is where unilib comes in to play. Neopolitan is simply unilib-on-cosmopolitan. With that in hand, the complexities of OAM can be worked through much more quickly and effectively. Yeah, I think the library is really that much better – there’s hardly a point otherwise!


Browse the repository on GitHub.

There will be documentation available here soon, and it will have a much nicer UX than your average doxygen or sphinx HTML. I am developing sli-tool to this end.