Skip to content

NG Programming Language Guide

Welcome to the NG programming language! This guide provides a comprehensive, progressive introduction to NG — from your first program to advanced metaprogramming.

What is NG?

NG is a modern, statically-typed, multi-paradigm programming language implemented in C++23. It features:

  • Rich type system — Generics, traits, tagged unions, nominal types, higher-kinded types
  • Ownership model — Value semantics, references, moves, partial moves
  • Compile-time metaprogramming — Const if, const predicates, const functions, type specialization
  • Dual backend — AST interpreter (STUPID) and bytecode VM (ORGASM)
  • Native FFI — Seamless C++ function binding
  • ImGui integration — Immediate-mode GUI applications

Quick Start

Build from Source

bash
git clone <repository-url> ng
cd ng
git submodule update --init --recursive
cmake -S . -B build -GNinja
cmake --build build -j

Run Your First Program

bash
./build/ngi example/01.id.ng

Try the REPL

bash
./build/ngi
>> print("Hello, World!");

Run Tests

bash
./build/ng_test

All 695+ tests pass with 3,327+ assertions.

Learning Path

Start here and follow the guides in order:

#GuideTopics
1Getting StartedBuild, first program, REPL, backends
2Basic SyntaxComments, variables, types, operators
3Control Flowif/else, loop, switch, const if
4FunctionsDefinition, recursion, native functions, methods
5Data StructuresArrays, tuples, objects, tagged unions, ranges
6Modules and ImportsModule system, export/import, path resolution
7GenericsType parameters, constraints, parameter packs
8References, Moves & Ownershipref, move, partial moves, borrowing
9TraitsDefinition, impl, bounds, objects, derive, auto traits
10Type System in DepthNominal types, inference, casting
11Compile-Time Programmingconst if, typeof, const predicates, const functions
12Advanced GenericsHKT, specialization, enhanced tuples, fold expressions
13Standard LibraryPrelude, I/O, strings, collections, tuples
14Memory ManagementHeap, GC, Drop, moves, smart pointers
15ORGASM BackendBytecode compilation, VM, native bridge
16ImGui IntegrationGUI programming with Dear ImGui

Example Programs

The example/ directory contains 59 numbered examples that correspond to these guides:

RangeTopic Area
01–14Basics: identity, definitions, functions, strings, arrays, objects, imports, loops, tuples
15Generics
16–21Tagged unions, switch, const if, union types, recursion
22–24References, moves, value semantics
25–40Traits: Show, bounds, supertraits, defaults, objects, Copy, Clone, Drop
42–47Compile-time: const predicates, specialization, native constraints
48–49Higher-kinded generics, variadic HKT
50–51Partial moves
52Const array/vector/span
53Const functions
54Enhanced tuple types
55Auto derive traits
56Standard library modules
57Ranges, slicing, pipeline
58Fold expressions
59List and sequence operations

Additional Resources

  • Design Documentsdocs/design/ — Detailed design rationales for major features
  • Internal Architecturedocs/ref/Internals.md — Compiler and runtime internals
  • Memory Modeldocs/ref/Memory.md — Memory management design
  • C++ Compatibilitydocs/ref/cxx-compatibility.md — FFI with C++

Project Status

  • Compiler Pipeline: Lexer → Parser → AST → Type Checker → Bytecode Compiler → VM
  • 695+ tests passing with 3,327+ assertions
  • 59 runnable examples demonstrating all features
  • Complete standard library with prelude, I/O, strings, collections, tuples
  • ImGui integration for GUI applications

Contributing

See CONTRIBUTING.md for guidelines. Notable points:

  • Use conventional commits (feat:, fix:, chore:)
  • All C++23 with RAII and const correctness
  • Tests use Catch2 v3 (vendored)
  • AI-generated code must be disclosed

Made with ❤️ by the NG community.