G Programming Language
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.1 KiB

The G Programming Language

A modern alternative to C intended to be fast, simple, and pleasant. Influenced by C, C++, Odin, Rust, and Zig.

Note that at present, G is highly unstable and will certainly change.


import "std:io";

main :: proc() -> s32 {
	io.print("Hello, World!\n");
	return 0;

Note that this example will not currently compile.


G is being developed on x86-64 Linux, and is untested elsewhere.


  • CMake >= 3.14, to build
  • LLVM, to build
  • Clang, for linking compiled object files


To build the G compiler on UNIX, run BuildUNIX.sh.


See ./bin/g --help for program options.

Once the compiler is itself compiled, it can compile sources into object files by running ./bin/g FILES, where FILES is replaced with a list of G source files to compile. At present, errors may not be correctly reported and the compiler may just die if any are encountered.

For example, to compile the main.g example file, run

./bin/g examples/main.g
clang llvm.o

The first command will produce two files, llvm.bc and llvm.o, the bc file is LLVM IR bitcode, and can be decompiled to LLVM IR using llvm-dis, and the o file is an object file that can be linked into an executable with the second command. The second command will output an executable file, a.out by default.


Not all todo items will necesarilly be implemented

  • Implement procedure declarations
  • Implement procedure calls
  • Implement variable declarations
  • Implement variable assignments
  • Implement integers
  • Implement reals
  • Implement arrays
  • Implement expression parsing
  • Implement expression code generation
  • Implement the type type
  • Implement multiple return values
  • Implement defer
  • Implement errdefer
  • Implement if and else
  • Implement for
  • Implement generics of some kind
  • Implement module definition
  • Implement module use
  • ...
  • Re-write compiler in G


Copyright (C) 2021, Jakob Wakeling
MIT Licence