• 0 Posts
  • 134 Comments
Joined 2 years ago
cake
Cake day: September 2nd, 2023

help-circle
  • I see you ignored my entire comment.

    I don’t know what is more explicit about expect. Unwrap is as explicit as it gets without directly calling panic!, it’s only 1 abstraction level away. It’s literally the same as expect, but without a string argument. It’s probably top 10 functions most commonly used in rust, every rust programmer knows what unwrap does.

    Any code reviewer should be able to see that unwrap and flag it as a potential issue. It’s not a weird function with an obscure panic side effect. It can only do 2 things: panic or not panic, it can be implemented in a single line. 3 lines if the panic! Is on a different line to the if statement.


  • An unhanded error will always result on a panic (or a halt I guess). You cannot continue the execution of the program without handling an error (remember, just ignoring it is a form of handling). You either handle the error and continue execution, or you don’t and stop execution.

    A panic is very far from a segfault. In apparent result, it is the same. However, a panic is a controlled stopping of the program’s execution. A segfault is a forced execution stop by the OS.

    But the OS can only know that it has to segfault if a program accesses memory outside its control.

    If the program accesses memory that it’s under it’s control, but is outside bounds, then the program will not stop the execution, and this is way worse.

    EDIT: As you said, it’s also an important difference that a panic will just stop the thread, not the entire process.





  • The problem with static mut is that it allows you to create multiple mutable references. And also mix mutable and immutable references. Additionally, it is accessible by any thread. So, as long as you don’t do any of that, it should be safe. Maybe I’m missing something.

    If this is the entire program, it’s not unsafe. But if it is just a fraction of the program, it may be unsafe. For example if 2 threads call the function at the same time. Since you would have 2 mutable references to BUF. Well, not actually unsafe since you don’t use the mutable reference, only create it.

    As to the other question, static variables are not in the stack. They have their own region of memory. If they were in the stack, they couldn’t be accessed across threads, since each thread has its own stack.

    EDIT: for completeness sake. For your last question. Yes, using a static buffer is probably more performant, since it doesn’t need to be set to 0 each time it’s called. However, that’s not what statics are for. If what you want is just to avoid that setting to 0, there are ways to get initialized arrays. For example MybeUninit. Which would be way better.



  • Installing dependencies via the OS’ package manager is one of the worst experiences there is. I understand it for C, because the language is ancient and doesn’t have its own dependency manager.

    But when developing, there are many dependencies you need that aren’t in the package manager. And when they are, they are often years old versions.

    And in the case of python, it installs dependencies in the global scope, which means that you sometimes import that version instead of the pip one.

    And in the case of python there’s the extra:

    python main.py

    python command not found

    Ah. It must be python3 then. Now all the bash scripts are broken. Since it’s python3, I’m going to install packages with pip3:

    pip3 install matplotlib

    pip3 command not found

    What?? So for python you need to put the 3, but for pip they removed it?

    Ngl, python development is much less stressful on windows.


  • The problem with that is that reviewing takes time. Valuable maintainer time.

    Curl faced this issue. Hundreds of AI slop “security vulnerabilities” were submitted to curl. Since they are security vulnerabilities, they can’t just ignore them, they had to read every one of them, only to find out they weren’t real. Wasting a bunch of time.

    Most of the slop was basically people typing into chatgpt “find me a security vulnerability of a project that has a bounty for finding one” and just copy-pasting whatever it said in a bug report.

    With simple MRs at least you can just ignore the AI ones an priorize the human ones if you don’t have enough time. But that will just lead to AI slop not being marked as such in order to skip the low-prio AI queue.



  • I haven’t tried using a GUI library for this. But it is possible (and relatively easy) to build for Android using rust.

    I found this tool called “x build” that works basically out of the box. It was a bit tricky to set up the release build, but got it working too.

    I made a small App using winit+wgpu and it seems to work. Win it also has touchscreen-specific events.

    Iced does use winit+wgpu, so if they are listening to the touchscreen events, it should work for Android. Haven’t tested it though.


  • When I want to draw raw polygons, I use wgpu. When I want a GUI I used iced. And when I want both, I use wgpu+imgui.

    Learning wgpu is quite steep, and it has tons of boilerplate. So unless you’re certain that you will use it a lot. I would just use iced.

    When I say wgpu I mean wgpu+winit. Though winit is quite simple and light. So the main part is wgpu.