SkillAgentSearch skills...

MyraLang

Myra is a statically-typed, compiled language in the Pascal/Oberon tradition. It transpiles to C++23 and uses Zig as a build backend, producing real x86-64 executables and libraries for Windows and Linux. The backend is invisible. You write Myra. You get binaries. Myra - Pascal. Refined.

Install / Use

/learn @tinyBigGAMES/MyraLang

README

<div align="center">

Myra

Discord Follow on Bluesky

</div>

What is Myra?

Myra is C++23. You just write it in Pascal syntax.

Under the hood, Myra compiles to C++ 23 and uses Zig as the build system. That means you get everything C++ 23 gives you: the full standard library, every platform target Zig/clang supports, every optimization the compiler can produce, without writing a line of C++. You write clean, structured Pascal-style code. Myra handles the rest.

module exe hello;

begin
  writeln("Hello from Myra! 🚀");
end.

When you need to drop to raw C++, to call a C++ API directly, include a header, or write a helper that C++ expresses better, you can do that inline, without leaving your source file. cppstart header / cppstart source / cppend inject raw C++ into the generated output. cpp("expression") embeds a C++ expression at any call site. It is not an escape hatch. It is a designed feature. The standard library itself uses it.

Myra takes its syntax philosophy from Oberon: start with Pascal and remove everything that is not essential. What remains is clean, readable, and unambiguous. begin..end blocks, := assignment, strong static typing, and a module system that replaces header files entirely. No cruft, no legacy baggage. Just the parts of Pascal that were always right.

The entire toolchain ships in the box. Zig, clang, the C++ runtime, the standard library, the LSP server, the debugger adapter: everything needed to go from source to native binary is included in the release. There is nothing to install, configure, or set up. You unzip, add bin\ to your PATH, and write code.

🎯 Who is Myra For?

Myra is for developers who want native performance and low-level control without fighting the language. If you are building any of the following, Myra is worth a look:

  • Systems software: Write low-level code with full pointer arithmetic, packed structs, union types, and direct memory management. Myra does not hide the machine from you.
  • Game engines and tools: Call C libraries (SDL3, raylib, etc.) directly via FFI with no boilerplate. Target Windows and Linux from the same codebase. Shared library interop is a first-class feature, not an afterthought.
  • DLL / shared library development: Export clean C-linkage APIs from a Myra dll or lib module and consume them from any language that speaks C ABI.
  • Cross-platform CLI tools: Compile once, run on Windows and Linux64. WSL2 integration means you can build and test Linux binaries without leaving Windows.
  • Embedded tooling: Small, predictable binaries with configurable optimization levels (releasesmall, releasefast, releasesafe). The Zig backend produces tight output.
  • Learning systems programming: Pascal-family syntax is famously readable and explicit. Myra adds modern ideas while keeping the code approachable for people coming from high-level languages.

✨ Key Features

