nous

joined 2 years ago
[–] nous 10 points 1 week ago (1 children)

The readme for smol has an example for stdout. I assume stdin is the same:

        let mut stdout = Unblock::new(std::io::stdout());
        io::copy(stream, &mut stdout).await?;

And there is more information about how to use it for reading/writing on the Unblock docs.

[–] nous 16 points 1 week ago (1 children)

By far the most important thing is consistency

This is not true. The most important thing is correctness. The code should do what you expect/want it to do. This is followed closely by maintainability. The code should be easy to read and modify. These are the two most important aspects and I believe all other rules or methodologies out there are in service of these two things. Normally the maintainability side of things as correctness is not that hard to achieve with any system of rules out there.

You must resist the urge to make your little corner of the code base nicer than the rest of it.

Uhg. I really don't like these words. I agree with their sentiment, to a degree, but they make it sound like you should not try to improve anything at all. Just leave it as it is and write your new code in the same old crappy way that it always has been. Which is terrible advice. But I get what they are trying to say - you should not jump into a area swinging a wrecking ball around trying to make the code as locally nice as possible at the expense of the rest of the code base and other developmental practices around.

In reality there is a middle ground. You should strive to make your corner of the code base as nice as possible but you should also take into account the rest of the code base and current practices as well. Sometimes having a little bit better local maintainability is not worth the cost of making the code base as a whole less maintainable. Sometimes a big improvement to local maintainability is worth a minor inconvenience to the code base as a whole - especially for fast moving parts of the code base. You don't want something that no one has touched in 10 years to drastically slow down current features you are working on just to keep things consistent.

Yes consistency is important. But things are far more nuanced than that statement alone. You should strive for consistency of a code base - it does after all have a big effect on the maintainability of the code base. But there are times that it hampers maintainability as well. And in those situations always go for maintainability over consistency.

Say for instance some new library or an update to a library introduces a new much better way of working. Your code base is full of the old way though. Should you stick to the old way just to keep up with consistency? If the improvement is good enough then it might be worthwhile. Ideally if you can you would go though and update the whole code base to the new way of working. That way you improve things overall and keep consistency of the code base. But that is not always practical to do. It might be better to decide that the new way is worth switching to for new code, and worth refactoring old code when you are working in that area anyway but not worth the effort of converting the whole code base at once. This makes maintainability of the new code better, at the expense of old less used code.

But the new way might not be a big enough jump in maintainability of new code that it is worth sacrificing the maintainability of the code base as a whole. Every situation like this needs to be discussed with your team and you need to decide on what makes most sense for your project. But the answer is not always that consistency is the most important aspect. Even if it is an important aspect.

[–] nous 4 points 1 week ago (1 children)

Consistency as a means to correctness still means correctness is the more important aspect. Far too many projects and people that go hard on some methodologies and practices lose sight of their main goal and start focusing on the methods instead. Even to the point were the methods are no longer working toward the goal they originally set out to accomplish.

Always have the goal in mind, once your practices start to interfere with that goal then it is time to rethink them.

[–] nous 6 points 2 weeks ago

There is no problem with having home on a different disk. But why do you want swap on the slower disk? These would benefit from being on the faster disks. Same with all the system binaries.

Personally I would put as much as possible on the faster disk and mount the slower somewhere that the speed matters less. Like for photos/videos in your home dir.

/boot can be anywhere though if you are getting a grub error that suggests the UEFI firmware is finding grubs first stage but grub is having issues after that. Personally I don't use grub anymore, systemd-boot is far simpler as it does not need to deal with legacy MBR booting.

[–] nous 2 points 2 weeks ago (1 children)

Most packages managers can run arbitrary code on install or upgrade or removal. You are trusting the code you choose to run on your system no matter where you get it from. Remember the old bug in ubuntu that ran a rm -rf / usr/.. instead of rm -rf /usr/... and wiped a load of peoples systems?

Flatpacks, Apparmor and snaps are better in this reguard as they are somewhat more sandboxed and can restrict what the applications have access to.

But really if the install script is from the authors of the package then it should be just as trustworthy as the package. But generally I download and read the install scripts as there is no standard they are following and I don't want them touching random system files in ways I am not aware of or cannot undo easily. Sometimes they are just detecting the OS and picking relevant packages to install - maybe with some thrid party repos. Other times they mess with your home partition and do a bunch of stuff including messing with bashrc files to add things to your PATH which I don't like. I would never run a install script that is not from the author of the application though and be very wary of install scripts from a smaller package with fewer users.

