arendjr

@arendjr@programming.dev

This profile is from a federated server and may be incomplete. Browse more on the original instance.

arendjr,

I greatly fear refactoring in Rust. Making a single conceptual change can require a huge number of code changes in practice, especially if it’s a change to ownership.

I think this is a fair criticism, but I think you and the poster you responded to are talking about different things. Usually when people use the term “fearless” in relation to Rust, it means the language provides a high level of confidence that what you’re delivering is free of mistakes. This certainly applies to refactoring too, where usually after you are done, and things compile again, you can be reasonably confident things work as before (assuming you didn’t make other changes the type system can’t catch for you).

The kind of fear you are describing sounds more like a discouragement because of the amount of work ahead of you. That’s fair, because Rust does sometimes make things harder. I just think many Rust developers will disagree with you, not because you’re wrong, but because they may not feel the same type of discouragement, possibly because they’ve learned to appreciate the rewards more.

arendjr,

let alone if it’s technically “real” (as in physical in any way.)

This right here might already be a flaw in your argument. Something doesn’t need to be physical to be real. In fact, there’s scientific evidence that physical reality itself is an illusion created through observation. That implies (although it cannot prove) that consciousness may be a higher construct that exists outside of physical reality itself.

If you’re interested in the philosophical questions this raises, there’s a great summary article that was published in Nature: www.nature.com/articles/436029a

arendjr,

I see that’s certainly a different way of looking at it :) Of course I can’t say with any authority that it must be wrong, but I think it’s a flaw because it seems you’re presuming that consciousness arises from physical properties. If the physical act of copying a brain’s data were to give rise to consciousness, that would imply consciousness is a product of physical reality. But my position (and that of the paper I linked) is that physical reality is a product of mental consciousness.

arendjr,

Do elaborate on the batshit part :) It’s a scientific fact that physical matter does not exist in its physical form when unobserved. This may not prove the existence of consciousness, but it certainly makes it plausible. It certainly invalidates physical reality as the “source of truth”, so to say. Which makes the explanation that physical reality is a product of consciousness not just plausible, but more likely than the other way around. Again, not a proof, but far from batshit.

arendjr, (edited )

Thanks, that seems a fair approach, although it doesn’t have me entirely convinced yet. Can you explain what the physical form of a wave function is? Because it’s not like a wave, such as waves in the sea. It’s really a wave function, an abstract representation of probabilities which in my understanding does not have any physical representation.

You say the building does not start acting like a wave, and you’re right, that would be silly. But it does enter into a superposition where the building can be either collapsed or not. Like Schreudinger’s cat, which can be dead or alive, and will be in a superposition of both until observation happens again. And yes, the probabilities of this superposition are indeed expressed through the wave function, even though there is no physical wave.

It’s true observation does not require consciousness. But until we know what does constitute observation, I believe consciousness provides a plausible explanation.

arendjr,

In fact, one of the great mysteries of physics right now is why only quantum objects have that property, and in order to figure that out we have to figure out what interaction “observation” actually is.

This does not stroke with my understanding of quantum physics. As far as we know there is no clear distinction between “quantum objects” vs “non-quantum objects”. The double slit experiment has been reproduced with molecules as large as 114 atoms, and there seems no reason to believe that would be the upper limit: livescience.com/19268-quantum-double-slit-experim…

This proves that the wave is in fact real, because we can see the effects of it.

The only part that’s proven is the interference pattern. So yes, we know it acts like a wave in that particular sense. But that’s not the same thing as saying it is a wave in the physical sense. A wave in the classic physical sense doesn’t collapse upon observation. I know it’s real in an abstract sense. I’m just questioning the physical nature of that reality.

arendjr,

can you define physical for me?

The distinction I tend to make is between physical using the classical definition of physics (where everything is made of particles basically) and the quantum mechanical physics which defies “physical” in the classical sense. So far we’ve only been able to scientifically witness quantum physics in small particles, but as you say, there’s no reason it can’t apply at a macro scale, just… we don’t know how to witness it, if possible.

it doesn’t require an observer to collapse the wave function

Or maybe it does? The explanation I have for us being unable to apply the experiments at a larger scale is that as we scale things up, it becomes harder and harder to avoid accidental observation that would taint the experiment. But that’s really no more than a hunch/gut feeling. I would have no idea how to prove that 😅

