⚡ Quick Start - 5 Minutes

Get your first FluxSharp program running in 5 minutes!

This guide will show you how to compile and run a simple program. No prior experience is required!

Step 1: Build the Compiler (1 minute)

The FluxSharp compiler is written in Rust. You will need to build it once.

# 1. Navigate to the compiler directory cd flux_compiler

2. Build the project in release mode (optimized)

cargo build --release

3. Return to the root directory

cd ..

This command compiles the

fluxc

binary and places it in

flux_compiler/target/release/

.

Step 2: Create Your First Program (1 minute)

Create a file named

hello.fsh

with the following content: ``

rust:hello.fsh class Main { public void main() { print("Hello, FluxSharp!"); } }

> [!NOTE] > - Every FluxSharp program needs a

Main

class with a

main()

method. > -

print()

is a built-in function to display text. > - Statements end with a semicolon

;

.

Step 3: Compile and Run (1 minute)

Use the

build.sh

script to compile and run your file.

bash ./build.sh hello.fsh

You should see the output:

text Hello, FluxSharp!

🎉 Success! You have run your first FluxSharp program!


Exploring Variables

Let's modify

hello.fsh

to use variables.

rust:hello.fsh class Main { public void main() { int age = 25; string name = "Alice"; print("Hello, " + name + "! You are " + age + " years old."); } }

Run it again:

bash ./build.sh hello.fsh

Expected output:

text Hello, Alice! You are 25 years old.

Basic Math Operations

FluxSharp handles arithmetic simply.

rust:hello.fsh class Main { public void main() { int x = 10; int y = 20; int sum = x + y; print("The sum of x and y is: " + sum); // Displays: 30 } }

`

String concatenation with numbers is automatically handled by the

print

function.


What You've Learned ✅

Concept

Description

Compilation

How to use

cargo build

to create the compiler.

Execution

How to use

build.sh

to compile and run

.fsh

files.

Basic Syntax

The

class Main

structure and the

main()

method.

Variables

Declaring variables with

int

and

string

.

print()` Function

Displaying text and variables.

Next Steps

Explore more advanced concepts:

  • Data Types: Discover all available types in TYPES.md.

  • Functions: Learn to write your own functions with FUNCTIONS.md.

  • Classes: Dive into object-oriented programming with CLASSES.md.

Troubleshooting

Error: "Missing semicolon" Don't forget to add a

;

at the end of each statement.

Error: "Undefined variable" Make sure to declare variables before using them.

Consult the Error Guide for a complete list of errors.


Happy coding! 🚀 Having trouble? Check ERROR_GUIDE.md