[–] nous 2 points 3 weeks ago (1 children)

I disagree with this. Stack traces are a lazy way to handle errors. They are useful only to the developer of an application for logic errors and bugs in the program. That is their one usecase and are very handy at that usecase.

For instance the very stack trace he gives us:

Traceback (most recent call last):
  File "/home/piku/.piku/envs/wikdict/lib/python3.11/site-packages/flask/app.py", line 1511, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/piku/.piku/envs/wikdict/lib/python3.11/site-packages/flask/app.py", line 919, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/piku/.piku/envs/wikdict/lib/python3.11/site-packages/flask/app.py", line 917, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/piku/.piku/envs/wikdict/lib/python3.11/site-packages/flask/app.py", line 902, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/piku/.piku/apps/wikdict/wikdict_web/lookup.py", line 119, in lookup
    if r := get_combined_result(lang, other_lang, query):
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/piku/.piku/apps/wikdict/wikdict_web/lookup.py", line 91, in get_combined_result
    conn = get_conn(lang + "-" + other_lang)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/piku/.piku/apps/wikdict/wikdict_web/base.py", line 103, in get_conn
    raise sqlite3.OperationalError(
sqlite3.OperationalError: Database file "/home/piku/.piku/data/wikdict/dict/en-ko.sqlite3" does not exist

Assuming that is related to a user input this could just be

Error: Database file "/home/piku/.piku/data/wikdict/dict/en-ko.sqlite3" does not exist.

Even better to give suggestions on how the user might want to fix that problem. Everything else in that stack trace is useless noise that looks scary and takes far more time to parse and get the useful into to users of the program. Stacktraces are just as bad as not adding context to input/environmental errors, maybe only marginally better for the developer. But no user should EVER see a stacktrace and IMO any stacktrace seen should indicate a bug in the application. They are a developers tool, not a way to show users an error message.

Don't be lazy and add context and print out your errormessages in a way that is useful to the users of your application. A stacktrace is not that.


And on the side of stacktraces, they can be more noisy then necessary even for a developer. Here span traces can be useful to find the source of an error without needing to print out the current stack trace which is often vastly less useful in async contexts or other things that are not strictly a straight forward nested call stack.

[–] nous 3 points 3 weeks ago (1 children)

What you have listed is a good start. https://www.rust-lang.org/learn has additional resources as well once you have gotten through those.

[–] nous 18 points 3 weeks ago* (last edited 3 weeks ago) (4 children)

Also if you are looking for a replacement for find that is not a full tui then take a look at fd which works more like what the author expected from the find commad - fd <pattern>.

[–] nous 4 points 3 weeks ago (1 children)

My point is the different levels of just working are subjective, not objective. I personally have spent far more time fixing bugs or just reinstalling ubuntu systems then I have over the same period for Arch systems. So many of my ubuntu installs just ended up breaking after a while where I have had the same Arch install on systems for 5+ years now. Could never get a Ubuntu system to last more then a year.

Everyone has different stories about the different OSs. It is all subjective.

[–] nous 0 points 3 weeks ago* (last edited 3 weeks ago)

You can cherry-pick examples of problems from every OS. That is my point. They all have issues that you may or may not encounter and quite a few that would make people from other OSs scratch their head and think what the hell the devs are thinking. Pointing out one issue of one OS does not change any of that.

Which is proven by the other replys to your comment - others dont find this issue to be as show stopping as you do and just live with it or dont use it at all. How many issues do you do the same for on your favorite OS?

[–] nous 2 points 3 weeks ago

What isn't associated with cancer? You can probably find a study on most things that have a link to cancer. If not chances are it just has not been studied yet.

[–] nous 19 points 3 weeks ago (9 children)

There is no perfect OS that just works for everyone. They are all software so they all have bugs. People how say an OS just works have never hit those bugs or have gotten used to fixing/working around or flat out ignoring them.

This is true of all OSs, including Windows, Linux and MacOS. They are all differently buggy messes.

Linux is the buggy mess that works best for me though.

view more: next ›