r/ProgrammingLanguages • • Mar 08 '26

I’m building a programming language (Cx) would anyone be willing to check it out and give feedback?

Building a systems language called Cx looking for design feedback

Site: https://cx-lang.com · Repo: https://github.com/COMMENTERTHE9/Cx_lang

Cx is a systems language aimed at game engines and real-time simulation. Early stage tree-walk interpreter right now, compiler backend coming.

Core goals

  • No GC, no runtime pauses
  • Deterministic memory via arenas + handles
  • Control without a borrow checker

What's working today

  • Functions with typed params, implicit/explicit returns
  • Numeric types t8..t128, f64, strings with {name} interpolation
  • Arena allocator + free checker (double-free prevention)
  • Handle<T> registry with generation counters and stale detection
  • Parameter copy modes: .copy, .copy.free, copy_into
  • when blocks with ranges, enums, and three-state bool (true/false/unknown)
  • Basic enums

Not done yet

  • Loops, structs, arrays
  • Modules, generics, stdlib
  • Compiler backend

cx

fnc greet(name: str) {
    print("hello {name}")
}
greet("Zara")
4 Upvotes

24 comments sorted by

View all comments

Show parent comment

1

u/flatfinger Mar 13 '26

IMHO, the most practical way to make programs memory safe is often to establish a set of memory-safety invariants such that, following initialization, no function would be capable of passing control to another function when the invariants don't hold unless it received control when they don't hold or some outside thread broke them.

In K&R2 C, if a function like:

    void test(int32_t *p, int32_t x, int32_t y)
    {
      if ((uint32_t)x < 1000) p[x] = y;
    }

specifies as an invariant that at all places where it is invoked, the passed pointerp must identify an int32_t-aligned region of storage with space for at least 4000 bytes following p, any of which may be set to any bit pattern without violating any other memory safety invariants, and adequate stack space is available when the function is called, the function would be incapable of violating any memory safety invariants unless one had already been violated somewhere.

While program-language constructs to manage invariants may be helpful, what's IMHO more important is limiting set of operations that would be even capable of violating any of them, since functions that contain no such operations wouldn't need to be substantively examined (beyond observing the lack of possibly dangerous operations) to prove that a program is memory safe.

If, however, something like a signed integer multiply that is performed in some other part of the program could cause a compiler to bypass the if test above in circumstances where x might exceed 999, that will vastly increase the difficulty of memory safety analysis.