Friday, November 17, 2023

C*: C Lang Sucessor


C*[C-Star] is a successor language to C, which allows quick rewrite of existing C Code to a more memory safe platform along with modern language features [ range based loops/Hash Maps...]. It specifically designed  to provide Type/Spatially safe C like Language with Sufficient Level of Temporal Safety without hampering development efficiency with a borrow checker. C* employs manual memory management with Arena allocator. C* like C ensures complete freedom to the programmer, instead of taxing development velocity.Performance optimization and memory management is left up to the  programmer.

It guarantees sufficient level of memory safety without bogging down the development velocity,it archives it through radically different memory architecture in comparison to competition.Every Data Type with more than one element is bounce checked by default thus preventing Spatial Memory Errors, Implicit Type Cast is done in safer way to prevent Type Corruption.

Any Experienced C  Developer can get hold of C* with in days, C* is very close to C which prevents a developer from learning new language with steep learning curve. 

C* can enforces Spatial and Type Safety, but it is up-to the developer to archive reasonable level of temporal safety with the tools provided by the language. C* like C or Ada follows a manual memory management architecture, this empowers developer with unmatched control over Physical hardware, .Arena allocator of C* simplifies lots of it but in some cases C-Style manual/dynamic memory allocation might be necessary. Temporally/Spatially Safe C equivalent of malloc/calloc/free/realloc/memmove are present for exceptional cases and porting legacy C application with some performance penalty.

C* Version 1.0:
- Simple Object Oriented Routine for Abstraction
- Enforced  Spatial/Temporal Memory Safety 
- Advance Manual Memory Management Architecture +
- libstar: To provide C* Library with C-11 Equivalent Functions.

Language Features:
- Safe Implicit Type Conversion
- TypeSafe Tagged Enum
- Pattern Matching / Structured binding patterns
- Tuple/Slices
- Hash Maps
- Range Based loops

Compability Goals:
- Easy Porting of C Code
- Seemless Interoperability with Modern C++(*)

Object Oriented Routines: C* doesn't aims to be C++ , rather provides simple Classes and Inheritance with own model of dynamic polymorphism to allow superior abstraction in comparison to C. Object Oriented Features are optional.

Advance Manual Memory Management + Architecture  : It uses Advance Thread Safe Arena allocator with Encrypted Pointers to make exploiting Temporal Memory bugs harder for  attacker, with performance far superior to legacy free/malloc. Hardened version of Arena exist where Temporal safety is paramount over the performance.

[Hardened C Function like malloc/calloc/free/realloc/memmove are present but hardened with Hard-pointer, to ensure temporal safety but their are performance penalty in comparison to their C equivalent, it is recommended to use AMMM+ semantics for C* application written from Scratch] 

*You can combine C* Code [.CXX/HXX] and modern C++ [.CPP/.HPP] seamlessly in one project, Clang Fork of C*(C-Star) will look after combining your C* and C++ seamlessly. This allows Safety Enforced C* Code to work flawlessly with High Performance Modern C++ Code. 

Target: Operating System Kernel /Kernel-mode Driver/Embedded Application.

Specimen Language Feature:

Pointer Declaration in C*: 

Ptr<Datatype,PtrType>
PtrType: Pointer Type
Destination: Destination Pointer , Ptr Arithmetic is not allowed.
Arithmetic: Ptr Arithmetic/Accessing Data structure is allowed  but Arbitrary Type Cast is not allowed.
Ref-pointer: Reference Counted Pointer, equivalent to  C++'s Shared Pointer
Hard-pointer: It is a hardened Fat Pointer for ensuring Temporal Safety, it can do everything what raw C pointer does but with Temporal Safety guarantee.  


This language will take at-least 8 years to completely mature, we recommend you to stay tuned. Early Versions of C* will be released with complete LLVM/CLang Source code with in few years. 

 

Acknowledgement: 

Evan , lead developer of Vale Programming Language for his excellent article at https://verdagon.dev/home

https://verdagon.dev/blog/when-to-use-memory-safe-part-1#the-safer-way-to-use-mmm-languages

 

No comments:

Post a Comment

C*: C Lang Sucessor

C*[C-Star] is a successor language to C, which allows quick rewrite of existing C Code to a more memory safe platform along with modern lang...