Skip to content

bruneo32/superc

SuperC: C11 superset language

A backwards-compatible extension of C with modern ergonomics like defer, methods, and operator overloading, without sacrificing performance and control.

⚠️ Alpha: expect bugs, missing features, and breaking changes.

License Documentation

Index

Why SuperC?

C is powerful, but unforgiving. SuperC keeps that power, while making it easier to use correctly.

SuperC does not aim to replace existing high-level languages, but rather to be a very good option for embedded systems programming. Hence, making it a great option for general purpose development too.

  • Zero‑cost abstractions - sometimes even more efficient than hand-written C.
  • No runtime overhead - no hidden allocations, no vtables.
  • Full C compatibility - use any existing C library without wrappers.
  • Multiplatform - write once, run on Linux, Windows, macOS with minimal #ifdef.
  • Great documentation - tutorials, examples, and edge cases all organized.
    No need to spend hours reading random forum posts or blindly pasting AI responses.

Read more about vision and scope here.

Features

Quick start

Right now the compiler is not reliable enough to showcase, but sure you can try to test the new features.

⚠️ Reminder: the compiler is unstable right now. Expect bugs.

Installation

# Clone
git clone https://github.com/bruneo32/superc.git
cd superc
# Build
make
# Setup compiler
alias superc="${PWD}/superc -I${PWD}/include "
# Build examples
superc example_simple.c
superc example_string.c

Examples

example_simple.c

#include <stdio.h>

int main() {
  FILE *f = fopen("example_simple.c", "r");
  defer {
    fclose(f);
    printf("File closed!\n");
  };

  printf("OK\n");
  // OK
  // File closed!
  return 0;
}

example_string.c

#include <stdio.h>
#include <string.h>

/* Silly GCC headers
 * destroy __attribute__ */
#ifdef __attribute__
#undef __attribute__
#endif

#define string char*

/* s1.length() is strlen(s1) */
inline size_t (string s1) length() {
  return strlen(s1);
}

/* s1 += s2 is strcat(s1, s2) */
string (string s1) __iadd__(const string s2) __attribute__((symbol("strcat")));

int main() {
  char s1[100] = "Hello, ";
  s1 += "world!"; // string += string

  printf("(%d) = %s\n", s1.length(), s1);
  // (13) = Hello, world!
  return 0;
}

Roadmap

  • Documentation
    • Keep documentation up-to-date.
    • Provide dual-track explanations: by-the-hand guides for beginners, and straight forward documentation for experienced developers.
    • Use examples (at least the following): simple usage, real usage, and edge cases.
  • Compiler
    1. Complete LLVM backend
      • Right now, the backend is experimental x86_64 specific, unoptimized assembly. Just meant to showcase the new language features.
    2. Complete C11 and C23 syntax
    3. Complete new language features:
      • Struct inheritance/composition
      • defer auto
      • Lambdas
      • (?) Namespaces
      • (?) HolyC "sub_switch"
      • (?) Switch goto in-switch labels.
    4. Better error messages, help, and man pages.
    5. Multiplatform support (write similar code in Linux, Windows and MacOS, etc)
      • Allow the same (safe) SuperC code to compile and run across platforms without much modification.
      • The goal is to reduce the heavy regions guarded by #ifdef macros when working with cross-platform code (for Windows mostly).
  • Standard library
    • #include <superc.h>
    • Strings
    • Arrays
    • Try/catch
    • Date
    • ...
  • Multithreading
    • Similar to goroutines, SuperC must support lightweight threads for massive concurrency, easy to use and manage resources.
    • This implies new syntax.
    • And library functions.
  • Tooling & Editor Extensions
    1. A language cannot survive today without first-class tooling. Developing a highly responsive VSCode extension powered by a robust Language Server Protocol (LSP) is a top priority.
    2. Other editors are welcome as well (Neovim, Emacs, JetBrains, ...).

Documentation

Start with Getting Started, and explore features with examples.

Contributing

SuperC is in an early stage - contributions are highly appreciated.

You can help with:

  • Compiler development
  • Design discussions
  • Documentation
  • Examples and testing

Notes

Forked from chibicc.

About

C11 superset language

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors