I am currently working on other projects that I am more impressed with, I might unarchive this later for opts but this is a python interpreted language. Nothing is gonna be very fast.
Boron is a statically typed, precision-first programming language designed for expressive control flow, rich data types, and seamless package integration. This README details every aspect of the language—from basic syntax to advanced features—so you can quickly get started writing robust programs.
The goal of this language is to be a simple introduction to programming that slightly abstracts, but also expands on python to make it a mix of Java, Python, and C++ to give beginners an introduction to Object Oriented Programming.
-
Download/Clone the Repository:
Clone the Boron repository from GitHub or download the source. -
Run a Program:
Execute your Boron source file (e.g.,program.b) using the interpreter:python C:\Users\[user]\Downloads\Boron\boronlang\app.py program.b(Adjust the command according to your project setup.)
That simple! Literally grab, and go!
-
Comments:
Use#!to add inline comments. Anything after#!on a line is ignored by the parser.#! This is a comment that explains the code below -
Line Breaks and Semicolons:
Newlines (EOL) can be used to separate statements. Will be adding semicolon soon but it's unnecessary for right now.
Boron enforces types at compile time. The primary built-in types are:
- Integer: Whole numbers
Example:42 - Decimal: High‑precision numbers using
Decimal
Example:3.14 - Boolean:
trueorfalse - String: Text enclosed in double quotes
Example:"Hello, World!" - List: Ordered collection of elements, untyped
Example:
[1, 2, 3] - Array: Fixed‑size, typed collection
- Vector Unlimited-size, typed collection
- Range: A range defined by a start, stop, and increment
Example:
int myInt = 42
dec myDec = 3.14
bool myBool = true
str myStr = "Hello, World!"
list myList = [1, 2, 3]
array myArray[int][5] = [1, 2, 3, 4, 5]
vec myVec[int] = [2, 3, 4]
range myRange = (1, 9, 1)
Declare variables by specifying a type, a name, and optionally an initial value. Examples:
#! Basic variable declarations
int myInt = 42
dec myDec = 3.14
bool myBool = true
str myStr = "Hello, World!"
-
List Declaration:
list myList = [1, 2, 3] -
Array Declaration:
Specify the element type and size:array myArray[int][5] = [1, 2, 3, 4, 5] -
Vector Declaration:
Specify the element type:vec myVec[int] = [1, 2, 3, 4, 5] -
Range Declaration:
Create a range for use in loops:range myRange = (0, 9, 1) #! Defines a range from 0 to 9 with a step of 1
Boron supports standard arithmetic, comparison, logical, and compound assignment operators.
-
Arithmetic Operators:
2 + 3 #! Addition 5 - 2 #! Subtraction 3 * 4 #! Multiplication 10 / 2 #! Division 2 ** 3 #! Exponentiation (power) 10 // 3 #! Floor division 10 % 3 #! Modulus -
Comparison Operators:
myInt > 10 myInt < 10 myInt == 42 myInt != 42 true and true true or false -
Logical Operators:
bool result = (myInt > 10) or (myBool == true) bool result = (myInt > 10) and (myInt < 20) -
Compound Assignments:
myInt++ #! increments myInt by 1 myInt += 5 #! increments myInt by 5 myInt -= 2 #! decrements myInt by 2 myInt *= 3 #! compound multiplies myint by 3 myInt /= 4 #! compound divides myint by 4
if myInt == 42 {
out("Answer found!")
}
else if myInt > 42 {
out("Too high!")
}
else {
out("Too low!")
}
for (int i = 0; i < 5; i++) {
out(myArray[i])
}
bool continueLoop = true
while continueLoop {
out("Looping...")
continueLoop = false
}
int i = 2
do {
out("Hi!")
i--
} while (i > 0)
fn myFunction(int arg1, int arg2) -> bool {
if arg1 == arg2 {
-> true #! returns true if the arguments are equal
}
-> false #! otherwise returns false
}
Function calls look like this:
out(myFunction(1, 1)) #! expected to print true
out(myFunction(1, 2)) #! expected to print false
Classes are another thing that are simple and fun, to use them just create their fields and methods
class Integer {
int number
fn __init__ (class self, int this) -> {
self.number = this
}
fn add (class self, int that) -> dec {
-> self.number + that
}
}
To create an instance of a class, just create a new object of it
Integer mine = new Integer(1)
Then you can operate on it!
out("Number: " + toStr(mine.number) + ", Add 2: " + toStr(mine.add(2)))
#import Math
Imports are also really simple, just #import said package, and you can use it's methods!
Math.sin(0.5)
FizzBuzz:
#! define fizzbuzz function
fn fizzbuzz(int numinput) -> str {
if numinput % 5 == 0 and numinput % 3 == 0 {
-> "FizzBuzz"
}
else if numinput % 3 == 0 {
-> "Fizz"
}
else if numinput % 5 == 0 {
-> "Buzz"
}
else {
-> numinput
}
}
#! while true
while true {
int numinput = toInt(inp("> ")) #! take input, convert to int
str fb = toStr(fizzbuzz(numinput)) #! run it thru fizzbuzz function
out(fb) #! print
}
Quicksort:
#import Random
fn quicksort(list arr) -> list {
if length(arr) <= 1 {
-> arr
}
int pivot = arr[length(arr) // 2]
list left = []
list right = []
list equal = []
for (int i = 0; i < length(arr); i += 1) {
int value = arr[i]
if value < pivot {
left += [value]
}
else if value > pivot {
right += [value]
}
else {
equal += [value]
}
}
-> quicksort(left) + equal + quicksort(right)
}
list sample_list = Random.fill(21, 10000)
list sorted_list = quicksort(sample_list)
out("Sorted array: " + toStr(sorted_list))
Factorial:
fn factorial(int n) -> int {
if n <= 1 {
-> 1
}
-> n * factorial(n - 1)
}
int num = 100
out("Factorial of " + toStr(num) + " is " + toStr(factorial(num)))
99 Bottles of Beer:
for (int i = 99; i > 2; i--) {
out(toStr(i) + " bottles of beer on the wall, " + toStr(i) + " bottles of beer!")
out("Take one down, pass it around, " + toStr(i - 1) + " bottles of beer on the wall!")
}
out("1 bottle of beer on the wall, 1 bottle of beer!")
out("Take one down, pass it around, no more bottles of beer on the wall!")
out("No more bottles of beer on the wall, no more bottles of beer!")
out("Go to the store, buy some more, 99 more bottles of beer on the wall!")
- Additional Data Types: Planning to add full support for tuples and sets, enum, and hashed data structures. Uncertain on what the entire scope is but there is a lot to come.
- Improved Error Handling: Stack tracing is fully python based. I would like to eventually make it based in my language, so you can check what line your code is precisely on instead of printing some AST out and trying to find it that way.
- Decorators: In python, there is the ability to wrap functions in a decorator by creating a super function and calling the lesser function inside of it, expanding it's functionality. I really like this feature and plan to add it soon.
- Generics: And no, not the python way. I hope to add these in a way that resembles the syntax of java. i.e:
class Box<T> {
vec items[T]
def __init__(class self, vec items[T]) {
self.items = items
}
}
- Typecasting: As of right now, to typecast you just get a string representation by running the toType() function, Type being the type you want to change to. i.e. toString(1). i would eventually like to have syntax for this that looks like
(type) value
- Other shit: I have no clue what else to add here. A lot more to come.
If you need more info, refer to "everything.b" in the examples folder, and view the other examples. Enjoy writing Boron, a simple yet complex enough introduction to programming!