Hacker News new | ask | show | jobs
by labrador 222 days ago
My read today is that the advantage of Rust over C/C++ is that the compiler enforces the rules, where in C/C++ you'd have to use a static source code analyzer to find omissions. Since Clojure uses Software Transactional Memory and Persistant Data Structures to only make copies of updated shared data structures, it seems like it could actually be faster than Rust/C/C++ depending on how efficient the copy is. I may have it wrong but it sure is interesting...
3 comments

While STM was a big selling point when Clojure in practice it's actually very rarely used. The persistent data structures are indeed the heart of Clojure.

While for many applications Clojure's performance is good enough it's not anywhere near what you can achieve with Rust. I once did a small game in Clojure trying to be very clever to eke out every last bit of performance and still didn't hit an acceptable frame rate. Made a very naive reimplementation in Rust that involved copying the entire state every frame and it run buttery smooth.

If there is a task for wish persistent data structures are the most performant solution it should be easy enough to implement and use them in rust too. Probably someone already did that.

Clojure is my default programming language but if I want performance (or static types) I reach for Rust.

That’s my take after using Rust for half a decade. The type system is very powerful and can encode logic in types in a way that’s impossible in most other languages, which is how the borrow checker works (the lifetime of a reference is part of its type).
> can encode logic in types in a way that’s impossible in most other languages

It’d be of great help if you could share an example of this along with an explanation why it’s impossible in a different language say one of Java/C++/Go

> in C/C++ you'd have to use a static source code analyzer to find omissions

Clang and GCC have a pretty solid suite of static checks that they can enforce if you enable them. They catch most of the common footguns.