KC - The C sequel that does not break your code.

What KC attempts to accomplish and what challenges must be overcome.

Simplicity and familiarity

It looks a lot like C, and works like you expect C to work, but with safety built in.

Compatibility and interoperability

It can call C functions from shared libraries without bindings, include legacy code, and link with pre-existing object files.

Error Handling

The error handling is the greatest enhancement.  Optionals are now part of the language, as well as enumerated error values as an intrinsic part of every function return.

Type System

An even stronger type system that includes rigorous enforcement, eliminating the need for void pointers through an anytype capability that is evaluated by the preprocessor to ensure correctness.

Module system

The module system solves the dependency nightmare and adds versioning support, namespaces, and other features that make large projects easier to manage.  Modules can be imported from local or remote repositories.

Memory safety

Memory deallocation can be deferred and pointers are safe.  No borrows, but defer responsibility can returned to a calling process.  Pointers are tagged for validity.  Pointer reassignment automatically frees an allocation, pointers that are free are automatically tagged as invalid, and use of an invalid pointer can be trapped.

Slices, Character Arrays, and String Interpolation

Traditional null-terminated C strings are supported, but KC adds a new string type as a sliceable character array.  Declarations of strings to the new type are backward compatible to the old operations, but as are all arrays in KC, sliceable and can be accessed by reference or by copy.  Likewise, strings are parsed internally according to prefixes on the string, similar to Python's f-strings.

New operators

In order to distinguish the assignment of a reference, or the assignment of a value, the familiar = operator diverges into two forms.  The := operation implies a reference to allocated memory - the transfer of a value into a memory space along with whatever allocation of memory is needed to accomplish it.  The :: operator creates a reference to an already-allocated space.  These operators give the programmer finer control over what the compiler checks and ensures that the programmer and compiler are expecting the same behaviors. 

Strictness compiler options

Through environment or option on the compiler, in the same spirit as the -std and -W options, KC adds options to enforce various levels of strictness for code it compiles.  Options include:
• Enforce every safety and correctness check (default),
• Enforce every safety and correctness check internally on each module only, allowing tagged C-compatible boundary APIs in the target,
• Enforce every safety and correctness check internally on each module only, and create only C-compatible boundaries on the target,
• Warn on safety and correctness check violations within each module, continue compilation if at all possible, but fail if a flagged interface is violated, and
• Warn on  safety and correctness check violations within each module and selectively revert to C as necessary complete compilation as necessary.

Static targets

Support for generating self-contained, static targets is the default.  Use of dynamic libraries during runtime is also possible, but not the primary use case.  The strength of the module system is in controlling verified artifacts and not increasing variation in production by the presence of a complex mix of libraries in the environment.  Static executables, though larger, are safer than the wild west, and yet careful deployment of hot-reloadable libraries is also advantageous of it is done thoughtfully and methodically, so such are supported as well.


Address

PO Box 7
Whitinsville, MA 01588, US

About us

We are just a team of developers who love C, but do not love bugs.  We tried Rust; we tried Zig; we tried C3 and D; and we tried every other alleged C replacement under the Sun and came away wanting.  So, we figured if nobody else can deliver what we need, we will build what we want.

Follow us