Setting Up Your Environment
Last updated
Last updated
Before we can start writing Bend code, we need to install the Bend compiler and its runtime environment. Bend is built on top of Rust, so you’ll need to have Rust installed on your system. Here’s how you can get everything set up:
Bend requires the Rust programming language’s nightly version. To install Rust, follow these steps:
Visit the Rust website at .
Follow the instructions to download and install rustup
, which is Rust’s installation and version management tool.
Once rustup
is installed, open a terminal and run the following command to install the nightly version of Rust:
Make Rust nightly your default version by running:
Step 2: Install Bend
With Rust set up, you can now install Bend. Open a terminal and run the following commands:
This will install both the HVM2 runtime and Bend language compiler.
To ensure that Bend has been installed correctly, run:
You should see a list of available commands and options for the Bend compiler.
While you can write Bend code in any text editor, using an editor with Rust support will make your life easier due to syntax highlighting and other helpful features. Here are some recommendations:
Visual Studio Code with the Rust extension
IntelliJ IDEA with the Rust plugin
Sublime Text with Rust Enhanced package
Setting Up Your First Project
Create a new directory for your Bend project and navigate into it:
Inside this directory, create a new file named main.bend
which will be our entry point for Bend programs.
Open main.bend
in your text editor and type in the following code:
Compiling and Running Your Code
To compile and run your Bend program, you’ll use the bend
command followed by the run
subcommand and the file name:
You should see the output Hello, Bend!
in your terminal.
Congratulations! You’ve successfully set up your Bend development environment, written a simple program, and executed it. In the next chapter, we’ll dive into the basics of the Bend programming language and start writing some real code.
(Source: )