Language Basics
Rui is designed with a clean, readable syntax that minimizes punctuation requirements while maintaining clarity and expressiveness.
Syntax Overview
Rui uses a simple, intuitive syntax that focuses on readability. Here's a basic example:
// Simple program
write("Hello, World!")
suppose name = "Alice"
write("Hello " + name)Key characteristics of Rui syntax:
- Minimal punctuation: No semicolons required, clean and readable
- Descriptive keywords: Use
supposefor variables,definefor functions - Flexible formatting: Statements can be terminated with newlines or semicolons
- Clear structure: Code blocks use curly braces for organization
Statement Termination
Rui provides flexibility in how you terminate statements. Both newlines and semicolons are supported:
suppose x = 10
suppose y = 20;
write(x + y)This flexibility allows you to write code in a style that feels natural to you:
- Newline termination: Most common approach, keeps code clean
- Semicolon termination: Useful for multiple statements on one line
- Mixed usage: You can mix both styles in the same file
Code Organization
Rui uses curly braces to organize code into blocks:
// Function definition
define greet(name) {
write("Hello, " + name + "!")
}
// Conditional statement
if (age >= 18) {
write("You are an adult")
} else {
write("You are a minor")
}
// Loop structure
until (count < 5) {
write("Count: " + count)
suppose count = count + 1
}Comments
Rui supports both single-line and multiline comments:
// This is a single-line comment
suppose name = "Alice" // Inline comment
/*
This is a multiline comment
that can span multiple lines
and is completely ignored
*/
suppose age = 25Best Practices
- Use descriptive variable names: Choose names that clearly indicate purpose
- Consistent formatting: Pick a style and stick with it throughout your code
- Add comments for complex logic: Explain what your code does, especially for non-obvious operations
- Organize code logically: Group related statements together
Understanding these basics will help you write clean, readable Rui code. The language is designed to be intuitive, so you can focus on solving problems rather than fighting syntax.