Gem Language Guide
-Complete reference for Gem's syntax, features, and programming concepts
+Gem Documentation
+Complete guide to the Gem programming language
Getting Started
+Learn how to install Gem and write your first program. Gem is a statically-typed programming language designed for safety, performance, and developer productivity.
+Installation
+Gem is distributed as source code that you compile locally. This ensures optimal performance for your system and gives you access to the latest features.
+ +Prerequisites
+-
+
- A C compiler (GCC, Clang, or MSVC) +
- Make (on Unix-like systems) +
- Git (to clone the repository) +
Building from Source
+# Clone the repository
+git clone https://github.com/SimuCorps/Gem.git
+cd Gem
+
+# Build Gem with standard library (recommended)
+make
+
+# Or build without standard library for minimal installation
+make no-stl
+
+# Install system-wide (optional)
+sudo make install
+ This will create a gemc executable in the project directory. If you installed system-wide, you can run gemc from anywhere.
💡 Build Options
+-
+
makeormake gemc- Full build with standard library
+ make no-stlormake gemch- Minimal build without STL
+ make clean- Remove build artifacts
+ make test- Run the test suite
+
Your First Program
+Let's write a simple "Hello, World!" program to verify your installation works correctly.
+ +Create a File
+Create a new file called hello.gem:
# hello.gem - Your first Gem program
+puts "Hello, World!"
+
+# Variables with type safety
+string name = "Gem"
+int version = 1
+
+puts "Welcome to #{name} v#{version}!"
+
+# Functions
+def greet(string person) string
+ return "Hello, #{person}!"
+end
+
+puts greet("Developer")
+ Run the Program
+# Run your program
+./gemc hello.gem
+ You should see output like:
+Hello, World! +Welcome to Gem v1! +Hello, Developer!+
Interactive REPL
+Gem includes an interactive Read-Eval-Print Loop (REPL) that's perfect for experimenting with the language and testing small code snippets.
+ +Starting the REPL
+# Start the interactive shell
+./gemc
+ You'll see a prompt where you can type Gem code:
+> puts "Hello from REPL!" +Hello from REPL! +> int x = 42 +> puts x +42 +> string! message = "Mutable string" +> message = "Changed!" +> puts message +Changed! +>+
🎯 REPL Tips
+-
+
- Press Ctrl+C or Ctrl+D to exit +
- Variables persist between statements +
- Type checking works in real-time +
- Great for learning and experimentation +
Basic Concepts
+Here are the fundamental concepts you need to understand to start programming in Gem:
+ +Type Safety
+Gem is statically typed, meaning all variables must have explicit types:
+# Basic types
+int age = 25
+string name = "Alice"
+bool isActive = true
+
+# Type errors are caught at compile time
+# age = "not a number" # ❌ Error!
+ Mutability Control
+Variables are immutable by default. Use mut to make them mutable (or ! as syntactic sugar):
# Immutable by default
+string message = "Hello"
+
+# Mutable with 'mut' keyword (recommended)
+mut string mutableMessage = "Hello"
+mutableMessage = "Changed!"
+
+# Mutable with '!' suffix (alternative)
+string! altMutableMessage = "Hello"
+altMutableMessage = "Changed!"
+ Nullability Safety
+Use ? to allow variables to be nil:
# Nullable variable
+string? optionalName = nil
+optionalName = "Alice"
+
+# Must check before use
+if (optionalName != nil)
+ puts "Hello, #{optionalName}!"
+end
+ Functions
+Functions have explicit parameter and return types:
+# Function with parameters and return type
+def add(int a, int b) int
+ return a + b
+end
+
+# Function with no return value
+def greet(string name) void
+ puts "Hello, #{name}!"
+end
+ Language Overview
Gem is a statically-typed programming language designed for safety, performance, and developer productivity. It combines modern language features with compile-time guarantees to prevent common programming errors.
@@ -729,6 +944,394 @@