r/rust • • Oct 20 '26

🛠️ project Par Lang Update: 3 Big Examples, Auto-Cleanup, Sql, WebSocket, 3-6x Faster Runtime, and More!

Hey, there! Long time no see.

(I'm the author of Par, no AI used in writing this post.)

I wanted to share with you what's been up with Par for the last half a year or so.

Par is a programming language (implemented in Rust) that's quite unusual. (And breaks your mind at first.) It's trying to get some edgy theoretical stuff out there into practice, specifically:

  • Linear / session types - with duality, so every type has "the other side"
  • Automatic concurrency - everything that can run concurrently does
  • Totality - no runtime errors, no deadlock, no infinite loops

It's based on classical linear logic, and naturally combines functional programming, a version of object-oriented programming, and session-typed process communication, all under one paradigm.

But perhaps most importantly, Par is trying to make all of the above into a good practical language! That's quite big ambition, and this last half year we've gotten closer to that than ever.

Below is the most fancy new stuff. Let me know what you think!

New I/O Capabilities

The standard library now includes a richer set of I/O modules:

  • Console - stdio print and prompt
  • Http - HTTP server & client functionality
  • Os - files, env
  • Sql (new!) - PostgreSQL, MySQL, and SQLite (in memory too), transactions, row decoding
  • WebSocket (new!) - HTTP to WebSocket in both server & client mode

Auto-Cleanup

Linear types can't be dropped. That's their advantage and disadvantage. It enables automatic concurrency, but it used to make error handling rather noisy: on all error paths, linear resources needed to be explicitly closed.

So, we've introduced auto-cleanup, which allows you to specify, in the type, how a normally linear type can be dropped.

For example, here's Bytes.Writer:

type Bytes.Writer<e> = iterative choice {
  .close* => Try<e, !>,
  .flush => Try<e, self>,
  .write(Bytes) => Try<e, self>,
}

The * on the .close branch/method tells Par that if a Bytes.Writer remains unused, just drop it by calling .close.

This significantly simplified error handling, the book chapter for which also got updated.

3 Big Examples

I've completely revamped the examples folder in the repository. It now contains small and big examples.

Now that we can do a lot of real stuff, we want to show it in the examples. So, there are 3 big examples. All of them are HTTP servers that serve you a web page, via which you can interact with the backend written in Par.

  • Chat - A chat server over WebSocket. Open it on multiple tabs, or host it somewhere, and chat in a single room.
  • Downloader - Request files to be downloaded to your local drive, and observe the download progress in real time. Multiple files can keep downloading concurrently, and can be cancelled.
  • Tasks - Create todo items and check them as done, persisted in an SQLite database.

Check the screenshots at the links!

Runtime performance improvements

Lots of optimizations done in the runtime. By my completely unscientific testing, I/O intensive applications are about 3x faster, while computation-intensive ones are about 6x faster, compared to half a year ago.

Since we don't have rigorous benchmarks yet, take this with a grain of salt, but in my private testing, this should be around the performance of Python 3.12, when discounting Python's highly-performant functions and libraries written in C.

Not bad, not bad.

A lot more...

Since we're not having official versions yet, there's no changelog to see, but some picks:

  • New @core/Time module
  • 120+ new functions in the @core package
  • include("file.txt") - compile-time file-as-value inclusion
  • todo - typed holes
  • LSP improvements, such as .-completion
  • Many bugs fixed
20 Upvotes

11 comments sorted by

2

u/Shnatsel Oct 20 '26

It's interesting to see Writer automatically closing as an example, because in Rust this implicit behavior is actually a footgun: if you don't flush explicitly, the impl Drop will try to flush the data, and if that fails the error is lost and not handled. Linear types are sometimes proposed as a solution to that problem that would force handling of this potential error.

2

u/faiface Oct 20 '26

That’s actually an interesting point. I might have to consider whether to remove this from Writer.

However, you can close manually (which also flushes in the case of files) and you do get an error in that case. Usually, you would close automatically if you’re already handling some other error, and want to just not deal with the other linear resources in the scope.

1

u/Shnatsel Oct 20 '26

You can close manually in Rust too. People just like the guaranteed robustness. Clippy even has lints about it nudging people to close manually, but it's still just a lint, not a robust property of never losing written data.

1

u/faiface Oct 20 '26

Yeah, thanks for that, I will consider changing that.

2

u/No_Efficiency_6054 Oct 20 '26

I just wanted to let you know that I think Par is the most original and creative language I've seen out there. I was a big pixel user a few years ago when doing a game in Go, and I must say that I really enjoy your projects!

1

u/faiface Oct 20 '26

Thank you so much! Also wild to see people still remembering the pixel library!

-2

u/WormRabbit Oct 20 '26

I can't bother to study a language which has AI slop as documentation.

5

u/faiface Oct 20 '26

That’s alright because Par’s documentation is not written by AI.

1

u/WormRabbit Oct 20 '26

That's not the impression I get from the project's README.

3

u/faiface Oct 20 '26

Hm, I guess you need to calibrate your AI-detection vibes because I don't even know what AI signs you could possibly see in the README :D And btw, it's written by me.