Getting started

πŸ‘‰ Pick the language#

Firefly Zero supports lots of programming languages:

  • πŸ¦€ Rust
  • πŸƒ Go
  • πŸ€ C and C++
  • ⚑️ Zig
  • 🐰 MoonBit

Experimental:

  • πŸŒ™ Lua
  • πŸ§ͺ Elixir
  • βŒ› Coming soon: more languages (Python, JS, Kotlin).

For simple apps and games, it’s a good idea to stick to what you already know. But if you’re ready to learn something new for better results, we recommend using Go. It’s easy to learn, sufficiently fast, and memory-safe.

πŸ“₯ Install tools#

  1. Install firefly-cli and firefly-emulator
  2. Install WebAssembly compiler for your language:
rustup update nightly
rustup component add rust-src --toolchain nightly
rustup target add wasm32-unknown-unknown
Install Zig. Make sure to select the latest stable release, NOT a “master” build.

The preferred way to build a C (or C++) app is using wasi-sdk:

  1. Go to wasi-sdk releases.
  2. Download and install the latest release for your OS.
  3. This should install wasi-sdk into /opt/wasi-sdk. If you used an alternative installation method and installed wasi-sdk in a different place, provide the absolute path to it in the WASI_SDK_PATH environment variable.
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
Nothing to install for Lua, you’re ready to go!

πŸ’» Create the project#

A new project can be created using firefly_cli new:

firefly_cli new --lang=rust hello-world
firefly_cli new --lang=go hello-world
firefly_cli new --lang=zig hello-world
firefly_cli new --lang=c hello-world
firefly_cli new --lang=cpp hello-world
firefly_cli new --lang=moon hello-world
firefly_cli new --lang=lua hello-world

In this example, it will create hello-world directory and initialize in it a new app called hello-world using your chosen programming language. Don’t think about it too hard, you can later change the project name in the config (hello-world/firefly.toml).

πŸƒ Build and run#

  1. Build and install the app: firefly_cli build
  2. Run the last built app: firefly_emulator

Have troubles using emulator? Check out the emulator user guide.

πŸ“¦ Distribute#

  1. Export an app into a zip file: firefly_cli export.

  2. Publish the file anywhere you like. For open-source projects, a good option is Github Releases.

  3. People then can download and install the app:

    firefly_cli import ./joearms.hello-world.zip
  4. Optional: add your app into the catalog: catalog.fireflyzero.com.

🧠 Further reading#

There are several things you should know to make a game:

  1. How the runtime works in general. Start by reading about firefly.toml and then go through all other pages in this documentation in order.
  2. How to make games and what patterns make it easier. We recommend reading Game Programming Patterns.

And take a look at resources for your language: