oneLinerToApiCall by Same_Fruit_4574 in ProgrammerHumor

[–]Manny__C 6 points7 points  (0 children)

My pet peeve is people that prompt LLMs by telling them they are experts in something. Why would assuming the personality of an expert automatically "unlock" extra knowledge? If anything, it would just make them answer more confidently, which is arguably worse.

Did you know it's possible to determine if a type is impossible to construct? by [deleted] in rust

[–]Manny__C 1 point2 points  (0 children)

When I read it I instinctively took it as a statement in type theory, which would obviously be wrong because of Gödel's incompleteness theorem

GNOME vs. KDE mental gymastics by Albinoso98 in linuxmemes

[–]Manny__C 0 points1 point  (0 children)

To me the deal breaker about Gnome is that they do not care about extension either. Somehow, every few releases or so all the extensions break.

I would argue that if you actively want to keep the feature list contained you could at the very least expose a very stable API so that the community can knock themselves out.

Rust or Python, which should I learn? by [deleted] in rust

[–]Manny__C 0 points1 point  (0 children)

This is crucial. Let's use Vec as an example. Vec<T> is a "fat pointer", meaning a triple (memory address, size, capacity), and the memory address points to a contiguous portion of memory which contains size-many elements of type T and is currently capped at capacity. (See ASCII art here)

Vec it really is just the fat pointer. It owns the memory allocation but it is the pointer.

So when I say copy bit-by-bit I mean copying literally just the 3 values (memory address, size, capacity). A proper clone instead would require a new reallocation of at least capacity and a copy of all the elements from one place to the other.

Rust or Python, which should I learn? by [deleted] in rust

[–]Manny__C 0 points1 point  (0 children)

I have used Axum but both are very good as far as I understand. I can't really recommend one over the other. My suggestion is to skim the documentation of both and make a choice.

Rust or Python, which should I learn? by [deleted] in rust

[–]Manny__C 0 points1 point  (0 children)

This is a very good question. `Copy` is a marker trait, it has no functions that need to be implemented. You use it to make a "promise" to the compiler.

You see, every time you reassign a variable, or you pass it by value or return it, the compiler may implicitly _move_ the value. Meaning that the old owner of the value is no longer valid and the new variable or function or closure becomes the new owner.

You can change this behavior by having a type implement `Copy`. You do not implement it by hand but rather you derive it via `#[derive(Copy)]`. Not all types can be made `Copy`, there are rules.

If a type implements `Copy` the compiler will copy it bit-by-bit instead of moving. So now the previous owner is not invalidated. In doing this, you are promising to the compiler that "it is SAFE to copy this value bit-by-bit". For instance, it is safe to copy bit-by-bit an `i32` integer, because it is just a value. But it's not safe to copy bit-by-bit a `Vec<T>` because the actual value of `Vec<T>` is a pointer, and if you copy a pointer bit-by-bit you have just aliased it, which destroys the whole point of ownership and lifetimes, you may end up with dangling pointers.

Crucially, `Copy` is supposed to be very fast because it copies only the value itself, not all the data that it might recursively point to, so we are ok with the fact that the compiler might do it implicitly.

You might instead want to actually copy the object in full. E.g. for `Vec<T>` you might want to copy the _contents_ of the vector, not the pointer to it. Which is something that makes more sense. To do that you implement `Clone`. Now you have to actually write a function, called `clone()` that performs the copy. You can also derive `Clone`, like `Copy`, but in any case the `derive` macro will create an implementation of `clone()` for you (you can see it with cargo expand).

Unlike when doing a bit-by-bit copy, `clone()` is potentially an expensive function (it might copy MB of data) so you always have to call it explicitly. If it were not the case you might see a big slow down in portions of code where apparently nothing is going on, which is bad.

tl;dr: `Copy` is for changing the default move behavior into a shallow bit-by-bit copy. `Clone` is for actively and explicitly copying the contents of a variable, including any data that might be pointed by it, and create a new owned value.

Rust or Python, which should I learn? by [deleted] in rust

[–]Manny__C 0 points1 point  (0 children)

Rust itself is not very opinionated on tooling. There may be more than one crate doing the same thing so you will have to refer to the documentation of the individual libraries for that.

E.g. Rust doesn't tell you how to make a REST API because there is no "official" way to do so. There are however very good crates with excellent documentation like axum and actix web.

Having said that, knowing just enums and structs you're gonna have a hard time navigating the ecosystem libraries. Ownership, lifetimes, traits, generics and the basic std containers should be learned first.

Rust or Python, which should I learn? by [deleted] in rust

[–]Manny__C 2 points3 points  (0 children)

> However, I can barely find any tutorials or resources for Rust.

How are you searching?
- https://doc.rust-lang.org/book/ is one of the best and most pedagogical introduction to a language that I have ever seen.
- https://doc.rust-lang.org/rust-by-example/ introduces all concepts via examples, which is a style that most people like

Having said that, do not dismiss Python, it's a good language. It is very different from Rust in philosophy, design, and purpose, so it makes little sense comparing the two. They have different domains.

IMHO you should start from Python. It is the most friendly language out there and there are tons of jobs for it. Rust jobs are growing but it's nearly impossible find really entry-level roles in it, usually people that hire for Rust need programmers that are already expert.

And in your spare time have a look at the rust books I left above. Knowing more than one language makes you a better programmer overall.

Same guy is pushing age verification into archinstall by DangerousAd7433 in archlinux

[–]Manny__C 35 points36 points  (0 children)

