Rust

8316 readers
25 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 3 years ago
MODERATORS
1
2
3
4
5
 
 

So yeah, as the probably unnecessarily long title says, this is a CLI that displays the current playing lyrics, but instead of trying to go online and fetch a match it just uses the already there xesam:asText property in MPRIS.

Sadly a lot of popular players that implement the MPRIS2 standard still don't implement that specific one, so it wont work with them. Even the one used in the showcase had to be modified, tho I am hopefully gonna upstream it soon.

I am very strict about AI usage, so for this project the only hint of AI that was used was for tab auto completion that is just used for boilerplate like, idk, implementing the Default trait for PlayerState (not including the actual tricky metadata_last_updated part). Safe to say it was only one notch above no AI at all.

So yeah, here you go give it a try and feel free to roast me, after all this is my first cli and cargo publish ;)

6
7
8
9
 
 

Rustweek 2027 Call for Proposals is open for anyone interesting in submitting a talk to the conference. RustWeek is in Utrecht, The Netherlands, May 24–29 2027.

10
11
 
 

Was recently somewhat surprised that you can't just copy a Rust executable into a ´scratch´ container and have it work, so this is a cool blog post to find in my RSS feed.

I'm guessing, if you're doing something less complex, then you just need the ´musl´ target and the allocator...

12
 
 

See also the discussion for Klabnik's Arguing about arguments

13
 
 

1.100 is looking to be an interesting release, with the allocator api and never type (and dependency cooldowns in Cargo). Which is kind of nice for a round number release.

14
15
16
17
 
 

cross-posted from: https://lemmy.zip/post/71977304

I think most of my comments and error messages are written in Portuguese, but this is only a prototype, so please ignore that.

Kata manages memory with per-fiber bump arenas backed by structured concurrency — no garbage collector, no borrow checker, no reference counting; escape analysis decides at compile time whether each value stays local or escapes to the caller's arena, and ; in actions distinguishes "local computation" from "value that escapes." Refined types (data (Int, > _ 0) as PositiveInt) carry logical predicates validated at compile time, participate in multiple dispatch, and can delegate interface implementations to their base type through refines — a fallback mechanism with no equivalent in Rust or Haskell. The pure/impure boundary is not a monad you thread through your code — functions (lambda) and actions (action) are separate syntactic domains with their own structural rules, enforced at compile time; where Haskell tracks purity through IO as a type-level effect, Kata makes it a property of the syntax you write.


Memory

• Kata: Per-fiber bump arenas + escape analysis; no GC, no borrow checker

• Python: Refcounting + cycle GC

• Haskell: Tracing GC

• Rust: Ownership + borrow checker


Refined types

• Kata: data (Int, > _ 0) as PositiveInt — predicates validated at compile time, participate in dispatch, refines delegates interfaces to base

• Python: Not available

• Haskell: Liquid Haskell (external plugin, not core)

• Rust: Not available


Purity

• Kata: Physical barrier: separate syntax, operators, structural rules

• Python: Not enforced

• Haskell: Monadic IO (type-level effect)

• Rust: Not enforced


Conditionals

• Kata: Pattern matching + guards (exhaustiveness enforced)

• Python: if/elif/else

• Haskell: if + pattern matching

• Rust: if + match


Backend • Kata: Cranelift JIT/AOT (native, no VM)

• Python: CPython interpreter

• Haskell: GHC (LLVM/native)

• Rust: LLVM (native)

The repo is at github.com/ArthurJ/Kata — build with cargo build, then try kata repl, kata run examples/, or kata test. I'd love feedback on the language design: what feels right, what feels wrong, what you'd do differently.

action greet (name::Text) => Unit
    echo!(+ "Hello, " (+ name "!"))

action main
    greet!("World")
    greet!("Kata")

main!()
enum BMI
    Underweight(< _ 18.5)
    Normal(<= _ 25.0)
    Overweight(<= _ 30.0)
    Obese

action main
    echo!(BMI 17.0)
    echo!(BMI 22.0)
    echo!(BMI 27.0)
    echo!(BMI 35.0)
main!()
fizzbuzz :: Int => Text
lambda x:
    both: "FizzBuzz"
    fizz: "Fizz"
    buzz: "Buzz"
    otherwise: show x
    with
        fizz := divisible x 3
        buzz := divisible x 5
        both := and fizz buzz


divisible :: Int Int => Boolean
lambda x n:
    match div x n
        Ok q: = x (* n q)
        Err _: Boolean::False


action main
    for i in [1..16]
        echo!(fizzbuzz i)


main!()
18
19
20
21
 
 

While load testing one of our Rust services at work, we ran into something that took us way longer to figure out than we'd like to admit: memory that shoots up under load and just stays there.

Though glibc is the default allocator and works well for the majority of applications, it can retain significant allocator-owned memory for bursty workloads due to arena reuse, fragmentation, and cached free chunks.

Allocator switch, and this article was mentioned in Lemmy Release v0.19.20 - Reduced Memory Usage

This release significantly reduces memory usage for the Lemmy backend. Metrics on production instances show a reduction up to 10 times. Here you can see the statistics from a few different instances. Read on for a technical explanation below. Note that the change only affects x86, there is no difference on ARM (e.g. Raspberry Pi), see here for details.

22
23
 
 

cross-posted from: https://programming.dev/post/56782117

Supply-chain through social engineering

24
25
view more: next ›