Skip to content

Quick Start Guide

Installation

Prerequisites

Choose your platform and install dependencies:

Linux (Ubuntu/Debian)
sudo apt-get update
sudo apt-get install build-essential cmake pkg-config libcurl4-openssl-dev libjsoncpp-dev
Linux (Fedora/RHEL)
sudo dnf install gcc-c++ cmake pkgconfig libcurl-devel jsoncpp-devel
Linux (Arch)
sudo pacman -S base-devel cmake curl jsoncpp
macOS
brew install cmake curl jsoncpp
Windows (Visual Studio)
# Install Visual Studio with C++ workload, then:
cmake -B build -S .
cmake --build build --config Release
Windows (MSYS2 - Alternative)
# In MSYS2 MINGW64 terminal:
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-curl mingw-w64-x86_64-jsoncpp make

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:

say("Hello from Neutron!");

var name = "World";
say("Hello, ${name}!");

Run it:

./neutron hello.nt

Run Tests

Verify your installation:

# Linux/macOS/Windows
python3 run_tests.py

Expected output:

================================
  Test Summary
================================
Total tests: 21
Passed: 21
Failed: 0

All tests passed!

Learn More

Quick Reference

Variables

var x = 42;
var name = "Alice";
var isTrue = true;
var empty = nil;

// Multiple declarations
var a = 1, b = 2;

Functions

fun greet(name) {
    return "Hello, " + name;
}

say(greet("World"));

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


Ready to build something awesome? Start coding! 🚀