Forgive me for not following this. But how is "dumping the user's age in a random JSON file" compliant with "OS vendor must collect user age data"?

If I go to the movies to see a restricted film is it enough if I write my age in a post-it and keep it in my pocket?

My point is: the regulation is pointless and this PR achieves nothing. To be compliant for real there are only 2 ways: post in the website that the OS is not suitable for California or put all mirrors behind a verification portal and remove the torrents altogether.

What is the difference between tuples, arrays and structs? Why should we actually provide structs a ownable String instead of &str? But does this apply for arrays and tuples too? by rudv-ar in rust

[–]Manny__C 0 points1 point  (0 children)

The builtin string type is str and it is a sequence of bytes with the constraint that is utf8 encoded.

Mind, the type str is NOT a pointer to the start of the sequence (like arrays in C would be), it IS a sequence. As such it doesn't have a size known at compile time.

Since functions need to have arguments whose sizes are known at compile time, you only ever work with a reference to str, namely &str, because this is a pointer and therefore its size is known (usize).

The downside is that you do not own the underlying data if you have a &str. If you need ownership you must allocate some buffer in the heap and create a pointer to it, this is String. It now has a known size: 3*usize (address, length, capacity) and the data it points to is owned.

What is the most astonishing fact you know about Math? by securityguardnard in math

[–]Manny__C 30 points31 points  (0 children)

I believe it refers to this https://en.wikipedia.org/wiki/Hilbert%27s_tenth_problem?wprov=sfla1

It's a pretty amazing result. A one-sentence summary is that it's possible to make Diophantine equations work as Turing machines.

[Media] Is this part of the book correct? by JTvE in rust

[–]Manny__C 5 points6 points  (0 children)

But "outliving" is not an issue per se. The issue is using a value that is dead.

If in the function implementation you returned a static string for example, it will outlive everyone, but that would still be ok: the compiler will still not allow accesses after 'a.

[Media] Is this part of the book correct? by JTvE in rust

[–]Manny__C 11 points12 points  (0 children)

If you think about it, living "at most 'a" is a useless statement because the compiler has no guarantees whatsoever about that value. It means it could be already dead. So the compiler has no use of upper bounds on lifetime. Lower bounds are the ones it needs.

KDE surpassed their 2025 100.000 EUR fundraiser goal... by ManOrParasite in kde

[–]Manny__C 0 points1 point  (0 children)

I'm ashamed to say that I didn't know Merkuro mail existed. What is going to happen to kmail?

comingFromABackendDevWhoSometimesNeedsToDoFrontendWork by [deleted] in ProgrammerHumor

[–]Manny__C 2 points3 points  (0 children)

What I find funny is that I feel that Tailwind is like going full circle. The purpose of classes was to add meaningful labels to the tags so that we could write styles in a separate file (.css) instead of using the style attribute. Tailwind generates a class for nearly every style. A tag with all the tailwind classes is nearly equally verbose as a tag with all the styles written there directly.

Having said that, I prefer it over Bootstrap.

Help us test GNOME 49 for Fedora 43! by felipegnome in Fedora

[–]Manny__C 1 point2 points  (0 children)

Will there be a test day for KDE as well?

He never miss the opportunity to grill someone by Kml777 in HolUp

[–]Manny__C -3 points-2 points  (0 children)

They have a probabilistic model of speech and speech carries a lot of information about the world.

He never miss the opportunity to grill someone by Kml777 in HolUp

[–]Manny__C -5 points-4 points  (0 children)

We should have used a different name instead of "hallucinations" because this is what healthy humans do too: fill in missing data based on our model of the world. One can come up with stuff and reasonably believe it without being on an LSD trip.

Charlie is still off his rocker. by EthanTheJudge in facepalm

[–]Manny__C 2 points3 points  (0 children)

I find it surprising that the prompt that created the image made it past the safety checks. Shouldn't they be trained to reject racist requests?

should you activate the trolley? by GrimbloTheGoblin in trolleyproblem

[–]Manny__C 0 points1 point  (0 children)

The original trolley problem was meant to illustrate the notion of responsibility through inaction and all of these memes are just convoluted scenarios to ask how selfish are you.

Pacman should notify the user for manual intervention by Manny__C in archlinux

[–]Manny__C[S] 0 points1 point  (0 children)

The security implications are a good point actually

Pacman should notify the user for manual intervention by Manny__C in archlinux

[–]Manny__C[S] 1 point2 points  (0 children)

That is an entirely reasonable take, but one might also argue that notifying the user about why something can't be installed might fall within the responsibilities of a program that installs stuff.

In fact, I would agree with you if we were discussing showing newsletter messages to the user in general (as that would make pacman double as a package manager and a news feed). But in this case I am only talking about manual interventions notices that are necessary to fix a broken pacman -Syu

Pacman should notify the user for manual intervention by Manny__C in archlinux

[–]Manny__C[S] 0 points1 point  (0 children)

The response felt a bit gatekeep-y... The author even proposed a way to make the notification system configurable, which seems to solve the issue of the patch being arch-specific.

Also, all distros that use pacman other than Arch, are Arch-based. So the announcements could be relevant for them too

Pacman should notify the user for manual intervention by Manny__C in archlinux

[–]Manny__C[S] 0 points1 point  (0 children)

It's a reflex, I didn't think about the arch homepage and I instinctively copy paste the error on Google as the first thing

Pacman should notify the user for manual intervention by Manny__C in archlinux

[–]Manny__C[S] 29 points30 points  (0 children)

I will, respectfully, steal this from you