Skip to content

πŸ”₯ NitroPascal - A modern Object Pascal compiler targeting native code through Zig's C++ backend.

License

Notifications You must be signed in to change notification settings

tinyBigGAMES/NitroPascal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NitroPascal

Join Facebook Group Chat on Discord Follow on Bluesky

Modern Pascal β€’ C Performance

Write elegant NitroPascal, compile to blazing-fast native code

Website β€’ Documentation β€’ Examples β€’ Contributing


πŸ“‘ Table of Contents


🎯 Introduction

NitroPascal is a next-generation Pascal compiler that bridges the elegance of Object Pascal with the raw performance of C. By transpiling Object Pascal code to optimized C++, NitroPascal aims to deliver the best of both worlds: readable, maintainable code that doesn't sacrifice speed.

πŸ”₯ What Makes It Special?

NitroPascal takes a revolutionary approach to achieving C-level performance: transpilation. Instead of interpreting or compiling directly to bytecode, NitroPascal transpiles Object Pascal code into highly optimized, idiomatic C++. This intermediate C++ representation is then compiled using Zig as a drop-in C++ compiler, with the entire build orchestrated through build.zig, unlocking:

  • 🎯 Multi-Target Compilation: Generate native binaries for Windows, Linux, macOS, and beyond
  • ⚑ Aggressive Optimization: Leverage decades of C++ compiler optimization research through Zig's LLVM backend
  • πŸ”§ Unified Build System: Simple, powerful builds with Zig's build.zig
  • 🌐 Cross-Platform Excellence: Write once in Pascal, deploy everywhere with native performance
  • πŸ”— Natural Interop: Generated C++ code interfaces seamlessly with existing C/C++ libraries

By standing on the shoulders of the C++ ecosystem while leveraging Zig's modern toolchain and preserving Pascal's elegance, NitroPascal delivers truly uncompromising performance without sacrificing developer productivity.

πŸ”„ How It Works

NitroPascal's compilation pipeline transforms your Pascal code through multiple stages for optimal performance:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Object Pascal  β”‚  Write clean, modern Pascal code
β”‚     Source      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  NitroPascal    β”‚  Parse and analyze with custom parser
β”‚   Transpiler    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Optimized C++  β”‚  Generate idiomatic, optimized C++
β”‚      Code       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Zig Compiler   β”‚  Compile with Zig (drop-in C++ compiler)
β”‚  (LLVM Backend) β”‚  Leverage LLVM optimizations
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Native Binary   β”‚  Lightning-fast executable
β”‚  Multi-Platform β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ’» Quick Example

See how elegant Object Pascal code transforms into optimized C++:

Object Pascal Source Generated C++ Code
program HelloWorld;

type
  TPoint = record
    X: Integer;
    Y: Integer;
  end;

procedure PrintPoint(const P: TPoint);
begin
  WriteLn('Point(', P.X, ', ', P.Y, ')');
end;

var
  Point: TPoint;
begin
  Point.X := 10;
  Point.Y := 20;
  PrintPoint(Point);
  WriteLn('Hello from NitroPascal!');
end.
// Optimized C++ output
#include <iostream>

struct TPoint {
  int32_t X;
  int32_t Y;
};

void PrintPoint(const TPoint& P) {
  std::wcout << L"Point(" << P.X 
             << L", " << P.Y << L")" 
             << std::endl;
}

int main() {
  TPoint Point;
  Point.X = 10;
  Point.Y = 20;
  PrintPoint(Point);
  std::wcout << L"Hello from NitroPascal!" 
             << std::endl;
  return 0;
}

πŸ’‘ Why NitroPascal?

Pascal has always been celebrated for its clarity and strong typing, making it an excellent choice for teaching and building reliable software. However, performance-critical applications have traditionally gravitated toward C/C++. NitroPascal challenges this dichotomy by:

  • Breaking the Performance Ceiling: Achieving C-level performance without abandoning Pascal's clarity
  • Modern Language Features: Bringing contemporary programming paradigms to the Pascal ecosystem
  • Zero-Cost Abstractions: High-level constructs that compile down to optimal machine code
  • Developer Experience: Maintaining the readability and maintainability that made Pascal beloved

✨ Features

Language & Syntax

  • 🎨 Clean, expressive syntax that doesn't compromise on power
  • πŸ“ Object Pascal syntax compatible with Delphi code
  • πŸ”’ Memory safety through strong typing without garbage collection overhead

Performance & Optimization

  • ⚑ C-level performance through advanced transpilation
  • πŸ”₯ Optimized runtime engineered for maximum speed
  • 🎯 Zero-cost abstractions that compile to optimal machine code

Build & Deployment

  • πŸ› οΈ Modern tooling powered by Zig's build system
  • 🌐 Cross-platform compilation for Windows, Linux, macOS, and more
  • βš™οΈ Low-level control when you need it, high-level abstractions when you don't

Interoperability

  • πŸ“¦ Seamless C/C++ interop for leveraging existing ecosystems
  • πŸ”— Natural FFI through generated C++ code
  • 🌍 Library ecosystem access to the vast C/C++ world

πŸš€ Getting Started

Download the latest release from the Releases page. All dependencies are bundled - no separate installations required!

Note: NitroPascal is currently under active development. Check the releases page for the latest version!

πŸ“š Documentation

  • Third-Party Libraries - Open source libraries used by NitroPascal
  • Website - Official NitroPascal website
  • API Reference (coming soon)
  • Language Guide (coming soon)

🀝 Contributing

We welcome contributions! NitroPascal is in active development and there are many ways to help:

  • πŸ› Report bugs and issues
  • πŸ’‘ Suggest new features
  • πŸ“– Improve documentation
  • πŸ”§ Submit pull requests

Please check our Contributing Guidelines (coming soon) for more details.

πŸ“„ License

NitroPascal is licensed under the BSD-3-Clause License.

Why BSD-3-Clause?

The BSD-3-Clause license is a permissive open-source license that provides you with:

  • βœ… Commercial Use - Use NitroPascal in commercial projects without restrictions
  • βœ… Modification - Modify the source code to fit your needs
  • βœ… Distribution - Redistribute the software freely
  • βœ… Private Use - Use NitroPascal in private/proprietary projects
  • βœ… No Copyleft - No requirement to open-source your projects built with NitroPascal

This means you can use NitroPascal to build both open-source and proprietary applications without worrying about licensing conflicts. The only requirements are to include the copyright notice and disclaimer in distributions.

πŸ™ Acknowledgments

NitroPascal builds upon excellent open-source projects:

  • LLVM - Compiler infrastructure
  • Zig - Programming language and toolchain

See THIRD-PARTY.md for complete attribution.


🚧 Status

Currently Under Construction πŸ—οΈ

NitroPascal is in active development. Star the repo to stay updated!


Built with passion for performance and elegance ⚑

Β© 2025-present tinyBigGAMESβ„’ LLC β€’ All Rights Reserved