arendjr,

Agreed on all counts, except it being useless to think about :) It’s only useless if you dismiss philosophy as interesting altogether.

But that kinda misses the point, right? Like, all that means is that the observation may have created the particle, not that the observation created reality, because reality is not all particles.

I guess that depends on the point being made. You didn’t raise this argument, but I often see people arguing that the universe is deterministic and therefore we cannot have free will. But the quantum mechanical reality is probabilistic, which does leave room for things such as free will.

I can agree with your view to say observation doesn’t create reality, but then it does still affect it by collapsing the wave function. It’s a meaningful distinction to make in a discussion about consciousness, since it leaves open the possibility that our consciousness is not merely an emergent property of complex interaction that has an illusion of free will, but that it may actually be an agent of free will.

And yes, I fully recognise this enters into the philosophical realm and there is no science to support these claims. I’m merely arguing that science leaves open a path that enters that realm, and from there it is up to us to make sense of it.

There is the philosophical adage “I think therefore I am”, which I do adhere to. I know I am, so I’ll consider as flawed any reasoning that says I’m not. Maybe that just makes me a particularly stubborn scientific curiosity, but I like to think I’m more than that :)

arendjr,

I can’t say for sure we won’t need to revisit this again as we learn more about the nature of what data is missing and whether with more context we can automatically triage and notify the right people, but for now it feels like the cost / benefit ratio of “talking versus doing” is about right.

This was a nice post, and I agree people should think a bit about how to name things, because getting it wrong can lead to others making wrong assumptions, which ends up wasting a lot of time.

That said, I would get pretty annoyed if a PR I’m involved with ended up with this level of bike-shedding over a function name. If the end goal is to avoid wasting people’s time, bringing out the big guns and making three attempts, with three rounds of review, to get the name of such a trivial function right is surely throwing out the cost / benefit ratio right upfront.

arendjr,

Couple of weeks ago there was a post here calling for more content to be posted in this sub, so I figured you might appreciate the content. As a project, Biome is also helping a lot of web developers become interested in Rust, since many of our contributors make their first-time Rust contributions there.

arendjr,

Surely it would be easier to leave that to the TypeeScript devs and just focus on linting and formatting, no?

Almost nobody uses the TypeScript compiler for transpilation. I think most people nowadays use either Esbuild or SWC for that. The advantage that Biome has is that we already have the parsing and the serialization infrastructure and can add features like that with relative ease. For users that means fewer dependencies, less configuration, and less room for error.

arendjr,

It’s a fair concern, but if there’s any consolation, we’re experiencing quite the influx of new contributors lately and the maintainer team is growing every month for the last couple of months. There’s a lot of steam coming our way, so I don’t think we’ll run out just yet :)

arendjr,

❤️

If Inheritance is so bad, why does everyone use it? (buttondown.email)

This essay says that inheritance is harmful and if possible you should “ban inheritance completely”. You see these arguments a lot, as well as things like “prefer composition to inheritance”. A lot of these arguments argue that in practice inheritance has problems. But they don’t preclude inheritance working in another...

arendjr,

So to put it all together ComplexEnum = Nothing | TaggedU32 | (bool x String)? Is that correct?

Pretty much, yeah. But just be aware the tags are effectively unique constants, so each has only one value. For consistency I would write it as:

ComplexEnum = Nothing | Something(u32) | LotsOfThings(bool x String)

In this notation,Something(u32) could also be written as 1 x u32 because tags are constants.

arendjr,

I mean, the actual operation is just an example, of course. Feel free to make it a .map() operation instead. The strings couldn’t be reused then, but the vector’s allocation still could… in theory.

arendjr, (edited )

Yeah, that’s helpful if I would be currently optimizing a hot loop now. But I was really just using it as an example. Also, retain_mut() doesn’t compose as well.

I’d much rather write:


