Skip to main content

Mastering Verse Primitive Types

Pick the wrong type in Verse, and you won't find out until your game does something weird at runtime. Health regenerates in fractions instead of whole numbers. A timer that should tick smoothly jumps in odd increments. Nine times out of ten, the culprit is a type mismatch you didn't even know you'd made.

Verse's type system is smaller and stricter than what you're probably used to, but that's actually a feature. Once you know what each primitive does—and why it exists—you stop fighting the compiler and start using it to catch your mistakes before they ship.

Here's what's actually going on under the hood.

Numbers: Three Types, Not Just One

Most languages give you a couple of number types and call it a day. Verse splits things up more deliberately, and once you see why, it makes sense.

int — Whole Numbers, No Surprises

An int is exactly what it sounds like: a whole number, positive, negative, or zero. Under the hood, Verse integers actually support arbitrary precision at runtime—but any literal you type directly into your code has to fit inside a standard 64-bit signed range. That's a subtle distinction, and it rarely bites you, but it's worth knowing it's there.

Health : int = 100
Damage : int = 25
RemainingHealth := Health - Damage # Results in 75

Addition, subtraction, multiplication—all behave the way you'd expect. Division is where things get interesting, and we'll get to that in a second.

float — For Anything With Decimals

Reach for float when you're dealing with speed, physics, timers, or anything that needs fractional precision. It's 64-bit IEEE-754 under the hood, which means it also understands special values like NaN and infinity—handy when you're debugging a physics calculation that's gone sideways.

Speed : float = 3.5
TimeElapsed : float = 2.0
Distance := Speed * TimeElapsed # Results in 7.0

rational — The Type You Didn't Know You Needed

Here's where Verse diverges from almost every language you've used. Divide one int by another, and you don't get a float. You get a rational—an exact fraction.

Half := 1 / 2         # rational fraction: 1/2
Third := 1 / 3        # rational fraction: 1/3
Rounded := Floor(Third) # Evaluates to 0

Why does this matter? Because floating-point division introduces rounding errors. Divide 1 by 3 as a float, and you get an ugly, imprecise decimal that can compound into real bugs over thousands of calculations. A rational keeps the exact value—1/3, not 0.333333—until you explicitly decide to round it with something like Floor(). And since int acts as a natural subtype of rational, you can mix the two without extra conversion steps.

This is one of those design choices that feels unfamiliar at first and then feels obvious once you've been burned by float rounding in another engine.

Logic: Just True or False

logic is Verse's boolean type. Nothing fancy here—just true or false, controlling your branches and conditions.

IsAlive : logic = true
HasKey : logic = false

if (IsAlive? and HasKey?):
    Print("Player can open the door!")
else:
    Print("Access denied.")

Notice those ? marks again. You'll see this pattern everywhere in Verse—testing a logic value inside a condition requires that explicit success check.

Text: Split Into Three Layers

Most languages hand you a single string type and call it done. Verse breaks text down further, and it's actually useful once you're dealing with emojis or extended characters.

char holds a single 16-bit UTF-16 code unit—your standard letters and symbols.

char32 steps up to a full 32-bit Unicode scalar value, which you need for emojis and other characters that don't fit in 16 bits.

string is your immutable sequence of UTF-16 code units, built for player names, UI text, and on-screen messages. Strings support interpolation right out of the box using curly braces.

Letter : char = 'A'
Emoji : char32 = '\u{1F600}' # 😀 
PlayerName : string = "Joash"

Print("Welcome, {PlayerName}!")

Try to cram an emoji into a plain char, and you'll hit a wall—that's exactly why char32 exists.

The Two Special Cases

any — Use Sparingly

any is the universal supertype. It can hold literally anything.

var Varied : any = 42
set Varied = "Now I'm a string!"

That flexibility comes at a cost, though: you lose compile-time type safety the moment you use it. Reach for any when you're building a genuinely generic container or framework—not as a shortcut to avoid picking the right type. If you're using any because you're not sure what type something should be, that's usually a sign to slow down and figure it out.

void — Nothing to See Here