Myra is a complete language for systems-level development. These are the capabilities that ship today:

  • 🔧 Pascal-family syntax: Clean, readable, case-insensitive. begin..end blocks, := assignment, strong typing throughout. Familiar to Pascal and Delphi developers; readable even to those who are not.
  • 🎯 Native binaries: Compiles to real x86-64 executables, DLLs, and static libraries. No VM, no bytecode, no interpreter. The output runs bare metal.
  • 🌐 Cross-platform: Target Windows (Win64) or Linux (Linux64) from the same source. Cross-compile from Windows via WSL2 with no additional configuration.
  • 🔗 FFI / C interop: Call any C library with external declarations and "C" linkage. Full varargs support for printf-style APIs. Perfect ABI compatibility — structs, unions, anonymous unions, and bit fields map directly to their C equivalents with no manual adjustment.
  • 🔄 C Header Importer: TMyraCImporter converts C headers into ready-to-use Myra modules automatically. Point it at a .h file and it preprocesses with Zig/Clang, parses all declarations, and emits a complete .myra binding with the correct types, signatures, and cross-platform directives — no manual tweaking required.
  • 📦 Module system: Three module kinds: exe (executable), dll (shared library), lib (static library). A clean import mechanism wires them together without header files.
  • 🧬 Rich type system: Records with inheritance and field alignment, classes with methods and virtual dispatch, unions, enums, sets, fixed and dynamic arrays, typed and untyped pointers, routine types, and bit fields.
  • ⚠️ Structured exception handling: try/except/finally with full hardware exception support for divide-by-zero, access violations, and other CPU-level faults.
  • 🔄 Routine overloading: Multiple routines with the same name resolved by parameter signature. The C++ backend handles name mangling transparently.
  • 📊 Sets: Pascal-style bit-set types backed by a 64-bit integer. Full set arithmetic: membership (in), union (+), intersection (*), and difference (-).
  • 📝 Managed strings: Reference-counted UTF-8 string and UTF-16 wstring types with automatic lifecycle management. Emoji, CJK, and accented characters work without any special handling.
  • 💾 Full memory control: new/dispose for class instances, getmem/freemem for raw allocation, resizemem for reallocation. You decide what lives where.
  • 🔢 Variadic routines: Define your own variadic routines with .... Access argument count and values via varargs.count and varargs.next(T).
  • 🏷️ Version info and icons: Embed metadata and application icons into Windows executables via directives. No post-build steps or resource compilers required.
  • 🔀 Conditional compilation: $ifdef/$ifndef/$elseif/$else/$endif with predefined platform symbols. Write platform-specific code in the same file cleanly.
  • 🛠️ Built-in CLI: The myra command scaffolds new projects, builds, runs, and cleans with a single command. No Makefiles, no CMake, no build configuration required for the common case.
  • 🔌 Language Server Protocol: A full LSP server ships with Myra and works with any LSP-compatible editor. Run it out-of-process as MyraLSP.exe or embed it in-process via the TMyraLSPServer class.
  • 🐛 Integrated debugger: DAP-compatible debugger integration via LLDB. The $breakpoint directive records source locations into a .breakpoints file that the debugger loads automatically. An interactive debug REPL is included for command-line debugging.
  • Built-in test blocks: test "name" begin ... end; blocks for inline unit tests, compiled and run as part of the test suite with colour-coded pass/fail output.

🚀 Getting Started

Every Myra program is a module. The module kind (exe, dll, or lib) is declared at the top of the file and determines what artifact gets built. An executable module has a begin..end. body that serves as the program entry point. There is no main() to wire up, no boilerplate to write.

Here is a complete program that demonstrates cross-platform conditional compilation and the writeln format string syntax:

module exe hello;

//$target win64
//$target linux64

begin
  $ifdef TARGET_WIN64
  writeln("Hello from Myra, running on WIN64");
  $elseif TARGET_LINUX64
  writeln("Hello from Myra, running on LINUX64");
  $else
  writeln("Hello from Myra, running on UNKNOWN");
  $endif

  writeln("Name: {}, Age: {}", "Jarrod", 42);
  writeln("Pi is approximately {:.4f}", 3.14159);
  writeln("Hex: 0x{:X}, Octal: {:o}", 255, 255);

  writeln("Hello 🌍 World!");
end.

The writeln statement accepts a format string with {} placeholders that are matched left-to-right to the arguments that follow. Standard format specifiers are supported inside the braces: {:.4f} for fixed-point precision, {:X} for uppercase hex, {:o} for octal, and more. The write statement works identically but does not append a newline.

The $target directive (commented out above) lets you lock a source file to a specific platform. When left commented, the compiler target is controlled at the command line or from the build configuration. The TARGET_WIN64 and TARGET_LINUX64 symbols are injected automatically based on the active target, so you can write portable code that branches cleanly at compile time.

📖 Language Tour

Routines

Routines are the basic unit of abstraction in Myra. They are declared with the routine keyword and can return a value using return. Parameters are passed by value (as const) by default. Use var to pass by reference when you need the routine to modify the caller's variable. Routines can be overloaded, meaning multiple routines can share the same name as long as their parameter signatures differ.

Local type, const, and var sections can appear inside a routine body before the begin block, keeping definitions scoped to where they are needed.

module exe routines;

routine add(const a: int32; const b: int32): int32;
begin
  return a + b;
end;

// Routine overloading - same name, different types
routine max(const a: int32; const b: int32): int32;
begin
  if a > b then return a; end;
  return b;
end;

routine max(const a: float64; const b: float64): float64;
begin
  if a > b then return a; end;
  return b;
end;

// Recursion
routine fib(const n: int32): int32;
begin
  if n <= 1 then return n; end;
  return fib(n - 1) + fib(n - 2);
end;

// var parameter - modified in place
routine inc(var x: int32);
begin
  x := x + 1;
end;

var
  x: int32;

begin
  writeln("add(3, 4) = {}", add(3, 4));
  writeln("max int = {}", max(3, 7));
  
View on GitHub
GitHub Stars14
CategoryDevelopment
Updated1mo ago
Forks4

Languages

Pascal

Security Score

80/100

Audited on Mar 2, 2026

No findings