Welcome to the Barn Programming Language Documentation 🔮
Introduction
Welcome to the official documentation for Barn, a modern and versatile programming language designed for simplicity and efficiency. Whether you're a seasoned developer or just starting your coding journey, this documentation serves as your comprehensive guide to understanding and harnessing the power of Barn.
Table of Contents
Getting Started
Installation Guide
Before you can dive into the world of Barn, you need to install the Barn compiler and set up your development environment. The installation guide provides step-by-step instructions for various platforms, ensuring a smooth start to your Barn programming journey.
If you're using a Linux, MacOS or other Unix-Like operating system you can easily build Barn using commands below. Make sure that GCC (or any other C compiler) and Makefile is installed on your machine.
git clone https://github.com/barn-lang/barn && cd barn
make CC=gcc
make install
barn --version
If you are using Windows
idk i don't have windows so i can't test it rn lol (this is just for now)
Hello, World! in Barn
Let's kick things off with a simple "Hello, World!" program in Barn. This introductory example will familiarize you with the basic syntax and structure of a Barn program, setting the stage for more complex projects.
@import "std.ba"
fun main() -> i32 {
println("Hello, World!")
return 0
}
- import "std.ba": This line imports the standard library module named "std.ba" into your Barn program. The "std.ba" module likely contains essential functions and utilities that are commonly used in Barn programs. By importing it, you gain access to these functionalities, making your code more powerful and versatile.
- fun main() -> i32: This line declares the main function, the entry point of the Barn program. The -> i32 specifies that the main function returns an integer (i32).
- println("Hello, World!"): Inside the main function, this line calls the println function, likely provided by the "std.ba" module. It prints the string "Hello, World" to the standard output, making it visible when you run the program.
- return 0: The main function concludes with return 0, indicating that the program executed successfully. In many programming languages, a return value of 0 conventionally signifies that the program terminated without errors.