Getting Started with FluentAI
Welcome to FluentAI! This guide will help you install FluentAI and write your first program.
Installation
FluentAI can be built from source on Linux, macOS, and Windows. You'll need Rust installed on your system.
Prerequisites
Before installing FluentAI, ensure you have:
- Rust 1.70 or later (install from rustup.rs)
- Git
- A C compiler (for linking)
Building from Source
# Clone the repository
git clone https://github.com/beamsjr/FluentAI
cd FluentAI/rust
# Build the project
cargo build --release
# The binary will be available at target/release/fluentai
Adding to PATH
To use FluentAI from anywhere, add it to your PATH:
# Linux/macOS
echo 'export PATH="$PATH:/path/to/FluentAI/rust/target/release"' >> ~/.bashrc
source ~/.bashrc
# Windows (PowerShell)
$env:Path += ";C:\path\to\FluentAI\rust\target\release"
Note: Native installers are coming soon. For now, please build from source.
Hello World
Let's write your first FluentAI program!
Create a New File
Create a file called hello.fc with the following content:
// hello.fc
$("Hello, World!").print();
Run the Program
fluentai run hello.fc
You should see:
Hello, World!
Understanding the Code
$()- Creates a printable wrapper around a string.print()- Method that outputs to the console;- Statement terminator
Project Structure
For larger projects, FluentAI uses a module-based structure:
my-project/
├── src/
│ ├── main.fc # Entry point
│ ├── lib.fc # Library code
│ └── modules/ # Additional modules
├── tests/ # Test files
├── examples/ # Example code
└── fluent.toml # Project configuration
Creating a Project
# Create project directory
mkdir my-project
cd my-project
# Create source directory
mkdir src
# Create main file
echo '$("Hello from my project!").print();' > src/main.fc
# Run the project
fluentai run src/main.fc
Basic Syntax Overview
Here's a quick overview of FluentAI's syntax to get you started:
Note on Semicolons: FluentAI requires semicolons after statements (like C#/.NET), but the last expression in a block doesn't need one as it serves as the block's return value.
Variables
// Immutable by default
let name = "Alice";
// Mutable variable
let mut count = 0;
count := count + 1;
// Constants
const MAX_USERS = 100;
Functions
// Simple function
private function greet(name: string) -> string {
f"Hello, {name}!"
}
// Lambda expression
let double = (x) => x * 2;
// Using functions
let message = greet("Bob");
let result = double(21);
Collections
// Lists
let numbers = [1, 2, 3, 4, 5];
// Maps
let user = {
"name": "Alice",
"age": 30
};
// Sets
let unique_items = #{1, 2, 3};
Control Flow
// If expression
let status = if (age >= 18) { "adult" } else { "minor" };
// Pattern matching
result.match()
.case(Ok(value), => process(value))
.case(Err(error), => handle_error(error))
.get();
// Loops
for item in items {
$(item).print();
}
Next Steps
Now that you have FluentAI installed and understand the basics, here are some suggestions for what to explore next:
- Language Guide - Deep dive into FluentAI's features
- Tutorials - Step-by-step guides for common tasks
- API Reference - Complete documentation of standard library
- Examples - Check out the examples directory on GitHub
Tip: Join our community on GitHub to ask questions and share your projects!