A programming language focused on performance and simplicity.
Sapphire is designed for developers who value efficiency, clear syntax, and a comprehensive built-in ecosystem, minimizing external dependencies.
Discover SapphireWhy Choose Sapphire?
Sapphire isn't just another language; it's a philosophy. We believe in providing a powerful, yet intuitive, development experience from the ground up.
High-Performance Core
Sapphire's main interpreter is meticulously crafted in C++ to ensure your applications run with exceptional speed and efficiency, leveraging low-level power.
Batteries Included Ecosystem
Forget dependency hell. Sapphire aims to provide a comprehensive set of built-in functionalities, from UI to networking, so you can focus on building, not configuring.
Clear and Expressive Syntax
Designed for readability and developer ergonomics. Sapphire's syntax is clean, minimizing boilerplate and allowing your logic to shine through effortlessly.
Cross-Platform by Design
Built with portability in mind, Sapphire applications are designed to run consistently across various operating systems, simplifying deployment and reach.
Get to Know the Syntax
Explore various Sapphire code examples, from basic operations and data types to complex UI interactions and system calls. Our syntax is designed to be intuitive and powerful.
// Basic variable declaration and arithmetic operations
int a = 20;
int b = 10;
double c = 25.5;
// Mixed-type arithmetic, result is double
double result = a - b * c;
print "Result: " + valueToString(result);
// Boolean logic and type inference
bool isTrue = true;
bool isFalse = false;
print valueToString(isTrue and isFalse);
// String concatenation
string greeting = "Hello";
string target = "World";
print greeting + ", " + target + "!";
// Function declaration with parameters and return type
function calculateArea(double length, double width) double {
return length * width;
}
// Function returning void (no return value)
function greet(string name) void {
print "Hello, " + name + "!";
}
// Recursive function example (Factorial)
function factorial(int n) int {
if (n == 0) {
return 1;
}
return n * factorial(n - 1);
}
// Function call and variable assignment
double roomArea = calculateArea(10.5, 8.0);
print "Room area: " + valueToString(roomArea);
greet("Sapphire User");
print "Factorial of 5: " + valueToString(factorial(5));
// Class declaration with fields and methods
class Button {
string label;
bool isClicked;
function click() void {
this.isClicked = true;
print this.label " was clicked!";
}
}
// UI application structure (requires --no-console flag for packed executable)
function updateUI() void {
UI.SetNextWindowPos(50, 50);
UI.SetNextWindowSize(300, 150);
if (UI.Begin("My App")) {
UI.Text("Welcome to Sapphire UI!");
class myButton = Core.createInstance("Button");
myButton.label = "Click Me!";
if (UI.Button(myButton.label)) {
myButton.click();
}
}
UI.End();
}
// Accessing system environment variables
string pathVar = System.getEnv("PATH");
if (pathVar != nil) {
print "PATH variable: " + valueToString(pathVar);
} else {
print "PATH variable not found.";
}
// Working with dynamic arrays (lists)
class myList = ListUtil.create();
ListUtil.append(myList, "apple");
ListUtil.append(myList, "banana");
ListUtil.append(myList, 123);
print "List element at index 0: " + valueToString(myList[0]);
print "List length: " + valueToString(ListUtil.length(myList));
The Future of Sapphire
The language is just getting started. Here are some of our major goals for the future.
JIT Compilation
Implement a Just-In-Time (JIT) compiler for critical code paths, aiming for near-native performance and significantly boosting execution speed.
Advanced Error Handling & Debugging
Develop robust error reporting with native stack traces, more informative messages, and an integrated debugger for smoother development.
Comprehensive Standard Library
Expand the standard library with extensive modules for file I/O, networking, data structures, and more, ensuring batteries-included development.
Cross-Platform Installer
Simplify the installation process across Windows, macOS, and Linux, making Sapphire easily accessible to developers on any operating system.
Database Bindings
Provide native bindings for common database systems (e.g., SQLite, PostgreSQL), enabling seamless data persistence directly from Sapphire.
Concurrency Primitives
Introduce built-in primitives for concurrency, allowing developers to write high-performance parallel applications with ease.
License
MIT License
Sapphire is open-source software released under the **MIT License**. This permissive license allows you to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software.
For more details, please read the full MIT License on Open Source Initiative.
Join Our Community
Sapphire is a community-driven project. Your contributions, feedback, and ideas are invaluable as we grow and evolve the language.
Contribute Code
Help us improve the core language, build new native modules, or enhance the tooling. Check out our GitHub for open issues.
Share Your Ideas
Have a feature request or a new use case for Sapphire? Join our discussions and share your vision for the language's future.
Report Bugs
Found an issue? Your bug reports help us make Sapphire more stable and reliable for everyone. Submit them on our GitHub repository.
Getting Started with Sapphire
Ready to dive into Sapphire? Follow these simple steps to set up your development environment and run your first Sapphire script.
1. Download Tools
Obtain the latest Sapphire compiler (sapphirec.exe
) and packer (spack.exe
) from our GitHub releases page. Place them in a convenient directory.
2. Configure Environment
Ensure your C++ compiler (like MinGW's g++) and SFML libraries are correctly set up and accessible via your system's PATH or environment variables.
3. Write Code
Create your first .sp
file. Start with a simple "Hello, World!" program or explore the syntax examples above.
4. Compile & Pack
Use sapphirec.exe
to compile your .sp
to .sbc
bytecode, then use spack.exe
to package your bytecode into a standalone executable.
5. Run Your App
Execute your newly created Sapphire application! Enjoy the performance and simplicity of your code.