Coldwave Read the docs

Recipe: choose C# or Luau#

Goal: choose the language for a game's scripts, knowing what each can do today. Both call the same engine and both replay to the bit; a game may mix them (Luau scripts run first, then C#, each in the project's order).

Choose Luau when#

  • The game must run on the web, on a phone, or over the network. Luau runs everywhere frost does; C# runs on the desktop only for now.
  • You want the shortest loop: a saved script is swapped in at once under frost dev, keeping the world and state.
  • You want to start from a template or a sample: they are written in Luau first.

Choose C# when#

  • The game is for the desktop, and you want types, a compiler and C#'s tooling.
  • A hot loop walks many things: Step takes components as columns, lent the world's own memory. In the engine's own measurements, 100,000 bunnies took a median 39.8 ms a step in C# on .NET against 90.6 ms in scalar Luau (one run each, under load).

What C# cannot do yet#

LimitSo
Desktop only; phones (through Native AOT) are in progressKeep a phone game in Luau
The web only through FusionCompile: no spawning, input, sound, text or scene changes thereGive those to a Luau companion
Multiplayer refuses a game in C# (E0543)Network games are Luau
[State] holds only bool, int, uint, float, double and ThingKeep the rest in components
Libraries are compiled into each script, and a library's errors are reported at the scriptIn practice, one script composes the rest
A spawned thing is seen the next step; a script cannot read an event it sentPlan the order of a step around it
World.Spawn takes at most 8 component namesKeep what a thing is spawned with to eight components
HashCode and GetHashCode differ from run to runNever let them decide anything in the game

[FusionCompile] works like Unity's [BurstCompile]: mark a class and its Step is compiled for the web.

The whole C# API and its parity table with Luau: C# and frost reference csharp.

Setting up C#

Shell
frost --version                                        # from the -csharp download
dotnet --list-sdks                                   # the .NET SDK, version 10 or later

A script whose name ends in .cs is compiled by that SDK and run inside frost. Without C#, a game with C# is refused (E0482), and frost test says a C# game was skipped. The arena and 3D templates have also been written in C#, the arena one to the Luau one's world to the bit.

Checks, either language#

Shell
frost check game.toml
frost test game.toml
frost test --restore game.toml

For C#, frost test --json reports dotnet: {accepted, here} when the game was accepted on another major version of .NET than the one it runs on now.