zax.io

A guide to the Zax programming language

View project on GitHub

Zax Programming Language

Description

Zax is a data oriented modern refresh of a compile-time language which offers high level language capabilities including low level memory access. The language does not enforce type or memory safety but can be used in a type safe manner if desired.

Goals

  • Small and performant code input
  • Fast and efficient code output
  • Data orientated design
  • Structural typing system
  • Flow control focused
  • Full meta programming and reflection
  • Prioritization of proven language features
  • Long term source compilation stability
  • Pay (in terms of cost/efficiency) for what you use
  • Build control within the language
  • Full compile-time code execution

Non Goals

  • Preprocessor
  • Enforced memory management
  • Enforced safety (although compiler rules help safety)
  • Enforced language feature usage (containing costly runtime overhead)
  • Enforced system library usage
  • Exceptions
  • Garbage collection
  • Package manager (source repository importation is favoured)
  • Object oriented modeling

Key Features

Zax is a strongly typed compile-time language with some key features:

  • Low level features
    • Raw memory access
    • Raw memory casting
    • Bitwise operations
    • Sized types and alignment
    • Manual / raw memory allocation / deallocation
    • Memory clear and memory copy
    • Custom allocators
    • Collective allocation/deallocation
    • Raw pointers and references
    • Uninitialized memory type control
    • Direct type casting
    • Allocation vs initialization control
    • union types
    • Structure of arrays or array of structure support
  • Type and Flow control features
    • Familiar flow controls
      • if, else
      • switch, case, default
      • while / until
      • redo while / redo until
      • each, in
      • each, from
    • scope control and logic grouping with break and continue
    • Arrays
    • Strongly sized integers, floating points, enums, boolean, strings
    • Enum with underlying type
    • Locally defined variables
    • Locally defined types
  • High level features
    • Sized arrays, including strings
    • unique, own, strong, weak, handle, hint, discard, and collect memory
    • Default type initialization
    • Optional functional arguments
    • Multiple functional argument returns
    • Polymorphic types and functions
    • mutable and immutable types
    • Operator overloading
    • Constructors and destructors
    • Type default value initialization (including memory allocation)
    • Lambda functions with capture
    • Member functions
    • Namespace importation control
    • Module importation direct from source control
    • Multi-shared module compilation control
    • Source preservation by asset/module management
    • Library / compiler separation
    • Type composition with inner/outer casting (without inheritance)
    • Safe type conversion using as
    • Selective runtime type information
    • defer end of scope code execution
    • private and invisible types during importation
    • Type and variable alias
    • Partial types
    • Anonymous types
    • nothing types instances
    • value polymorphism for functions
  • Asynchronous programming
    • Asynchronous function calling
    • Parallel vs sequential allocators
    • Lazy type evaluation
    • Promises
    • Tasks
    • Coroutines
  • Meta programming
    • enum meta data
    • Automatic compile-time if / else
    • Custom compile-time literals
    • Variadic functions
    • Easily defined meta-function parameters
    • compile-time code reflection
    • compile-time code execution
    • compile-time code generation
    • compile-time code checking
    • Full compile type meta-data and traits
    • Built-in build control (tooling chain/ide not required to build)
  • Other
    • Usage deprecation
    • No header files
    • Runtime code panics (with selective disabling)
    • Harmonized warning suppression code mechanisms across compilers

… and much much more …

A prototype for the zax-compiler is being developed in C++.

Credit and Inspiration

Zax was inspired by C++, C, Pascal, Java, JavaScript, Jai, Objective-C, C#, F#, and Haskell and finally pays homage to Dr. Seuss.

Basics

Enums

Type Definition

Flow Control

Functions

Discard Operator

Except Error Handling

Optional Types

Alias

Scope

Lazy Functions

Variadic Functions

Operator Overloading

Composition

Pointer and References

Memory Allocation

Custom Allocators

Handle and Hint Pointers

Strong and Weak Pointers

Constructors and Destructors

Nothing Type Instances

Arrays

Casting

Context Type

Namespacing and Importing Modules

Forward

Mutability

Meta-Functions

Meta-Types

Partial Types

Concurrency

Compiler Directives

Compiler Warnings and Errors

FAQ