Skip to content

a core (re)design of the C++ Standard Template Library

License

Notifications You must be signed in to change notification settings

rfgplk/micron.cpp

Repository files navigation

micron_logo_default

the micron core library 🦅

a core (re)design of the C++ Standard Template Library (and libc)

micron is a comprehensive core library; a collection of algorithms, containers, iterators, functions, and OS interfaces; a header-only core system library written in c++23 targeting the Linux syscall API. Unlike library collections such as Boost et al., micron does not intend to merely augment the STL, but entirely replace it.

Version License C++23




Warning

micron is still in active development, and as of v0.5 has reached relative stability. Regardless, the ABI may change at any point, and without notice.

Using the Library

All necessary code is self contained within the src/ directory. Since micron relies on no external sources, no other files or libraries are necessary (with the sole exception of pthread.h, more on that below). Simply include any header file you want into your project and compile. For examples, check out the examples/ directory (currently being added).

Installation via local_install.sh

A simple script which copies all files to /usr/local/micron

Features

  • a fully functional, templated C++ standard library implementation, designed from the ground up with modern principles in mind
  • completely self-contained, with no dependencies on external code or even the traditional C standard library
  • all functions are guaranteed to be side effect free, ensuring deterministic and predictable behavior across the codebase
  • written entirely in c++23
  • a high performance, cache-aware algorithmic base architecture
  • provides an innovative foundation for systems-level development, reimagining conventional approaches to low-level programming
  • optimized for rapid compilation speeds, enabling faster iteration and development cycles.

Motivation

The Standard Template Library (STL) has long been constrained by its imperative to preserve ABI stability across different versions. This limitation, coupled with the necessity of maintaining binary compatibility, intrinsically impedes the STL's capacity to evolve and assimilate modern development paradigms. The necessity of safeguarding compatibility with legacy systems imposes an architectural limit that resists transformative change, effectively tethering the STL to design philosophies that, while once pioneering, now appear antiquated. Consequently, this has permitted more novel programming languages such as Rust, Go, and even Zig, to develop a markedly more sophisticated set of core libraries. These languages, unburdened by historical bloat, are free to explore novel abstractions and innovative ideas, allowing them to embrace paradigms such as memory safety by design, zero-cost abstractions, and concurrency models that are inherently safer and more efficient.

Conversely, the micron standard library, unencumbered by such legacy constraints, has been reimagined ab initio with an unwavering commitment to rigorous performance and safety, thereby embodying a more powerful design ethos. Its development paradigm is liberated from the shackles of historical compatibility, allowing for an effective evolution that can readily integrate state-of-the-art techniques and designs. This freedom facilitates a design philosophy that prioritizes performance determinism and safety invariants, fostering a more robust and efficient ecosystem. By eschewing the historical baggage that impedes the STL, the micron library is able to transcend the limitations of its predecessor, positioning itself at the vanguard of modern software development. In doing so, it exemplifies a fundamental truth of technological software evolution: that liberation from legacy obligations is often a prerequisite for genuine innovation.

Since micron is specifically developed with Linux in mind, all library code is meticulously optimized for the nuances of the Linux kernel and its underlying system calls. This singular focus allows for an unparalleled level of integration and efficiency, leveraging Linux-specific features without the overhead of cross-platform abstractions. Consequently, the library achieves a degree of performance and system coherence that is unattainable in more generalized, platform-agnostic designs, solidifying its role as an indispensable tool for high-performance Linux development.

Philosophy

All core library code adheres to the following design principles:

  • in all instances where functional equivalence exists between micron and the STL, or any third-party library, micron must demonstrate superior performance
  • in all conceivable scenarios, this code grants the developer absolute control, both of execution and compilation
  • functionality must be preserved with any arbitrary data type
  • in all instances, micron must maintain seamless interoperability with the STL and any other library offering equivalent functionality
  • in all cases, performance always takes precedence over safety, with the developer assuming full responsibility for code validity and security
  • all functions follow a strict side effect free formulation (pure functions)

in short:

  • the written code, in its explicit form, stands as the ultimate arbiter of truth, unyielding and devoid of ambiguity, embodying the essence of how code should perform.

Is micron entirely self-sufficient?

Yes, micron relies on no external code other than what is included in this repository. Meaning as long as you have a working gcc compiler, you can compile and run it anywhere. The sole exception as for now is <pthread.h>, which is necessary to facilitate multi-threading. (technical note: as for now you still need to link against -libc due to exceptions/stack unwinding/_start/TLS not being fully implemented).

Important

Documentation for the micron library does not currently exist, although the source is intended to be structured in a legible and understandable enough way to serve as documentation for the time being. micron is specifically designed for Linux and x86_64 (with limited ARM support), as such other operating systems, kernels, or CPU architectures are entirely unsupported for the time being.

Libraries

currently, micron provides the following core C++ libraries:

  • [algorithm]
  • [allocation]
  • [array]
  • [hash]
  • [maps]
  • [math]
  • [matrix]
  • [memory]
  • [parallel]
  • [quants]
  • [queue]
  • [simd]
  • [sort]
  • [string]
  • [sync]
  • [thread]
  • [trees]
  • [vector]

License

Licensed under the Boost Software License, except the 'abcmalloc' memory allocator, which is licensed under the MIT License

About

a core (re)design of the C++ Standard Template Library

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages