Creating Your First Program
Welcome to Gecco! This guide will help you write, compile, and run your first program in Gecco. Let’s dive in!
Step 1: Setting Up Your Environment
Before you begin, make sure:
Gecco is installed on your system. (Refer to the Installation Guide for instructions.)
Your terminal or IDE is configured to use Gecco's compiler and tools.
Step 2: Writing Your First Program
Let’s start with the classic "Hello, World!" program. Open your preferred text editor or IDE and create a new file named hello.gec
.
Example Code: hello.gec
Explanation
class Main {}
: Defines theMain
class, which is the starting point of your program.static func main()
: Themain
function serves as the program's entry point.print
: A built-in function to print text to the console.
Step 3: Compiling Your Program
To compile your program:
Open a terminal or command prompt.
Navigate to the directory containing
hello.gec
.Run the Gecco compiler:
gecco-compiler hello.gec -o helloThis will generate an executable file named
hello
in the same directory.
Step 4: Running Your Program
Run the compiled program with the following command:
On Windows:
On Linux/macOS:
You should see the output:
Step 5: Exploring Further
Now that you've successfully created and run your first program in Gecco, here are some ideas for what to try next:
Modify the message in
println
to display your name or a custom greeting.Experiment with variables and loops (see the Language Basics page for more examples).
Build a program that takes user input and prints it back to the console.
Congratulations! You’ve just written your first Gecco program. 🎉
Need help? Check out our Community Forum or Troubleshooting Guide.