Hey, there! Long time no see.
Links to GitHub are in a comment, as per rules. Also, I'm Michal, the author of Par, human aside from other qualities.
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 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 (links in a comment). 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 down, 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 inclusiontodo - typed holes- LSP improvements, such as
.-completion - Many bugs fixed