<span style="font-weight:bold;color:#a71d5d;">let</span><span style="color:#323232;"> vec_a: Vec<String> </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="font-style:italic;color:#969896;">/* ... */</span><span style="color:#323232;">;
</span><span style="font-weight:bold;color:#a71d5d;">let</span><span style="color:#323232;"> vec_b: Vec<String> </span><span style="font-weight:bold;color:#a71d5d;">=</span><span style="color:#323232;"> vec_a
</span><span style="color:#323232;">    .</span><span style="color:#62a35c;">into_iter</span><span style="color:#323232;">()
</span><span style="color:#323232;">    .</span><span style="color:#62a35c;">filter</span><span style="color:#323232;">(some_filter)
</span><span style="color:#323232;">    .</span><span style="color:#62a35c;">map</span><span style="color:#323232;">(some_map_fn)
</span><span style="color:#323232;">    .</span><span style="color:#62a35c;">collect</span><span style="color:#323232;">();
</span>

Over:


<span style="font-weight:bold;color:#a71d5d;">let mut</span><span style="color:#323232;"> vec_a: Vec<String> </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="font-style:italic;color:#969896;">/* ... */</span><span style="color:#323232;">;
</span><span style="color:#323232;">vec_a.</span><span style="color:#62a35c;">retain_mut</span><span style="color:#323232;">(|x| </span><span style="font-weight:bold;color:#a71d5d;">if </span><span style="color:#62a35c;">some_filter</span><span style="color:#323232;">(x) {
</span><span style="color:#323232;">    </span><span style="font-weight:bold;color:#a71d5d;">*</span><span style="color:#323232;">x </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#62a35c;">some_map_fn</span><span style="color:#323232;">(</span><span style="font-weight:bold;color:#a71d5d;">*</span><span style="color:#323232;">x); </span><span style="font-style:italic;color:#969896;">// Yikes, cannot move out of reference.
</span><span style="color:#323232;">    </span><span style="color:#0086b3;">true
</span><span style="color:#323232;">} </span><span style="font-weight:bold;color:#a71d5d;">else </span><span style="color:#323232;">{
</span><span style="color:#323232;">    </span><span style="color:#0086b3;">false
</span><span style="color:#323232;">});
</span>

And it would be nice if that would be optimized the same. After all, the point of Rust’s iterators is to provide zero-cost abstractions. In my opinion, functions like retain_mut() represent a leakiness to that abstraction, because the alternative turns out to not be zero cost.

arendjr,

That was a super interesting and informative read! Exactly what I was hoping to find when I posted this, thanks!

arendjr,

Thanks! That’s very much what I was looking for!

arendjr,

The composability doesn’t have much to do with whether it’s a reference or a move, it’s because it bypasses usage of the Iterator methods. Iterators chains can consist of filter, map and other operations, which allows various functions and/or closures to be composed together. Whereas with retain_mut() there isn’t really a chain and functions you may otherwise use in an iterator chain become harder to (re)use.

arendjr,

It also seems harsh to say iterators aren’t a zero-cost abstraction if they miss an optimisation that falls outside what the API promises. It’s natural to expect collect to allocate, no?

You’re right, I wouldn’t say iterators aren’t a zero-cost abstraction. But most abstractions are also leaky – it’s just the extent in which the leakiness is exposed that makes them more or less effective. As such, saying to just use retain_mut instead of the iterator approach highlights the shortcoming of the abstraction. But if the same results could be achieved while still using the same iterator, that would make that abstraction more useful and consistent. And that’s great, because that means we need to worry less when using iterators :)

arendjr,

What are the chances Qt is affected by this issue too?

arendjr, (edited )

That’s certainly not the case, because that’s like saying the issue is with Rust’s string slices. I think you may have missed the part of the issue where batch scripts require additional escaping due to Windows’ command handling. It’s a ridiculous design of the Windows API system, which is also why (almost?) every language they tested was vulnerable, so it would be actually very outstanding if Qt prevented this.

For C++ devs not using Qt it’s just another footgun they’ll likely keep introducing security issues with as well. But if you do use Qt, I think it’s better to double-check since it may also require a patch.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • provamag3
  • kavyap
  • DreamBathrooms
  • osvaldo12
  • magazineikmin
  • InstantRegret
  • everett
  • Youngstown
  • ngwrru68w68
  • slotface
  • rosin
  • GTA5RPClips
  • tester
  • PowerRangers
  • anitta
  • thenastyranch
  • mdbf
  • ethstaker
  • cisconetworking
  • Durango
  • vwfavf
  • normalnudes
  • tacticalgear
  • khanakhh
  • modclub
  • cubers
  • Leos
  • megavids
  • All magazines