void represents a function that runs, does its job, and hands nothing back.

LogMessage() : void =
    Print("This function returns nothing.")

If your function's whole purpose is a side effect—printing something, updating game state—void is your return type.

A Note on Intrinsic Functions

Functions like Abs() and Floor() aren't written in Verse—they're baked directly into the runtime. That has a practical consequence: you can call them, but you can't store them in a variable or pass them around as a parameter.

# Valid execution:
Result := Abs(-42) 

# Compiler Error:
# MyFunctionVariable := Abs 

Try to treat an intrinsic function like a regular first-class value, and the compiler will stop you cold. Worth remembering before you spend twenty minutes wondering why your "clever" abstraction won't build.

Seeing It All Together

Here's a script that pulls every primitive type into one place:

using { /Verse.org/Simulation }

RunTypeDemo() : void =
    PlayerName : string = "Joash"
    Score : int = 10
    Multiplier : float = 1.5
    Bonus := Score / 2        # rational = 5/1
    IsWinner : logic = true
    Letter : char = 'J'
    Emoji : char32 = '\u{1F44D}' # 👍

    Print("Player: {PlayerName}")
    Print("Score: {Score}")
    Print("Bonus: {Bonus}")
    Print("Winner: {if (IsWinner?) then "Yes" else "No"}")
    Print("Initial: {Letter} {Emoji}")

Notice that Bonus—dividing an int by an int still hands you back a rational, even here in a simple demo. That's Verse quietly protecting you from precision loss before you even asked for it.

Get comfortable with these seven types, and you've got the foundation for basically everything else in Verse. The rest of the language—collections, classes, concurrency—all builds on top of these same primitives.

Popular posts from this blog

C++ vcpkg Manifest Mode + CMake

 If you've ever tried to install a C++ library and felt like you were assembling furniture without instructions, this article is for you. We're going to talk about vcpkg manifest mode and how it works with CMake , and I'm going to explain it like you're five years old (in a good way — no judgment here). First, Let's Talk About the Problem In most programming languages, adding a library is easy. Python has pip install requests . JavaScript has npm install express . You type one command, and boom, the library shows up in your project. C++ never really had that. For decades, if you wanted to use a library like fmt or nlohmann/json , you had to: Download the source code yourself Figure out how to compile it Tell your compiler where to find the headers Tell your linker where to find the compiled binaries Cry a little vcpkg is Microsoft's answer to this mess. It's a package manager for C++ — like pip or npm , but for C++ libraries. And manifest mode...

How to Set Up a Linux Web Server and Host an HTML Page Easily

Setting up a web server on Linux means spending a fair amount of time in the terminal — Linux leans heavily on the command line rather than clicking through menus, so you'll be typing out instructions more often than not.  If you're new to this, it can feel a little intimidating at first, but the good news is you don't need to become a Linux wizard overnight. A handful of core commands will get you surprisingly far. A few you'll lean on constantly: cd — move between directories ls — see what's in the current directory mkdir — create a new folder nano or vim — edit files right there in the terminal sudo — run something with administrator privileges Get comfortable with these and you'll be able to navigate around, tweak configuration files, and install software without much trouble. You don't need to memorize everything — you just need to be confident enough to follow along with clear instructions, which is exactly what this guide aims to give you....

Linux Network Troubleshooting

If you've spent any time as a sysadmin — or honestly, just as someone who's had to fix their own home network at 11pm — you know that connectivity issues are one of the most common headaches out there. The good news is that a handful of core tools and a methodical approach can take you from "why isn't this working" to a root cause pretty quickly.  This guide walks through the essentials: configuring interfaces, managing routes, and diagnosing problems when things go sideways. Configuring Network Interfaces Your network interfaces are the actual bridge between your machine and the outside world, so getting them configured correctly is step one for any kind of reliable connectivity. Doing It Manually ifconfig is the old-school, tried-and-true tool for this on Unix-like systems. To see everything currently configured, run: ifconfig -a If you need to manually set up a specific interface — assigning an IP, a netmask, and bringing it online — it looks like this: ifconf...