Hello World & Basics

Your first steps with B3D programming

🎯 Learning Goals

By the end of this tutorial, you will:

  • Understand B3D's program structure
  • Create your first B3D program
  • Learn about variables and basic data types
  • Use simple string interpolation
  • Run B3D programs successfully

Understanding B3D Structure

Every B3D program has a specific structure with four main blocks:

Structure

The Four Blocks

<Config> // Project configuration project_name = 'my_project' version = '1.0.0' </Config> <Include> // Import libraries and dependencies include std.io </Include> <Data> // Variable declarations message = 'Hello, World!' </Data> <Main> // Your program logic print(message) </Main>
✅ Structure Rule: All four blocks must appear in this exact order. B3D enforces this structure to keep your code organized and maintainable.

Your First B3D Program

Step 1

Create hello.b3d

Create a new file called hello.b3d and enter this code:

<Config> project_name = 'hello_world' version = '1.0.0' author = 'Your Name' </Config> <Include> include std.io </Include> <Data> greeting = 'Hello, B3D World!' name = 'Developer' version_info = 'v1.0.0' </Data> <Main> print(greeting) print('Welcome, {name}!') print('You are using B3D {version_info}') </Main>
Step 2

Run Your Program

Open your terminal and run:

b3d run hello.b3d
Expected Output:
Hello, B3D World!
Welcome, Developer!
You are using B3D v1.0.0

Understanding Variables

In B3D, variables are declared in the <Data> block and can be used throughout your program.

Types

Basic Data Types

<Data> // Strings name = 'Alice' message = "Hello World" // Numbers age = 25 height = 5.8 // Booleans is_active = true is_complete = false // Lists colors = ['red', 'green', 'blue'] numbers = [1, 2, 3, 4, 5] </Data>

String Interpolation Magic

B3D's string interpolation lets you embed variables directly in strings using {variable} syntax.

Magic

Interpolation Examples

<Data> name = 'Alice' age = 25 scores = [95, 87, 92] </Data> <Main> // Basic interpolation print('Hello {name}!') // Expression interpolation print('Next year you will be {age + 1}') // Array access print('Your first score: {scores[0]}') // Complex expressions print('Average: {(scores[0] + scores[1] + scores[2]) / 3}') </Main>

Practical Exercises

🎯 Exercise 1: Personal Introduction

Create a program that introduces yourself with your name, age, and favorite hobby.

Hint: Use string interpolation to make it dynamic!

🎯 Exercise 2: Simple Calculator

Create a program that declares two numbers and shows their sum, difference, product, and quotient.

Challenge: Use string interpolation to show the calculations!

🎯 Exercise 3: List Operations

Create a list of your favorite foods and display the first and last items.

Bonus: Show how many foods are in your list!

Common Mistakes to Avoid

  • Wrong block order: Always use Config → Include → Data → Main
  • Missing includes: Don't forget include std.io for basic functions
  • Variable scope: Declare all variables in the Data block
  • String interpolation: Use {variable} not ${variable}

🎉 Congratulations!

You've completed the basics tutorial! You now know:

  • ✅ B3D program structure
  • ✅ Variable declaration and usage
  • ✅ Basic data types
  • ✅ String interpolation
  • ✅ Running B3D programs
Next Steps: Try the String Interpolation Mastery tutorial to learn advanced interpolation techniques!