연결됨 다시 연결 중 다시 연결 초 연결 실패 연결 일시 중지 복구 실패
I implemented QUIC in Sollang · Cover image

I implemented QUIC in Sollang

Public posts

Implementing QUIC v1 and v2 in Sollang in place of an external QUIC DLL, while improving type inference, immutability, and the self-hosted compiler.

Hello. This time, I will introduce a story about implementing QUIC in Sollang.

At first, I tried to add the socket library as a basic step to create a web server. After TCP and UDP started working, I naturally focused on QUIC as well.

The initial approach was to add the QUIC library for Rust. However, I realized that what I actually wanted was not “to be able to call QUIC from Sollang,” but rather to implement QUIC using Sollang.

I thought it would be a bit disappointing if the important protocols were hidden behind DLLs created in another language while the language itself was being created. So I changed the direction. I removed the code that attached external libraries, and implemented the QUIC protocol as Sollang from the beginning.

Sollang from the source to QUIC standard library and the native UDP socket via the embedded structure

Here, I also had to rethink the phrase “integrated during runtime”.

It wasn’t the way I wanted for all Sollang programs to necessarily include QUIC code. It is more natural for the standard library sources needed when a user brings in <code>sys.quic</code> to be compiled together with the program. Programs that don’t use QUIC remain lighter in size accordingly.

At the very bottom where it meets the operating system, there is <code>sys.socket</code>. Above this small boundary that handles UDP sockets in Windows and Linux, packets QUIC, TLS handshakes, encryption, and streams with loss recovery are layered with Sollang code.

So now neither <code>sollang_quic.dll nor </code> is needed. Using QUIC allows the QUIC written in Sollang to be included in the executable file.

The standard took QUIC v1 and v2 as the basis. TLS 1.3 was also rechecked based on RFC 9846, which replaced the previous RFC 8446 in July 2026. Implementations include Initial, Handshake, 1-RTT packets, version negotiation, streaming, DATAGRAM, and key renewal. Required technologies such as SHA-2, HMAC, HKDF, AES-GCM, X25519, and Ed25519 have also been included in the Sollang standard library.

Of course, it does not mean that all the QUIC draft features have been implemented. For example, areas like multipath are not included in this stability contract. It would be better to clearly distinguish between what has been implemented and what has not yet been implemented.

However, when implementing QUIC, what appeared more prominently was the compiler.

Passwords or protocol codes consist of static constants and fixed-length data. However, even though the type and length are already known, we were repeatedly using different types like <code>UInt32(1)</code>, or converting fixed data into a growable array and then continuously calling <code>push</code>.

This wasn’t a problem that could be solved just by fixing the library code neatly. If the naturally written code wouldn’t compile, instead of bypassing the source, we had to fix the compiler.

So, if there is a expectation type, the numeric type can be omitted. If the length of the array content can be determined, it is assumed to be a fixed array. Unmodified bindings are by default immutable, and unnecessary mutable indicators or duplicate types trigger an Snnn warning.

The nested <code>when</code> was also quite annoying. Instead of each success path increasing in depth by one block, in the function that returns <code>Result</code>, it can be smoothly connected as <code>?</code> like this.

sendPing endpoint: socket.Endpoint -> Result<Bool, socket.SocketError> uses Network {
    socket.connect(endpoint)? => connection
    socket.sendText(connection, "ping")? => count
    socket.shutdown(connection)?
    Result<Bool, socket.SocketError>.Ok(count == UIntSize(4))
}

Nothing is done when the conditions are met, and only handled when it fails. <code>if else </code>Road <code>unless</code>Allowed to be expressed as "or". The code that sequentially compared multiple values is in the "subject" style. <code>when</code>and it was organized like that. Actually QUIC While writing the code, SollangIt seems like you keep asking what the Down expression is.

During the work, compiler issues kept appearing, which caused some concern for a while.

It was difficult to determine whether the structure collapsed as the problem was fixed, or if hidden issues became apparent and made it more robust. This time, I based my criterion on whether the same invariant is maintained in both C# bootstrapper and self-host compiler.

The issue where the fixed array inside a control statement fell into an incorrect memory structure, the problem where enum <code>when</code> produced SSA values of a different type as the result, and the issue where using <code>Text</code> created by Arena required re-modifying the same Arena again – all of these were fixed by the compiler without hiding them in the source code. And each of them was left for regression testing.

Ultimately, 1,259 tests for overall regression passed on Windows and 1,258 on Linux. Both platforms converged to the same LLVM for Stage 2 and Stage 3, and the full CLI equivalence of the native compiler was also confirmed. The browser compiler and diagnostic tests also passed as well. The C# bootstrapper build also had 0 warnings and 0 errors.

After completing this task, it feels more like I directly wrote a fairly large protocol as Sollang rather than just adding one more QUIC.

“Why is this code so long?”, “Why does the compiler already know it, and does the user still need to use it?”, “Is it correct to avoid this error in the source code?” These questions led to many improvements.

The journey is still long, but through this process, the structure of Sollang seems to become stronger little by little.

The Windows and Linux installations can be obtained from Sollang 0.4.260817 GitHub Release. Starting from this version, the public packages will only contain native <code>sollang</code> and standard libraries for self-hosting.

0 Comments

Comments: 0

Sign in to leave a comment.

No comments yet. Write the first one.

The server connection was interrupted. Reconnect ×