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
frostdoes; 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 andstate. - 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:
Steptakes 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#
| Limit | So |
|---|---|
| Desktop only; phones (through Native AOT) are in progress | Keep a phone game in Luau |
| The web only through FusionCompile: no spawning, input, sound, text or scene changes there | Give 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 Thing | Keep the rest in components |
| Libraries are compiled into each script, and a library's errors are reported at the script | In practice, one script composes the rest |
| A spawned thing is seen the next step; a script cannot read an event it sent | Plan the order of a step around it |
World.Spawn takes at most 8 component names | Keep what a thing is spawned with to eight components |
HashCode and GetHashCode differ from run to run | Never 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#
frost --version # from the -csharp download
dotnet --list-sdks # the .NET SDK, version 10 or laterA 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#
frost check game.toml
frost test game.toml
frost test --restore game.tomlFor 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.