📚 B3D Documentation

Complete guide to B3D Programming Language v1.3.4

🚀 Getting Started

B3D is a modern programming language designed for high performance and ease of use. This guide will help you get started in minutes.

What is B3D?

B3D is a structured, high-performance programming language with:

  • Native compilation to fast binaries
  • Python interoperability
  • AI integration (OpenAI, Anthropic, Google)
  • Built-in package manager
  • Cross-platform support

System Requirements

  • Windows 7+ (x86_64)
  • Linux x86_64 or ARM64
  • macOS (Intel or Apple Silicon)

⚙️ Installation

Quick Install (Recommended)

The easiest way to install B3D is using our automated installers:

Linux / macOS

curl -sSL https://b3d.berkeai.com/install-b3d.sh | bash

Windows (PowerShell)

iwr -useb https://b3d.berkeai.com/install-b3d-windows.ps1 | iex

Manual Installation

Download the binary directly from the downloads page and add it to your PATH.

Verify Installation

b3d --version

You should see the version number displayed.

📖 Language Basics

Hello World

Create a file named hello.b3d:

config {
    name: "hello"
    version: "1.0.0"
}

fn main() {
    print("Hello, B3D!")
}

Run it with:

b3d run hello.b3d

File Structure

Every B3D program has:

  • config - Program metadata (name, version)
  • main() - Entry point function

📦 Variables

Variables are declared with automatic type inference:

// Numbers
x = 42
pi = 3.14159

// Strings
name = "B3D"
message = "Hello, World!"

// Lists
numbers = [1, 2, 3, 4, 5]
mixed = [1, "two", 3.0, true]

// Boolean
active = true
enabled = false

Integers

Whole numbers: 42, -10, 0

Floats

Decimal numbers: 3.14, 2.5

Strings

Text data: "hello", 'world'

Booleans

true or false values

🔧 Functions

Define functions with the fn keyword:

fn greet(name) {
    print("Hello, " + name + "!")
}

fn add(a, b) {
    return a + b
}

fn main() {
    greet("B3D")
    result = add(5, 3)
    print(result)
}

Function Features

  • Parameters are passed by value
  • Return type is inferred
  • Functions can be nested

🔀 Control Flow

If / Else

x = 10

if x > 5 {
    print("x is greater than 5")
} else if x == 5 {
    print("x equals 5")
} else {
    print("x is less than 5")
}

Loops

// For loop
for i in range(1, 5) {
    print(i)
}

// While loop
count = 0
while count < 3 {
    print(count)
    count = count + 1
}

📊 Data Types

Type Description Example
Integer Whole numbers 42, -10
Float Decimal numbers 3.14, 2.5
String Text data "hello", 'world'
Boolean true/false true, false
List Ordered collection [1, 2, 3]
Null No value null

📚 Built-in Libraries

String Functions

str_upper()

Convert to uppercase

str_upper("hello")

str_lower()

Convert to lowercase

str_lower("HELLO")

str_split()

Split by delimiter

str_split("a,b,c", ",")

str_trim()

Remove whitespace

str_trim(" hello ")

List Functions

list_sort()

Sort list elements

list_sort([3, 1, 2])

list_reverse()

Reverse list

list_reverse([1, 2, 3])

list_filter()

Filter elements

list_filter([1, 0, 1])

list_map()

Transform elements

list_map([1, 2, 3])

Math Functions

math_sqrt()

Square root

math_pow()

Power calculation

math_sin/cos()

Trigonometric

math_max/min()

Maximum/Minimum

Data Analysis

data_mean()

Calculate average

data_median()

Find median value

data_std()

Standard deviation

data_variance()

Calculate variance

💡 Examples

Calculator Program

config {
    name: "calculator"
    version: "1.0.0"
}

fn add(a, b) { return a + b }
fn subtract(a, b) { return a - b }
fn multiply(a, b) { return a * b }
fn divide(a, b) { return a / b }

fn main() {
    print(add(10, 5))
    print(subtract(10, 5))
    print(multiply(10, 5))
    print(divide(10, 5))
}

List Processing

config {
    name: "list-demo"
    version: "1.0.0"
}

fn main() {
    numbers = [5, 2, 8, 1, 9]
    
    sorted = list_sort(numbers)
    print(sorted)
    
    reversed = list_reverse(sorted)
    print(reversed)
    
    avg = data_mean(numbers)
    print(avg)
}

❓ Frequently Asked Questions

Is B3D free?

Yes! B3D is completely free and open-source under the MIT License.

What platforms does B3D support?

B3D runs on Windows, Linux (x86_64 and ARM64), and macOS (Intel and Apple Silicon).

Can I use Python with B3D?

Yes! B3D has seamless Python interoperability. You can import and use Python packages directly.

Does B3D have AI capabilities?

Yes! B3D has built-in support for OpenAI, Anthropic, and Google APIs.

How do I report bugs?

Please report bugs on our GitHub Issues page.

Where can I get help?

You can:

  • Read the documentation (you're reading it!)
  • Check GitHub repository
  • Open an issue on GitHub
  • Contact: hello@berkeai.com

Can I contribute to B3D?

Yes! We welcome contributions. Please visit the GitHub repository to get started.


Need more help?
Visit https://b3d.berkeai.com/ or check the GitHub repository