• 0 Posts
  • 101 Comments
Joined 2 years ago
cake
Cake day: June 21st, 2023

help-circle
  • For your goals, I would stick with Python unless you want to learn another language. There’s not much value to switch away when all the tools you need are primarily designed for Python.

    As far as functional programming goes, with AI stuff, my experience is that you generally are more interested in orchestrating services than FP. For example, run input through model #1, then based on the output, run one of these other 3 models (or multiple of them in parallel), then eventually pass it all back into another service/function to aggregate and format the outputs. You can think of each of these as being “functions”, but they’re much higher level than what you’d traditionally consider functions in FP and more along the lines of microservices.


  • I’ll be honest, I’m not really sure what you’re trying to say, but it sounds like cross-compilation to me? The article mentions several different GUI libraries that require dynamic linking and complicated build scripts, so even if you setup rustc to cross-compile (which isn’t that hard but is an extra unnecessary step for your run-of-the-mill dev who just wants to get paid), getting the build scripts to cross-compile C++ libraries or testing the cross-compiled binaries with dynamically linked libraries is a pain, assuming your build scripts even let you do that.

    All of this is avoidable by building from Windows. Or I guess you can not target Windows. That works too, but most businesses won’t see that as an option.


  • TehPers@beehaw.orgtoRust@programming.devRust GUI survey 2025
    link
    fedilink
    English
    arrow-up
    7
    arrow-down
    2
    ·
    9 days ago

    It’s a GUI framework evaluation. I would imagine most users of a desktop application with a GUI would be Windows users. It would generally be a little weird to develop a professional product that does not work on Windows (or at least Mac). It’s a lot easier to develop that natively than to cross-compile.





  • If you want the source to repeat indefinitely, you can try calling repeat_infinite on it. Combine that with pausable/stoppable, and use periodic_access to occasionally check whether the audio source should be paused/stopped probably by using an Arc[AtomicBool] (using square brackets because Lemmy hates angle ones).

    It could look something like this:

    let src = ...;
    let stop = Arc::new(AtomicBool::default());
    let stop2 = stop.clone();
    let src = src
        .repeat_infinite()
        .stoppable()
        .periodic_access(Duration::from_millis(50), move |src| {
            if stop2.load(Ordering::Relaxed) {
                src.stop();
            }
        });
    
    // later on...
    stop.store(true, Ordering::Relaxed);
    

    periodic_access is also how Sink controls the source when you want to pause/stop/etc it. You could probably use Sink directly if you want more control over the source.





  • Story points and velocity always felt to me like a flawed metric. It encourages volume of work, and discourages quality of work. The worse your code is, the more stories and tasks you can create to fix it, and the higher your velocity. It’s a bit of a shame that it’s used so widely as a measurement of work completed, and I wish a better means of measuring productivity would become more popular instead.







  • I really wish Python had multi-line lambdas. Sadly Python is very opinionated in ways I don’t quite understand, but I can at least respect while using it.

    For interfaces, honestly all I can suggest is using an ABC with only @abstractmethods. It’s not perfect, but it’s basically what you’d do in C++ anyway. If you’re looking for an interface that models data, you could look at dataclasses or TypedDict (depending on what kind of data it is), but it’s just not going to match what’s possible in TS sadly (mapped types, conditional types, complex union types, custom type guards, etc).


  • Edit: Lemmy decided to completely butcher my comment, so I’ve replaced all the ampersands with %. Sorry, this will look a bit funny.

    You (and they) are right that aliasing pointers is fine. I was running Miri on your playground link, and it gave the expected results. I was just too tired to realize that it was saying your failure case (where you did multiple mutable aliasing with borrows) caused UB and that your success case (where you did multiple mutable aliasing with pointers) did not cause UB.

    Generally speaking, the rules around aliasing only apply to borrows in Rust, from my understanding. Any code that creates two %mut borrows of the same value is immediate UB. Any code that could possibly cause that to happen using safe code is unsound. Since your method operates only on the raw pointers, no aliasing rules have been broken, however the compiler also can’t optimize around your code the same way it could had you used regular borrows (assuming it’s possible). At a lower level, this is reflected by the compiler telling LLVM that %mut T values (usually) are not aliased, and LLVM applies optimizations around that. (Note that UnsafeCell is a bit of a weird case, but is fundamental to how the other cell types work.)

    This is actually why shared pointers like Rc and Arc only give you shared borrows (%) of the values contained in them, and why you’re required to implement some kind of interior mutability if you want to mutate the shared values. The shared pointer cannot guarantee that two borrows of the same value are not active at the same time, but does allow for shared ownership of it. The Cell/RefCell/Mutex/etc types verify that there is only one active %mut T (unique borrow) of the inner value at a time (or in Cell’s case even allows you to mutate without ever receiving a %mut T).

    Note that while %T and %mut T are often referred to as “immutable” and “mutable” references, it’s probably more accurate to refer to them as “shared” and “unique” references. Mutability is not actually tied to whether you have a %T or a %mut T. This is trivially shown by looking at the Atomic* types, which only require a %self for their store operation.