• 0 Posts
  • 46 Comments
Joined 3 years ago
cake
Cake day: June 15th, 2023

help-circle

  • I think you have done way more work than would be needed to learn Rust. I mean, it certainly is useful knowledge if you want to do any of those things in Rust, but it’s definitely not needed to learn Rust.

    The Book (the Rust language guide) assumes that you know some other language first, but you don’t need to be an expert in anything in order to start learning Rust. If you understand the basic concepts of branching, loops, recursion and function calls, you are good to go.

    There are of course other concepts you will encounter in Rust (like Algebraic Data Types, Polymorphism, Ownership,…), but those are all explained in the Rust Book, so there really is no need to learn them in advance.




  • I’m willing to bet that it’s AI. It soft-contradicts itself quite often, emphasising that C++ is “Performance First”, but then also claiming stuff like “Rust achieves memory safety with zero runtime overhead”.

    Edit: What I am trying to say is that I have seen text like this in LLM output quite often, if the LLM is mixing text from different sources in its training data.

    Also, there is just wrong stuff in the text itself, not only in the conclusion. For instance the claim that Rust’s type system makes data races impossible. They are easier to avoid, but there is nothing stopping you from writing data races… Here, for instance, have a data race in safe Rust



  • This is so fucking stupid, I can’t even.

    For your mental health, have some reasonable arguments about Rust: https://www.heise.de/hintergrund/Entwicklung-Warum-Rust-die-Antwort-auf-miese-Software-und-Programmierfehler-ist-4879795.html

    Since it’s in German, here are the key points of the article (written from memory - the article is quite old, so I might misremember - best read the article yourself):

    • Software development is stuck in a vicious cycle regarding project budgets.
      • Some competitors don’t know better and just budget the “happy path”, that assumes that everything during development goes right.
        • The author uses a term for this which I like a lot: “Hybris of the programmer”
      • Other competitors know better, but still have to lie in order to remain competitive when it comes to prices
      • Therefore almost all software projects end up with a way too low budget
        • So we get buggy software
    • Rust might be a way out of this misery, because
      • it is understood that it takes longer to develop something with Rust
      • but on the flip-side the safety-guarantees rule out a lot of bugs
      • so customers who choose to have their project implemented using Rust are fully aware of the higher costs, but also the higher quality
      • and developers have a well known argument for the higher costs, and also have data that shows how this higher investment will yield a better quality product.


    • cargo install is for installing rust programs for your user, not for adding dependencies to your Rust project. Many cargo subcommands can be installed this way, for instance cargo bloat.
    • The file you are talking about is called Cargo.toml, because it is the file you need to write in order to configure cargo for your Rust project. TOML is the name of the file format. For details, please see the introductory chapter to Cargo in the Rust book.
    • Cargo recently got a new subcommand called cargo add, which allows to add dependencies directly on the command line. However, all it does is to add/edit/remove the respective lines in Cargo.toml. (Personal opinion: I have found it way easier to just edit the file directly than to learn yet another command…)

    That said: You still need to edit the Cargo.toml file, even if you solely use cargo add to manage your dependencies. That’s because that file contains a lot more information about your project than just the dependencies. For instance the current version, the feature-flags, your name, a link to the public repo,…


  • I haven’t done much Rust coding this year yet, mainly because I am trying to learn Lean4 and spent the last couple of months writing a (partially) formally validated (but not very fast) Binary Heap in Lean4.

    However, a few days ago I had an inspiration at night, that brought me back to my Rust spare time project: The visual novel engine I had started last year.

    For now I only did a relatively small change, but it’s one that will save me a lot of time (and nerves) later on. I am using a Free Monad based embedded Domain Specific Language for writing the game logic. The change now was to wrap that Free Monad in a State Monad Transformer, which I use to store the game state in.

    This idea seems to be working surprisingly well, and that has given me enough motivation to return to this project and to keep developing it further for now.


    Long and boring explanation with way too much detail:

    Sorry for going on a tangent, but there is a Rust-specific detail that makes this cool beyond the usual advantages of using a State Monad Transformer, and I cannot stop myself from sharing.

    For composing a large Free Monad, do-notation is more or less a must-have. However, do-notation in Rust only works well with types that implement Copy. If you want to use any other type in do-notation, you can only access variables of it in the following two lines. An attempt to access the data later will lead to an ownership problem (explained here). I have tried to overcome this by adding additional syntax to do-notation, but that is a crutch at best.

    So, this is where the State Monad Transformer comes in. It side-steps this problem by moving the state out of the do-notation block into the Free Monad’s Pure-nodes. That way it is readily available via the State Monad Transformer’s get()/put() functions, and the “use within two lines” limitation is not a big issue any more, as one can always get the value on one line, do something with it in the next line, and write the result back on the second line.




  • Behind all the negative tone there is a valid concern though.

    If you don’t know Rust, and you want to change internal interfaces on the C side, then you have a problem. If you only change the C code, the Rust code will no longer build.

    This now brings an interesting challenge to maintainers: How should they handle such merge requests? Should they accept breakage of the Rust code? If yes, who is then responsible for fixing it?

    I personally would just decline such merge requests, but I can see how this might be perceived as a barrier - quite a big barrier if you add the learning cliff of Rust.



  • I haven’t looked at the schematics, so I am not certain which connection exactly would be needed. I only know that the Reform Mainboard and the Reform CM4 adapter don’t expose any way of writing to the eMMC other than booting the system first. The problem here is that the Banana Pi CM4 boot process first looks for a bootloader in eMMC, and only if it cannot find one there, tries the SD card. So, if one flashes a bootloader that gets recognized by the firmware, but that later fails to boot, one is stuck…

    The I/O board on the other hand allows to connect to the CM4 via USB, and there is a weird, but supposedly working, procedure to erase the data in eMMC.

    In any case, I now have a spare CM4 I/O board lying around, and if I ever choose to upgrade my Reform to the Rockchip SoM (or something even faster), I can then still use the CM4 as a small standalone PC.


  • At least in my case, the default OS came on an SD Card, and both, the M.2 SSD (which I had ordered together with the laptop) and the eMMC were empty. The manual contains a section about moving the OS to eMMC, so I guess that’s their default setup.

    (In my case there’s an additional thing though: For the Banana Pi CM4 SoM the installation of u-boot into eMMC is officially not supported, as one would need a CM4 I/O board to erase it again, if anything goes wrong. I installed it there anyhow, and it’s working for me, but I did buy the I/O board beforehand as a precaution.)


  • I am curious how much work it will be to modify that Ubuntu image to fully work on the Reform. The audio chip and some other peripherals are on the mainboard, and need to be included in the device tree for the kernel to pick them up, so I would expect that at least some modifications of the image are needed.

    It might already be enough to grab the device tree from the MNT gitlab, compile it, and put it in the boot partition for stuff to work. (You will likely also want to install the reform-tools - either from their gitlab or from their repository. They include a kernel module that is needed to get battery readout and to power off the laptop on shutdown.)

    What helped me a lot while setting up the system was that I kept the SD card with the official (Debian Unstable) image around - every time something didn’t work, I could boot it up and check how the official image does it.