Quick Start Guide¶
Installation¶
Prerequisites¶
Choose your platform and install dependencies:
Linux (Ubuntu/Debian)
Windows (Visual Studio)
Windows (MSYS2 - Alternative)
Build¶
Linux / macOS¶
git clone https://github.com/yasakei/neutron.git
cd neutron
cmake -B build -S .
cmake --build build -j$(nproc)
./neutron --version
Windows (Visual Studio)¶
git clone https://github.com/yasakei/neutron.git
cd neutron
cmake -B build -S .
cmake --build build --config Release
build\Release\neutron.exe --version
Windows (MSYS2 - Alternative)¶
git clone https://github.com/yasakei/neutron.git
cd neutron
cmake -B build -S . -G "MSYS Makefiles"
cmake --build build -j$(nproc)
./neutron.exe --version
First Program¶
Create hello.nt:
Run it:
Run Tests¶
Verify your installation:
Expected output:
================================
Test Summary
================================
Total tests: 21
Passed: 21
Failed: 0
All tests passed!
Learn More¶
- README.md - Complete feature overview
- BUILD.md - Comprehensive build instructions
- Language Reference - Full language syntax
- Examples - Example programs
Quick Reference¶
Variables¶
var x = 42;
var name = "Alice";
var isTrue = true;
var empty = nil;
// Multiple declarations
var a = 1, b = 2;
Functions¶
Classes¶
class Person {
var name;
var age;
init(n, a) {
this.name = n;
this.age = a;
}
fun greet() {
say("Hi, I'm ${this.name}");
}
}
var person = Person();
person.init("Alice", 30);
person.greet();
Control Flow¶
// If-else
if (x > 10) {
say("Big");
} else {
say("Small");
}
// While loop
var i = 0;
while (i < 5) {
say(i);
i = i + 1;
}
// For loop
for (var i = 0; i < 5; i = i + 1) {
say(i);
}
Arrays¶
var numbers = [1, 2, 3, 4, 5];
say(numbers[0]); // 1
numbers[0] = 100;
say(numbers); // [100, 2, 3, 4, 5]
Modules¶
use sys;
use json;
use http;
// File I/O
sys.write("data.txt", "Hello!");
var content = sys.read("data.txt");
// JSON
var obj = {"name": "Neutron"};
var jsonStr = json.stringify(obj);
// HTTP
var response = http.get("https://api.example.com");
say(response.status);
Common Mistakes¶
⚠️ Important: .length is a property, not a method!
// ❌ Wrong
var arr = [1, 2, 3];
say(arr.length); // RuntimeError!
// ✅ Correct
say(arr.length); // 3
See the Common Pitfalls Guide for more tips!
Common Issues¶
"curl not found" or "jsoncpp not found" - Install missing dependencies (see Prerequisites above)
"CMake version too old" - Install CMake 3.15+ from cmake.org or your package manager
Visual Studio: Missing dependencies - Install Visual Studio with "Desktop development with C++" workload - Dependencies (curl, jsoncpp) are often available through vcpkg
MSYS2: Wrong terminal - Use MINGW64 terminal, not MSYS terminal
Tests fail - Check Known Issues - Ensure build completed successfully
Getting Help¶
- Documentation: docs/
- Common Pitfalls: common-pitfalls.md
- Issues: GitHub Issues
- Examples: programs/
Ready to build something awesome? Start coding! 🚀