Skip to content
callstackexceedPublic

About

Bang is a modern statically typed compiled programming language that makes it easy to develop simple and efficient programs.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

The Bang Programming Language

Bang is a modern statically typed compiled programming language that makes it easy to develop simple and efficient programs. While preserving the low-level capabilities of C, Bang introduces modern features such as postfix type annotations, default immutability, slices, strings, and object-oriented programming. It compiles directly to human-readable C code that is compatible with existing C toolchains.

Core Features of Bang

  • C-like performance - By compiling to C, Bang achieves C-level performance optimization through existing C compilers.
  • Modern type system - Bang has static typing with default immutability and explicit mutability.
  • Structs & Classes - Bang supports object-oriented programming, including single inheritance and polymorphism.
  • Built-in slices & strings - Slices and strings are first-class citizens with length information.
  • C ABI Compatibility - Call C functions and use the extensive C ecosystem.
  • Minimal runtime overhead - Output is standard C code, which just needs to be linked with a small runtime, bang.c.
  • Self-hosted compiler - The Bang compiler is written entirely in Bang and can compile itself in seconds.

Build from Source

Prerequisites

  • GCC (or Clang)
  • GNU Make
  • A POSIX-compliant environment (Linux/macOS/WSL)

Building Process

git clone https://github.com/callstackexceed/bangc.git
cd bangc
make # windows user can run make -f windows.make

Now you have a self-hosting Bang compiler bangc in the current directory.

Explanation of what make did : Bang uses a two-stage bootstrap:

  • Build the bootstrap compiler from a pre-generated bootc.c.
  • Compile the full Bang compiler using bootc.

Hello, World

extern "C" func puts(str: [*]char): int;

func main(): int {
    puts("hello, world!".data);
    return 0;
};

Compile and run:

./bangc ./hello.ba -o ./hello.c
gcc hello.c bang.c -o hello -I.
./hello # Output: hello, world!

For explanation and more introduction to features, see the Guide.

Current Status

Bang is young and currently at an early stage but is capable of compiling itself. If you find any bugs or have suggestions for features, please let me know!

License

MIT License

About

Bang is a modern statically typed compiled programming language that makes it easy to develop simple and efficient programs.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages