Verse is Epic Games' new programming language for Unreal Editor for Fortnite (UEFN) and future Unreal Engine projects. It combines functional programming concepts with a visual game development workflow.
Why Verse Matters
Unreal Engine uses C++ and Blueprints (visual scripting). Verse sits in between — more accessible than C++, more powerful than Blueprints, with unique features like failure contexts and speculative execution.
What you get for free:
- Native Unreal Engine integration
- Failure contexts (like try/catch but more powerful)
- Speculative execution for game logic
- Gradual typing (start loose, add types as you go)
- Concurrency primitives designed for games
- Built-in support for Fortnite Creative modding
The Basics
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
hello_world_device := class(creative_device):
OnBegin<override>()<suspends> : void =
Print("Hello from Verse!")
# Variables
Name : string = "Verse"
Score : int = 100
IsActive : logic = true
Print("Name: {Name}, Score: {Score}")
Functions
# Pure function
Add(A : int, B : int) : int =
A + B
# Function with failure context
SafeDivide(A : float, B : float)<decides><transacts> : float =
if (B = 0.0):
false? # Fail — caller must handle
A / B
# Using failable functions
Calculate() : void =
if (Result := SafeDivide(10.0, 3.0)):
Print("Result: {Result}")
else:
Print("Division failed")
Classes and Inheritance
weapon := class:
Name : string
Damage : int
FireRate : float
Fire() : void =
Print("{Name} fires for {Damage} damage!")
Reload()<suspends> : void =
Print("Reloading {Name}...")
Sleep(2.0)
Print("{Name} reloaded!")
rifle := class(weapon):
BurstCount : int = 3
Fire<override>() : void =
for (I := 0..BurstCount):
Print("Burst {I}: {Damage} damage!")
Failure Contexts (Key Feature)
# 'decides' means this function can fail
FindPlayer(Name : string)<decides><transacts> : player =
for (P : Players):
if (P.Name = Name):
return P
false? # Fail if not found
# Caller handles failure naturally
GreetPlayer() : void =
if (Player := FindPlayer("Alice")):
Print("Hello, {Player.Name}!")
else:
Print("Player not found")
# Chain failable operations
ComplexQuery()<decides><transacts> : result =
Player := FindPlayer("Alice")
Weapon := Player.GetEquippedWeapon()
if (Weapon.Damage > 50):
return result{Player := Player, Weapon := Weapon}
false?
Concurrency for Games
game_manager := class(creative_device):
OnBegin<override>()<suspends> : void =
# Run multiple game systems concurrently
race:
SpawnEnemies()
ManagePowerUps()
TrackScore()
SpawnEnemies()<suspends> : void =
loop:
Sleep(5.0)
SpawnEnemy()
Print("Enemy spawned!")
ManagePowerUps()<suspends> : void =
loop:
Sleep(15.0)
SpawnPowerUp()
Print("Power-up available!")
TrackScore()<suspends> : void =
loop:
Sleep(1.0)
UpdateScoreboard()
Arrays and Iteration
ProcessScores() : void =
Scores : []int = array{95, 87, 73, 62, 88}
# Filter and transform
HighScores := for (Score : Scores, Score > 80):
Score
# Sum
var Total : int = 0
for (Score : HighScores):
set Total += Score
Print("High score total: {Total}")
Useful Links
Building game data pipelines? Check out my developer tools on Apify for ready-made web scrapers, or email spinov001@gmail.com for custom solutions.
Top comments (0)