Menu

A Claude Client in One C# File, Compiled Ahead of Time
📰

A Claude Client in One C# File, Compiled Ahead of Time

DEV Community: dotnet·stepinto.dev·10 days ago
#yLMGw2Se
#devtodotnet#devto#dev#client#runtime
Reading 0:00
15s threshold

Last week's client was Go : a 5.8 MB static binary that starts in under two milliseconds, which is a high bar for any language with HTTP in its standard library. This week it's C#. .NET has had everything the spec needs in the box for a decade, and since .NET 8 it has had Native AOT, which compiles the whole program to a single native executable with no runtime to install. I wanted to know whether that gets a C# client anywhere near Go on size and cold start. It gets closer than I expected, though the runtime column on the leaderboard shows what the binary size leaves out.

The code is at github.com/AndyCross/claude-hot-path , and the spec every client passes is at /claude-hot-path/ .

JsonNode, not source generators

The idiomatic way to do JSON in AOT .NET is System.Text.Json with a source-generated JsonSerializerContext , so the serialiser knows every type at compile time and nothing needs reflection.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.