A gentle introduction to C* II
Continuing an imperative walk-through of what makes this language different from others.
Welcome to part two of a gentle introduction to C*. In our last instalment we introduced a few concepts that come with C*: attributes, the underscore pronoun, and
struct alignment and padding. That last item is what we’ll be diving deeper into first!
The radical semantics of data structure
As we said before, in C,
structs are for “macro size” member variables. Their fields’ sizes are virtually always denominated in bytes, and the C compiler performs implicit alignment of larger fields for the sake of performance. We already covered explicit alignment before, so what else is new?
structs of C* are powerfully expressive. So powerful, in fact, that the C* language provides only one built-in primitive type: the
bit. Every data structure you could ever need is defined as a hierarchy of
structs ultimately based on this one type. It’s reminiscent of object-oriented programming languages where the fundamental base type is
Object, except the
bit is entirely concrete and real. C* is not a language of the abstract, so it provides nothing like
classes, templates, macros (outside those provided by the C preprocessor) or compile-time functions.
The most radical rejection of the meta
Generic programming is viewed as indispensable to many programmers both high-level and low. In a contrasting view, however, it is the principal mechanism through which immaculate complexity in computing has exploded. C* soundly rejects this “genericism” with its facilities called “metaprogramming” as part of fulfilling its purpose in facilitating the development of well-behaved software systems.
This contrasting view holds that it is better for code to simply describe the program as it is. Most commonly, metaprogramming is abused for two purposes: (a) crafting well-formed data structures with precision of storage and access at runtime, and (b) extending the semantics of the language in use.
Instead of doing such things, it is better in the contrasting view to create a different program that handles such things directly. Instead of metaprogramming a data format, create a transmogrifier program and inform your build script about it. Instead of metaprogramming a new paradigm that is abstract, create an interpreter for a different programming language that suits your exact needs.
Oracle’s problem with C
It is famously alluded to as a disparagement of C that Oracle, probably as part of its OracleDB software, maintains millions of lines of pure C code. The criticism, spoken or not, is that C is hell to maintain at scale because it lacks everything provided by C++ and VHLLs like Python.
Not to comment specifically on the situation at Oracle, this is a grave misdiagnosis of the core problem. The problem of maintainability with this ocean of C code is not in the fact that it is an ocean, plain to see, as opposed to an abstract token claiming to represent an ocean, that you could theoretically see, but practically won’t. No, the problem is that it is an ocean – no boundaries, no limits, no law, no order. An IOU for an ocean does us no favours, and even does us the disservice of leading us to believe the ocean is a manageable thing at all.
This is why law & order is the key feature of C*. Making systems maintainable and well-behaved is not accomplished with abstractions that stand in for the real complexity of our programs. This we have surely seen a thousand times over by now, as the tide of CVEs and zero-day exploits only rises. Everyone knows this problem is getting worse. Instead, C* provides
marshalling as a means to achieve maintainable and well-behaved programs. It treats the current program as a territory so that enforcement of laws becomes practical with a classic divide-and-conquer strategy.
This has been part two of a gentle introduction to the C* programming language. Expect part three soon enough, where we’ll do a tasty run-around of a lot of various syntactic oddities and niceties of C*. It’ll be the opposite of this post, rather a light write-up that doesn’t lean too much on the philosophy underwriting the language.
If you haven’t already, please consider subscribing. While I will strive to make about one third of my content open to public reading, I will nonetheless be making at least the first three parts of this series public. At $5.55/month, it’s hardly more than your average trinket from Amazon with Prime shipping. And it helps me out tremendously.