[!TIP]
Burnlang is on hold at the moment because of personal preferences
Burnlang
Burn is an easy-to-use general-purpose programming language designed with simplicity and expressiveness in mind.
[!WARNING]
Burn is not ready for Production! Syntax may still change and functions may not work. Please Report bugs as Issues
Features
- Clean, readable syntax
- Strong and static typing
- First-class functions
- Struct-based type system
- Import system for code organization
- Built-in REPL for interactive development
Installation
Prerequisites
Building from Source
- Clone the repository:
git clone https://github.com/burnlang/burn.git
cd burn
- Build the project:
go build
- Run the executable:
# On Unix/Linux/macOS
./burn
# On Windows
./burn.exe
Usage
Burn can be used in several ways:
Execute a Burn file
burn path/to/file.bn
Start the REPL (interactive mode)
burn -r
Evaluate code directly
burn -e 'print("Hello, World!")'
Compile to standalone executable
burn -exe path/to/file.bn
This compiles your Burn program into a standalone executable that can be run without the Burn interpreter. The executable will be named after your source file (e.g., file.exe on Windows or file on other platforms).
You can also specify a custom output name:
burn -exe path/to/file.bn custom-name
The compiled executable includes the Burn runtime and all imported dependencies, so it can be distributed and run without requiring Burn to be installed.
Example
# Compile
burn -exe test/class.bn
# Run the executable
./class # On Unix/Linux/macOS
./class.exe # On Windows
Debug mode
Add the -d flag to see tokens, AST, and execution details:
burn -d path/to/file.bn
Language Syntax
Variables
var name = "John"
var age = 30
const PI = 3.14159
Functions
fun add(a: int, b: int): int {
return a + b
}
Types
type Person {
name: string,
age: int,
active: bool
}
var person = {
name: "John",
age: 30,
active: true
}
print(person.name)
Classes
// Classes provide a way to organize related functions
class Human {
fun create(name: string, age: int): Human {
return {
name: name,
age: age
}
}
fun greet(human: Human): string {
return "Hello, " + human.name + "!"
}
}
fun main() {
var john = Human.create("John", 30)
print(Human.greet(john))
}
Control Flow
// Define variables before using them
var x = 3
var counter = 0
// If statements
if (x > 5) {
print("x is greater than 5")
} else if (x == 5) {
print("x equals 5")
} else {
print("x is less than 5")
}
// While loops
while (counter < 3) {
print("Counter: " + toString(counter))
counter = counter + 1
}
// For loops
for (var i = 0; i < 3; i = i + 1) {
print("Loop iteration: " + toString(i))
}
Imports
import "test/utils.bn"
fun main() {
var result = power(2, 3) // Using imported function
print("2^3 = " + toString(result))
}
Built-in Functions
print(value): Display values to console
toString(value): Convert a value to string
input(prompt): Read user input with a prompt
Examples
Check the test directory for example programs:
Project Structure
cmd/: Command-line interface
pkg/: Core packages
ast/: Abstract syntax tree definitions
lexer/: Tokenization of source code
parser/: Parsing tokens into AST
typechecker/: Type checking system
interpreter/: Runtime execution
Contributing
Contributions are welcome! Here's how you can contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add some amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
Please make sure your code follows the existing style and includes appropriate tests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Thanks to all contributors who have helped shape the Burn language
- Inspired by modern programming languages with clean syntax
Plans For Burn
- Until language is ready for Production only master branch will be used
- Post Production Language will be self hosted
- Documentaion of the entire language with its own website
- After Selfhosting Package Manager will be next and use of other packages will be possible
- ...