← Home ← Back to /g/

Thread 106532364

284 posts 32 images /g/
Anonymous No.106532364 >>106532402 >>106532416 >>106532431 >>106532519 >>106532537 >>106532603 >>106532832 >>106544958 >>106546946 >>106548784 >>106549383 >>106549688 >>106550201 >>106550292 >>106550323 >>106551270 >>106551706
>"hurr durr, Rust is not hard at all and I never had problems fighting the borrow checker!"
>*uses RefCell*
I am so fucking sick of this
Anonymous No.106532373 >>106532395
it's the exact same thing with kotlin vs. java
"dude it's TYPE SAFE!"
>does a bunch of shit to get around that
pointer problems suck but it's always YOUR JOB to figure them out
Anonymous No.106532395 >>106532446
>>106532373
QRD? Are they not both Garbage Collected?
Anonymous No.106532402 >>106532441
>>106532364 (OP)
>uses tool in the language to do something
what did OP mean by this?
Anonymous No.106532416 >>106532441
>>106532364 (OP)
explain to me why using RefCell for certain things is bad
Anonymous No.106532429 >>106546758
>"hurr durr, C++ is not hard at all and I never had to manage memory manually"
>*uses std::vector*
I am so fucking sick of this

this is how you sound
Anonymous No.106532431
>>106532364 (OP)
she's so cute! we need to get more girls like her into coding :3
Anonymous No.106532441 >>106532466 >>106532486 >>106532583 >>106532848 >>106532918 >>106534094 >>106537626 >>106547592 >>106551706
>>106532416
>>106532402
If you use Rc, RefCell or std::shared_pointer EVER, you might as well use Go/C#
So, usecase for Rust?
Anonymous No.106532446 >>106546276
>>106532395
they ARE but the runtime itself has to remove them :^)
Anonymous No.106532466
>>106532441
>So, usecase for Rust?
You're too stupid to know what a linter is and also too stupid to check your own code, but NOT QUITE stupid enough to where you can't write a bunch of slop that should fail because of pointer errors (AKA indicating you're doing it wrong)
Anonymous No.106532486 >>106532503
>>106532441
You're not employed. You have never written any valuable open source software. You're a hobbyist programmer that makes useless toys, and you've never had sex.
Anonymous No.106532494 >>106532507
at least he is programming unlike 90% of /g/
Anonymous No.106532503
>>106532486
All of that also applies to you, sis ;)
Anonymous No.106532507
>>106532494
he's amateurgramming
Anonymous No.106532512
compiling rust codes is literally painful
Anonymous No.106532519 >>106544737
>>106532364 (OP)
i've never seen this text editor. what's this?
Anonymous No.106532537 >>106532585
>>106532364 (OP)

This is a low iq bait

What is a smart pointer (shared_ptr) in C++? Exactly the same wrapper type.

kys
Anonymous No.106532583 >>106532619
>>106532441
w-what?
are you literally retarded?
Anonymous No.106532585 >>106537560
>>106532537
In C++ you are not required to use it since you can just new and delete.
In Rust you are required to do this for any graphical application with a state, because the borrow checker does not understand that "this dialog object owns the state and also owns all callbacks that happen on it, therefore it should be allowed to borrow a reference to the state inside any callback where the dialog object is the first parameter, because that indicates that the dialog object owns this callback"
There is no way to do that using the Rust's borrow checker.
Anonymous No.106532603
>>106532364 (OP)
NOOOOOOOOO YOUR NOT ALLOWED TO USE REFCELL EVERYHING IS SUPPOSED TO BE IMMUTABLE WTFWTFWTFWTFWTFWTF
Anonymous No.106532619 >>106532638 >>106532642 >>106532688
>>106532583
prove me wrong.
a garbage collector has been proven to outperform a C++ program with heavy smart pointer usage. So, why would Rust be any different.
Anonymous No.106532638 >>106532699
>>106532619
>proven
the fever and hallucinogen fueled dreams you had while severely intoxicated don't count as proof
Anonymous No.106532642
>>106532619
>prove me wrong
lmao
Anonymous No.106532666
ChatGPT thread
Anonymous No.106532688 >>106532699
>>106532619
prove you wrong how?
what are you even talking about?
non-determinism calls for non-determinism solutions.
if you need refcounting, you need refcounting, whether you want it or not and you'll reimplement it if you don't have it available.

you should like a massive retard and should stop posting.
Anonymous No.106532699 >>106532713 >>106532717 >>106532768 >>106532983
>>106532638
>>106532688
RefCell is just slower than a language with a GC. Hate to break it to you, sis
Anonymous No.106532713 >>106532741 >>106542567
>>106532699
ah yes, the ultimate source... a barely voted comment on a stackoverflow post from a literal who
Anonymous No.106532717 >>106532746 >>106532768 >>106532983
>>106532699
Anonymous No.106532741
>>106532713
All I see from you is bark and no bite. I made an assertion and backed it up.
You backed up your assertions with nothing.
Therefore, I win.
Anonymous No.106532746 >>106532763
>>106532717
now it's orange reddit
>what are arena allocators
>what is creating objects on the stack, something shitty gc languages simply cannot do
it's embarrassing and you should kill yourself
Anonymous No.106532755
>Why are you using this tool?!
>Why are you using this tool that way?!
>REEEEEEEEEEEEEEEEEEE
Anonymous No.106532763 >>106532790
>>106532746
Explain to the thread how RefCell and shared_pointer make use of arena allocators and stack?
Anonymous No.106532768 >>106532787
>>106532699
>>106532717
the problem with retarded claims like this is it's always "in theory" and ignores all the actual tracing gc part of the costs.
"pauseless" GC's ignore trade-offs vs stop-the-world as well and ultimately every GC shitlang I ever dealt with was always much slower than C++ or Rust by orders of magnitude due to other factors unrelated to GC.
The reality is, C++ or Rust can simply use allocation patterns that look like "arenas" and still heem these shitty GC runtime languages anyway.
Anonymous No.106532787 >>106532814 >>106532876 >>106532899
>>106532768
>every GC shitlang I ever dealt with was always much slower than C++
because nobody in C++ uses std::shared_pointer. Everyone just uses unique where applicable and if unique is not applicable, everyone just uses raw pointers and new/delete mechanism
>or Rust
yeah maybe for command line programs, but any graphical program or any program that has a state (something that borrow checkers hate), will be using RefCell and therefore be SLOWER.
How many graphical Rust programs have you used?
Anonymous No.106532790 >>106532801
>>106532763
>RefCell
I'm not a tranny, I wouldn't know
>shared_pointer
it's known you can use custom allocators all throughout the std lib and you're trying to compare the generic use of a GC language to a very specific anti-pattern of manual memory management languages (heavy allocations) to make your argument sound better
Anonymous No.106532801 >>106532831
>>106532790
This entire thread is about RefCell and reference counting and you say it is an "anti pattern"
yes it is, but we are talking about Rust forcing you to use this pattern and hence how GC langs are just better than Rust and you should not use Rust.
Anonymous No.106532814 >>106532825
>>106532787
>because nobody in C++ uses std::shared_pointer
extremely shitty bait post. have a (You). now fuck off.
Anonymous No.106532825
>>106532814
I accept your concession.
Anonymous No.106532831
>>106532801
you brought c++ into this with false claims trying to support your distorted view of gc languages
Anonymous No.106532832 >>106532845 >>106533046
>>106532364 (OP)
> "Programmers can NEVER be trusted to write safe code in an unsafe language, ever. So use Rust."
> look into any nontrivial Rust codebase
> unsafe fn
> unsafe extern
> unsafe { }
> unsafe
> unsafe impl function
> "When to Use Unsafe Code: "
> "Using unsafe to use one of the five superpowers just discussed isn’t wrong or even frowned upon"
Anonymous No.106532845
>>106532832
unsafe is based because it is fast. RefCell is cringe because it makes your "ultra fast" Rust program slower than an equivalent Java program.
Anonymous No.106532848 >>106532868 >>106532873 >>106540221
>>106532441
Linux and GTK are full of shared pointers. Wdym?
Anonymous No.106532868 >>106532894 >>106532899 >>106540221
>>106532848
Gtk is C and Linux kernel has ZERO shared pointers (and is also C)
Anonymous No.106532873 >>106540221
>>106532848
>linux
>gtk
>c++
shit bait 0/10 made me reply
Anonymous No.106532876
>>106532787
Unique_ptr is just Box in Rust, except in Rust you do not have to pay for overhead of C++ move semantics. Box is truly zero cost in Rust.
Anonymous No.106532894 >>106532903 >>106532912 >>106532916
>>106532868
https://docs.kernel.org/core-api/kref.html
https://docs.gtk.org/glib/reference-counting.html

Why do cniles always speak about this as they have 0 idea about? It literally takes 5min to check this.
Anonymous No.106532899
>>106532868
>Linux kernel has ZERO shared pointers
same retard who said >>106532787
huh?
kek
Anonymous No.106532903
>>106532894
>this as
*things
Anonymous No.106532912
>>106532894
>https://docs.kernel.org/core-api/kref.html
Aha, so THIS is why Linux is so fucking slow lately
Anonymous No.106532916
>>106532894
it's possible that he took a look in gtk git page and went "yep, C", not knowing that glib reimplements OOP-ware in most blasphemous way that somehow works
Anonymous No.106532918 >>106532951
>>106532441
>if you ever used a fork might as well chop off your hands and replace them with forks
Anonymous No.106532951 >>106537492
>>106532918
Worst analogy itt award
Anonymous No.106532983 >>106533016
>>106532699
>>106532717
>dumb retards that don't understand the actual purpose of refcell, reference counting, or GC, and that refcell is orthogonal to the other two
Anonymous No.106533016 >>106533053
>>106532983
doesn't matter, overhead is the same
Rc counts number of "owners", RefCell counts the number of "mutable references"
It is all the same thing and has the same overhead
In C++ one could just use raw pointers to bypass this overhead.
Anonymous No.106533046 >>106533059 >>106542532 >>106542545
>>106532832
Uh-huh, sure buddy, let's see
https://lib.rs/std most popular rust crates

>https://github.com/serde-rs/serde
41k lines, 3 unsafes
>https://github.com/serde-rs/json
17k LoCs, 12 unsafes
>https://github.com/dtolnay/thiserror
4.5k LoCs, 0 unsafes
>https://github.com/rust-random/rand
>11k LoCs, 17 unsafes
Anonymous No.106533053 >>106537099
>>106533016
>RefCell counts the number of "mutable references"
no it doesn't
>It is all the same thing and has the same overhead
no it isn't
>In C++ one could just use raw pointers to bypass this overhead.
in C++ you could just use a raw pointer to corrupt your data, yes
Anonymous No.106533059 >>106533073 >>106533091 >>106533351 >>106533576 >>106534021 >>106547094
>>106533046
Why does serde take over 200MB of my storage space? json-c only takes a couple of KB
Anonymous No.106533073 >>106547265
>>106533059
Because Dave Tolnay hates you.
Anonymous No.106533091 >>106533124 >>106547265
>>106533059
Why are you moving the goalposts?
Anonymous No.106533124
>>106533091
I just want to hate on Rust without bringing in trannies because it makes it seem as though I have no actual argument.
Anonymous No.106533351 >>106533406 >>106547265
>>106533059
>compiling binaries takes storage
News at 11.
Anonymous No.106533406 >>106534021 >>106534198
>>106533351
Yes, now why does it take MORE storage than every other json library in existance? that is the real question, isn't it?
Another example, Gson library, one of the most extensive (perhaps bloated?) Json libraries in existance. The JAR is 280KB in size ...
https://repo1.maven.org/maven2/com/google/code/gson/gson/2.13.1/gson-2.13.1.jar
Anonymous No.106533576 >>106547265
>>106533059
filtering poor people
Anonymous No.106534021 >>106547265
>>106533059
>>106533406
Serde is not a json library. It's a fully fledged backend for making serialization libraries.
Anonymous No.106534094 >>106534115
>>106532441
>If you use Rc, RefCell or std::shared_pointer EVER
What if I have multiple detached threads reading the same resource that I want to be deleted when all the threads are done
Anonymous No.106534115 >>106534212 >>106534223
>>106534094
You don't need refcounting for that either, because typically when your main thread is done processing, it will just wait for the other threads to finish. And after that, you free the resources.
The pthread_join() function waits for the thread specified by thread to terminate. If that thread has already terminated, then pthread_join() returns immediately. The thread specified by
thread must be joinable.
Anonymous No.106534198 >>106534256
>>106533406
because, assuming we're talking about serde_derive, it generates a lot of intermediate code and a resultant .so/.dll that rustc dynamically links and executes to transform your serde marked structs into rust code. both C++ and Rust have a tendency to build massive binaries, most if it being symbols or debug information.
Anonymous No.106534212 >>106534232
>>106534115
and what if the threads are detached. you seem to be having some difficulty understanding problems that refcounted types solve.
Anonymous No.106534223 >>106534232
>>106534115
>detached threads
The type of thread you start up, detach, and let the OS close them. Main thread never joins
I like using them for writing to disk
Anonymous No.106534232 >>106534268 >>106534450
>>106534223
>>106534212
Don't detach them, there is no reason to.
Anonymous No.106534256 >>106534277
>>106534198
The serialization/deserialization routines do not end up in final binary unless you use them. They can still take space in intermediaries though
Anonymous No.106534266 >>106535973
A lot of binary bloat in Rust could be eliminated if they realized that runtime reflection is sometimes kind of good, actually.
Anonymous No.106534268
>>106534232
how? unless you're proposing structured concurrency, which rust is probably the only implementation that is actually valid and correct.
Anonymous No.106534277
>>106534256
I'm aware, but retard-kun asked why his compiler output folder was big. I'm merely pointing out compiler output from LLVM frontends will always be fuckhuge.
Anonymous No.106534450
>>106534232
>there's NO USECASE for A
>what about B
>ok well that might need A, but there's NO USE CASE for B
>what about C
>ok well that might need B, but there's NO USE FASE for C
Anonymous No.106534838
>>106534809
lol, oops.
Anonymous No.106535973
>>106534266
That's true zero cost abstractions bloat binary with monomorphisations. But it's often better to trade storage space for runtime performance, up to a point ofc.
Anonymous No.106537099 >>106537551 >>106537694 >>106538268
>>106533053
having multiple mutable references in a single thread is safe, rust is just retarted and doesn't allow you to do this without unsafe
Anonymous No.106537474
usecase for coding stream?
Anonymous No.106537492
>>106532951
>if you have an appropriate use for this tool EVER you need to start exclusively using it and remove any ability to use a different one
seems apt to me
Anonymous No.106537551
>>106537099
>having multiple mutable references in a single thread is safe
That's an undefined behavior.
Anonymous No.106537560
>>106532585
Maybe there is currently no way for the borrowchecker to do that, but there should be a way, patches welcome
Anonymous No.106537626
>>106532441
> you can never use anything once, you must always use everything all the time no matter what
Anonymous No.106537694 >>106546585
>>106537099
Yes, dangling pointers are impossible in a single-threaded context.
Anonymous No.106538268
>>106537099
retard
Anonymous No.106540221
>>106532848
>>106532868
>>106532873
Gtk uses GObject which is basically a shared pointer and OOP inheritance implementation in C
Anonymous No.106542532 >>106542584 >>106543796
>>106533046
Your data does not match what lib.rs reports.

What happens if you include tokio, and the 15 most popular crates, and the 15 most starred Github projects?

And when you write
>unsafes
does that refer to occurrences of the unsafe keyword or the number of lines contained in each unsafe block? Some unsafe blocks can be ridiculously long.

https://github.com/rust-lang/rust/tree/master/library/core/src/slice/sort
Anonymous No.106542545
>>106533046
https://materialize.com/blog/rust-concurrency-bug-unbounded-channels/
Anonymous No.106542567
>>106532713
This is basic CS knowledge though.
Anonymous No.106542584 >>106542596 >>106543846
>>106542532
>// SAFETY: we made sure that

Cnile sisters, I don't feel so good...
Anonymous No.106542596 >>106543846 >>106544335
>>106542584
I once saw a case of UB in the standard library of Rust, where the UB was in the section of code with lots of SAFETY comments.

https://github.com/rust-lang/rust/commit/71f5cfb21f3fd2f1740bced061c66ff112fec259

SAFETY comments do not magically make the code correct or free of UB.
Anonymous No.106543560
What in the name of fuck is ebussi doing? Don't you dare tell me he is rewriting gtk in Rust.
Anonymous No.106543792
Rust is for people too stupid to learn how to manage memory themselves. Historically these kind of people were filtered out of the industry once they started doing anything non trivial. Now they have shit like Rust, Java, Js, Python etc etc which allows them to continue shitting out garbage code because they do not have to worry about the memory layout or structure of their program, the language does it for them, albeit, poorly. This results in a subclass of programmers that are about as good as 1st year CS undergrads who proceed to shit out more and more garbage software while giving said people an over abundance of confidence which is not warranted. This is true in almost every domain and it's part of the reason why the world is in a rush to the bottom. It will never get better until society cracks under the collective incompetence of the work force and greed of the pay masters.
Anonymous No.106543796 >>106544302
>>106542532
>does that refer to occurrences of the unsafe keyword or the number of lines contained in each unsafe block? Some unsafe blocks can be ridiculously long.
occurences of unsafe keyword,most of which were single-line to call a single function, most of which was std::str::from_utf8_unchecked
>What happens if you include tokio, and the 15 most popular crates, and the 15 most starred Github projects?
how the fuck should I know you want more data get it yourself
Anonymous No.106543846 >>106544335
>>106542596
yes, but they explicitly explain whatever invariants you are aiming to enforce, which then you can verify or scrutinize, rather than leaving it as an undocumented emergent property of multiple disjointed elements
>>106542584
well they did
Anonymous No.106544302 >>106545152
>>106543796
Nice cherrypicking then, and you never explained why your data is different from the website.
Anonymous No.106544308
>colorful shell
oot, but isn't gnomedev hate that shit
Anonymous No.106544335 >>106546060
>>106543846
And not all SAFETY comments are checked, and considering the UB in the Rust standard library >>106542596, they might do more harm than good in some cases if they lure developers into a false sense of security. And unsafe Rust is harder than C++, in part due to the no aliasing requirement.
Anonymous No.106544366
Anonymous No.106544737
>>106532519
GNOME Builder
Anonymous No.106544958 >>106544975 >>106546367
>>106532364 (OP)
qrd on RefCell?
Anonymous No.106544975 >>106545433 >>106546367
>>106544958
It allows mutation through a shared reference.
Anonymous No.106545152 >>106546371
>>106544302
I just went to the repo, put unsafe in search bar and counted
Anonymous No.106545433 >>106545442 >>106545444 >>106545461 >>106545479 >>106545731 >>106546430
>>106544975
I see. The borrow checker should have allowed mutable shared references when in a single thread context.
The justifications I've read that about why it's not like that are retarded. Things like iterators and side effects orderings. Iterator safety should simply be ensured by another mechanism and likewise the side effect ordering thing shouldn't be a concern for the borrow checker.
Anonymous No.106545442
>>106545433
>The borrow checker should have allowed...
in the first place.
Anonymous No.106545444 >>106545475
>>106545433
>The borrow checker should have allowed mutable shared references when in a single thread context.
no
Anonymous No.106545461 >>106545475 >>106546421
>>106545433
>hurr durr
push_all(&vec, &mut vec)
dumb retard
Anonymous No.106545475
>>106545444
argument or stfu
>>106545461
what does it do?
Anonymous No.106545479 >>106545535 >>106546430
>>106545433
>The borrow checker should have allowed mutable shared references when in a single thread context.
That's an undefined behavior
Anonymous No.106545535 >>106545656 >>106546430
>>106545479
that's not an argument
if it's in a single thread, you can very well store a (mutable reference) pointer to a dynamic array in some data structure, and at the same time pass a mutable reference pointer to a function that will append elements to the array. There isn't any memory issue with that, even if a realloc happens, as long at array is boxed.

If the shared reference is the raw pointer to the array then it make sense to forbid reallocs if there is more than one reference, but mutation of the elements of the array itself is perfectly fine, in a single thread.
Anonymous No.106545656 >>106545700 >>106545754 >>106546430 >>106546794
>>106545535
>There isn't any memory issue with that, even if a realloc happens, as long at array is boxed.
let el = &vec[0];
vec.push(0);
*el = 5; // potential dangling pointer


>mutation of the elements of the array itself is perfectly fine, in a single thread.
You can have mutable references to multiple different elements of an array.
Anonymous No.106545700 >>106545731 >>106546430 >>106546487
>>106545656
i don't know how y'all argue with people who haven't even heard of basic shit like iterator invalidation.
https://www.geeksforgeeks.org/cpp/iterator-invalidation-cpp/
>The borrow checker should have allowed mutable shared references when in a single thread context. Just remember an indefinite set of rules to stay safe like us totally bug-free coding cpp geniuses do. Rust borrow checker is hard. cpp is easier....
Anonymous No.106545731 >>106545967
>>106545700
but >>106545433 mentioned iterators
Anonymous No.106545754 >>106545764 >>106546250
>>106545656
That's not mutation, that's moving the object somewhere else. Mutation is fine, but moving is not.
I don't care if Rust calls moving a mutation, the fact is that if you have an array of numbers, mutating the number at index [0] doesn't cause any problem.
Anonymous No.106545764 >>106545863 >>106545882
>>106545754
none of what you wrote makes any sense. stick to fizzbuzz, retard.
Anonymous No.106545863
>>106545764
tell him to write a non-Send/Sync pointer wrapper and share it with us instead ;)
Anonymous No.106545882 >>106545890 >>106545923
>>106545764
2 different references can perfectly mutate a the fields of a struct or elements of a fixed sized array, in a single thread, without any safety issue whatsoever.

This is irrefutable, shut the fuck up inbred.
Anonymous No.106545890 >>106545926
>>106545882
ok, nobody cares though.
Anonymous No.106545923 >>106546075 >>106546307 >>106546537 >>106546794
>>106545882
you can do this in Rust
https://doc.rust-lang.org/stable/std/primitive.slice.html#method.get_disjoint_mut
let v = &mut [1, 2, 3];

if let Ok([a, b]) = v.get_disjoint_mut([0, 2]) {
*a = 413;
*b = 612;
}

assert_eq!(v, &[413, 2, 612]);
Anonymous No.106545926
>>106545890
Apparently you do.
Anonymous No.106545967 >>106545990 >>106545996
>>106545731
and?
>Iterator safety should simply be ensured by another mechanism
what another mechanism? the toothfairy checking the binary?
>you shouldn't need a parachute when skydiving, your safety should be ensured by another mechanism, I have no fucking clue what that would be, but it should be something different
come up with a solution and we'll tell you why it's shit
Anonymous No.106545990 >>106546002
>>106545967
>what another mechanism?
you could check for invalidation at runtime with a generation counter.
>come up with a solution and we'll tell you why it's shit
dumb retard, I'm not disagreeing with you.
Anonymous No.106545996 >>106546006 >>106546032
>>106545967
>what another mechanism? the toothfairy checking the binary?
inside the body of the loop, disallow mutations to the thing that is iterated over
wow that was hard
Anonymous No.106546002
>>106545990
you could, at a cost
U can implement this in rust btw
Anonymous No.106546006 >>106546050
>>106545996
that's what rust does though
Anonymous No.106546032 >>106546104
>>106545996
what about not iterating?
what about containers in containers?
what about people that work around it by iterating indicies, then taking a reference to the ith element, then mutating the container?
Anonymous No.106546050 >>106546057
>>106546006
>more bad faith
Lol ok. You're proving that once again, Rust shilling is not based on technical grounds.
Anonymous No.106546057 >>106546104 >>106546127
>>106546050
>get btfo with facts and logic
>noooooooo! that's bad faith
keep crying, cnile
Anonymous No.106546060 >>106546717
>>106544335
Is pointer aliasing not also UB in C++? Or are you referring to a different kind of aliasing?
Anonymous No.106546075
>>106545923
you can split/chunk with many methods. a special mention of `slice.as_chunks_mut::<1>()` ;)
Anonymous No.106546080 >>106546088
I always thought that GNOME devs don't use their DE, but macs. However, it looks like ebussy mains it. What do I think of this..?
Anonymous No.106546088 >>106546108
>>106546080
why are you talking about gnome in a Rust thread?
Anonymous No.106546104 >>106546119
>>106546057
cope and seethe
>>106546032
>what about containers in containers?
This doesn't change anything.
>what about people that work around it by iterating indicies, then taking a reference to the ith element, then mutating the container?
this is too fucking vague to be either true or false
Anonymous No.106546108
>>106546088
nta. look at op picrel.
even if that's not ebussy (don't care to know), there is glib in the code ;)
Anonymous No.106546119 >>106546145
>>106546104
you seem smart and i appreciate your novel ideas in this thread.
can you share a demo of one of these ideas? tia
Anonymous No.106546127
>>106546057
>>get btfo with facts and logic
No, that's what I did. You lost but you won't admit it because you're a paid shill.
klll yourself
Anonymous No.106546145 >>106546170 >>106547324
>>106546119
>novel ideas
it's pointers 101, literally
Anonymous No.106546170
>>106546145
but Rust has pointers. are you just seething because the borrows check told you that your code is shit?
Anonymous No.106546222 >>106546232 >>106546905
Imagine sacrificing mutability, doubly linked list and graphs so that your language can have safe iterators.
Anonymous No.106546232 >>106546252 >>106546813
>>106546222
https://doc.rust-lang.org/stable/std/keyword.mut.html
https://doc.rust-lang.org/stable/std/collections/struct.LinkedList.html
https://github.com/Qiskit/rustworkx
Anonymous No.106546250 >>106546335
>>106545754
>That's not mutation
Pushing elements to a vector requires mutable access to it.

>you have an array of numbers, mutating the number at index [0] doesn't cause any problem.
You can have mutable references to multiple different elements of an array.
Anonymous No.106546252 >>106546261
>>106546232
Anonymous No.106546261 >>106546832
>>106546252
Because const and linked lists do not exists in other languages?
Anonymous No.106546276 >>106546322
>>106532446
It doesn't though. The JVM is strongly typed and the information is preserved and influences bytecode interpretation on the host machine.
Anonymous No.106546307 >>106546794
>>106545923
You can also just use destructuring to splt the references however you wish

struct Foo {
a: i32,
b: bool,
}

fn main() {
let mut arr = [
Foo { a: 1, b: true },
Foo { a: 2, b: false },
Foo { a: 3, b: true }
];

let &mut[
Foo { ref mut a, .. },
Foo { ref mut b, .. },
Foo { a: ref mut c, b: ref mut d }
] = &mut arr;

*a = 4;
*b = true;
*c = 5;
*d = false;
}
Anonymous No.106546322
>>106546276
https://kotlinlang.org/docs/generics.html#type-erasure
Anonymous No.106546335 >>106546350
>>106546250
>You can have mutable references to multiple different elements of an array.
You can't mutliple mutable references to the same elements of an array.
Anonymous No.106546350 >>106546370
>>106546335
That would be undefined behavior.
Anonymous No.106546367 >>106546377
>>106544958
>>106544975
Runtime checking, if you mess it up, your program might panic.
Anonymous No.106546370 >>106546493
>>106546350
For you.
Anonymous No.106546371
>>106545152
And that's not the only data you had, thus you again never explained it.
Anonymous No.106546377 >>106546859
>>106546367
so? panicking is memory safe.
Anonymous No.106546402 >>106546537 >>106546905
>this scares the Rustroon
int *array = malloc(16 * sizeof(int));

int *a = &array[0];
int *b = &array[0];

*a = 1;
*b = 2;

free(array);
Anonymous No.106546421
>>106545461
That example is, depending on what push_all does, a bug. And the borrow checker catching that bug is a good thing and speaks in favor of borrow checking. However, the borrow checker is not free for the design of the programming language or toolchains or programmers, and it disallows a number of correct programs as well, similar to static type checking in other programming languages. Are the trade-offs worth it? Personally, I hope for a successor language to C++ and Rust.
Anonymous No.106546430 >>106546442
>>106545433
>>106545479
>>106545535
>>106545656
>>106545700
Monologue?
Anonymous No.106546442 >>106546886
>>106546430
meds
Anonymous No.106546459 >>106546905
Rust BTFO
https://antelang.org/blog/safe_shared_mutability/
Anonymous No.106546487 >>106547447
>>106545700
>Rust borrow checker is hard. cpp is easier....
Low-IQ troll, are you truly too incompetent and stupid to differentiate between unsafe and the borrow checker? Off yourself.
Anonymous No.106546493 >>106546586 >>106546641 >>106546965
>>106546370
Anonymous No.106546537 >>106546651
>>106546402
nope, see >>106545923
Anonymous No.106546585 >>106546602
>>106537694
The problem is that rust prohibits this even if you put it in a reference counted wrapper.
Anonymous No.106546586 >>106546621
>>106546493
what is this supposed to be? there is so much UB in there, I can't even.
Anonymous No.106546602
>>106546585
what does reference counting have to do with mutability?
Anonymous No.106546621
>>106546586
It's an example of why you can't have "mutliple mutable references to the same elements of an array."
The anon I replied to did not believe this would be an undefined behavior.
Anonymous No.106546641 >>106546652 >>106546663 >>106547016
>>106546493
You can perfectly have 2 mutable pointers to overlapping regions of memory but I never said that you should pretend they don't alias each other.
But hey, thanks for the heads up that "unsafe" is actually a code word for malicious.
Anonymous No.106546651
>>106546537
you don't seem to understand what disjoint means
Anonymous No.106546652 >>106546797 >>106547016
>>106546641
pointers and references are not the same thing, dummy. of course you can have multiple mutable pointers to overlapping regions of memory.
Anonymous No.106546663 >>106546797
>>106546641
>You can perfectly have 2 mutable pointers to overlapping regions of memory but I never said that you should pretend they don't alias each other.
This is true, but references and pointers are not the same thing.
Rust mutable references do not alias each other by definition. And that's why creating such references is UB and leads to unpredictable behavior.
If you want to have multiple mutable pointers to same memory just use pointers, not references.
Anonymous No.106546676
>it's yet another "cniles beclown themselves" thread
lamao, never gets old
Anonymous No.106546717 >>106547509
>>106546060

C:
>Different-types no-aliasing: Always on, unless non-standard compiler flag is used. Linux kernel uses that flag with GCC.
>Universal no-aliasing: Opt-in by using the keyword "restrict". Rarely used. AFAIK, when Rust was created and began seeing usage, which uses this heavily, a number of undiscovered and old bugs related to this were fixed in LLVM.

C++:
>Different-types no-aliasing: Same as for C.
>Universal no-aliasing: Not available, considered too difficult by some AFAIK.

Rust:
>Different-types no-aliasing: Not available.
>Universal no-aliasing: Always on for references, not on for raw pointers.
Anonymous No.106546758
>>106532429
No one ever says this though
Anonymous No.106546794 >>106547041
>>106545656
>>106545923
>>106546307
what a disgusting, anti-human language. big tech pushes all these dumb concepts like "syntax sugar" and "code readability" and then go on to sponsor the most convoluted, dipshit attempt at reinventing the wheel
Anonymous No.106546797
>>106546652
>>106546663
Rust UB == retardation/malicious, got it
Anonymous No.106546813 >>106546847
>>106546232
>https://doc.rust-lang.org/stable/std/collections/struct.LinkedList.html
Oy mate.
https://doc.rust-lang.org/stable/src/alloc/collections/linked_list.rs.html
Now write it efficiently without unsafe.

>https://github.com/Qiskit/rustworkx
Oy mate.
That isn't even a Rust crate, just an internal Rust implementation. Try again.
Anonymous No.106546821
And here comes the drooling retard.
Everyone cheer, it's the cnile!
Anonymous No.106546832 >>106546863 >>106547397 >>106547488
>>106546261
Rust seems to be the odd one out here, being bothersome to implement something as basic as a doubly-linked list in efficiently, being more or less forced to use unsafe.
Anonymous No.106546840
rust is the satire stroustrup interview taken seriously
Anonymous No.106546841 >>106547092
>number of good and novel software written in Rust in the last 10 years:
>0
Empirical evidence is all that matters. Call me back when Rust is production-ready.
Anonymous No.106546847 >>106547228
>>106546813
>Now write it efficiently without unsafe.
linked lists aren't efficient though
>That isn't even a Rust crate, just an internal Rust implementation. Try again.
https://crates.io/crates/rustworkx-core
Try not being a dumb retard.
Anonymous No.106546859
>>106546377
And still a bug, and also implies runtime overhead even when not panicking.
Anonymous No.106546862 >>106546898
>references are not pointer and can't alias
>but we compile references to pointers
Anonymous No.106546863 >>106547248
>>106546832
>bothersome
Doubly linked list implementation is like 30 LoC. Git gud
Anonymous No.106546886 >>106546905 >>106547447
>>106546442
Thank you for confirming. Yes, take your meds and off yourself, low-IQ troll.
Anonymous No.106546898 >>106546933
>>106546862
>references are not pointer
nobody said that.
Anonymous No.106546905 >>106547263
>>106546886
>low-IQ troll.
Said the idiot that pretends that some safe pointer operations aren't safe, because it's not OK?
>>106546459
>>106546402
>>106546222
Anonymous No.106546933 >>106546964
>>106546898
With what's been said in this thread, your as-a-matter-of-fact statements don't mean much.
Anonymous No.106546946
>>106532364 (OP)
Use case for ebussy streams?
Anonymous No.106546964 >>106547014
>>106546933
People told you pointers and references are not the same thing, but that doesn't mean one can't be a specific case of other.
Bools are primitive types, but primitive types are not the same thing as booleans.
References are just very specific kinds of pointers.
Anonymous No.106546965 >>106546980
>>106546493
Please paste that into Miri, the Rust online playground has an option to test with Miri.
Anonymous No.106546980 >>106546998
>>106546965
What for? This is just UB demonstration. Miri will just detect it as well.
Anonymous No.106546998 >>106547008
>>106546980
but there are at least two other UBs before you even get to the aliasing UB.
Anonymous No.106547008
>>106546998
Yeah there is.
Compiling playground v0.0.1 (/playground)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.55s
Running `/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo-miri runner target/miri/x86_64-unknown-linux-gnu/debug/playground`
error: Undefined Behavior: trying to retag from <296> for Unique permission at alloc157[0x0], but that tag only grants SharedReadOnly permission for this location
--> src/main.rs:12:27
|
12 | let target = unsafe { std::mem::transmute::<&u64, &mut [u64; 3]>(&arr[0]) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this error occurs as part of retag at alloc157[0x0..0x18]
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <296> was created by a SharedReadOnly retag at offsets [0x0..0x8]
--> src/main.rs:12:70
|
12 | let target = unsafe { std::mem::transmute::<&u64, &mut [u64; 3]>(&arr[0]) };
| ^^^^^^^
= note: BACKTRACE (of the first span):
= note: inside `main` at src/main.rs:12:27: 12:78

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to 1 previous error
Anonymous No.106547014 >>106547029 >>106547051 >>106547471
>>106546964
And I told you that you can safely have 2 mutable references or pointers to the same heap cells, mutating this cell and it is perfectly safe if it's in the 2 references are in the same thread and if the compiler frontend/backend doesn't pretend they don't alias.
That's a fact, deal with it.
Anonymous No.106547016
>>106546641
>>106546652
Ambiguity and lack of clear and easily distinguishable definitions ruin the day again.

Rust references and raw pointers are both pointer kinds in Rust. Raw pointers are often called pointers in Rust.
Anonymous No.106547029 >>106547052
>>106547014
>you can safely have 2 mutable references to the same heap cells
That's undefined behavior as demonstrated above.
Anonymous No.106547041
>>106546794
I don't those examples have ugly code, honestly. There are far uglier examples in Rust in my opinion.
Anonymous No.106547051
>>106547014
sure, but there are good reasons that have already been stated multiple times in this thread why Rust disallows this.
Anonymous No.106547052 >>106547064 >>106547066 >>106547089
>>106547029
>That's undefined behavior
I don't give a shit about the idiotic semantics of your idiotic language. Hardware pointers and as matter of fact even emulated pointers have a logic of their own and in this logic single threaded mutability is fine.
Anonymous No.106547064 >>106547079
>>106547052
>Hardware pointers
>emulated pointers
lamo
Anonymous No.106547066
>>106547052
this also holds for platonic references to heap cells in the platonic realm
Anonymous No.106547077
Go makes trannies go -ACK
Anonymous No.106547079
>>106547064
You're so thick that I don't know how to talk to you.

captcha: KYS4R
Anonymous No.106547089
>>106547052
Rust is a high level language. The pointer variables do not reflect anything in hardware, they are purely abstract. Compiler is free to express them in any way it wants, as registers, memory locations, indexes or just optimize them away completely.
Also "hardware pointers" is not really a rigid term and might mean a lot of different things. Assembly is not even a typed language so it doesn't have a concept of pointers by itself. They are just another layers of abstraction programmers use to reason about their code.
Anonymous No.106547092 >>106551407
>>106546841
what do you use for 2FA OTP?
Anonymous No.106547094 >>106547265
>>106533059
Given how tedious and awful serialization and deserialization are in C, and how nice it is in rust, I would assume at least some of that space is used to make things actually good. It's also bigger than in Go and C++ because the parsing is all figured out at compile time rather than using runtime reflection and bloated dynamic data structures respectively.
Anonymous No.106547228 >>106547295 >>106547447
>>106546847
>linked lists aren't efficient though
Low-IQ, dumb, moronic, retarded troll, cease your trolling, give an efficient implementation, and off yourself.

>https://crates.io/crates/rustworkx-core
>Try not being a dumb retard.
You didn't even give the right path to the crate on Github.
https://github.com/Qiskit/rustworkx/tree/main/rustworkx-core
And that is not even the actual Rust graph library used internally, it appears to be using petgraph. And petgraph does use unsafe.

Off yourself, dumb, retarded troll.
Anonymous No.106547248 >>106547328 >>106547447 >>106547488
>>106546863
Try writing it without using unsafe.
And explain to me why rustaceans were forced to write a whole book just to explain to people how to write a doubly-linked list in Rust.
https://rust-unofficial.github.io/too-many-lists/
Off yourself, retarded, nitwit troll.
Anonymous No.106547263 >>106547360 >>106547447
>>106546905
Are those your posts? Retarded, idiot, negative-worth troll, off yourself.
Anonymous No.106547265 >>106547347 >>106547357
>>106533073
>>106533091
>>106533351
>>106533576
>>106534021
>>106547094
imagine not double-checking rust "storage" claims on /g/
cargo new serde-sz
cd serde-sz
cargo add serde-json
nvim src/main.rs


use serde_json::Value;

fn main() {
let j = serde_json::json!{{
"code" : 200,
"success": true,
}};
let b = serde_json::to_vec(&j).unwrap();
let Ok(Value::Object(m)) = serde_json::from_slice(&b) else { panic!() };
dbg!(&m["code"]);
}


cargo build --release
% du -sh target/release
20M target/release
% du -sh target/release/serde-sz
516K target/release/serde-sz
Anonymous No.106547295 >>106547377
>>106547228
everything you said is dumb and retarded
Anonymous No.106547324
>>106546145
can you provide a demo of your run-time iterator invalidation checker?
it sounds very interesting and you sound very knowledgeable.
Anonymous No.106547328 >>106547397
>>106547248
>Try writing it without using unsafe.
Why move the goalpost?
Anonymous No.106547347 >>106547577
>>106547265
Did you use derive macros though?
Anonymous No.106547357 >>106547734
>>106547265
NTA, but some people were not happy with Rust serde.
https://soasis.org/posts/a-mirror-for-rust-a-plan-for-generic-compile-time-introspection-in-rust/
Anonymous No.106547360 >>106547425
>>106547263
How much did they hurt you?
Anonymous No.106547377 >>106547447
>>106547295
That is yourself that you are describing, zero-IQ, inept troll. Off yourself.
Anonymous No.106547397 >>106547428 >>106547447
>>106547328
Yet I didn't, zero-IQ, negative-worth troll. >>106546832 . Off yourself.
Anonymous No.106547425 >>106547447 >>106547511
>>106547360
Are you hallucinating? Off yourself, mentally ill, moronic, incompetent troll.
Anonymous No.106547428 >>106547488
>>106547397
You were talking about doubly linked lists being "bothersome to implement" and now you are talking about unsafe. These things are not synonymous, unless you are a complete beginner who doesn't understand how unsafe works.
Anonymous No.106547447 >>106547488
>>106546487
>>106546886
>>106547228
>>106547248
>>106547263
>>106547377
>>106547397
>>106547425
Anonymous No.106547471 >>106547509 >>106547543
>>106547014
Based on what? Pretty sure it's not even kosher in C++ because of aliasing.
Anonymous No.106547488
>>106547428
>>106547447
Both of these posts mention unsafe.
>>106547248
>>106546832
Now off yourself, moronic, idiot troll.
Anonymous No.106547509
>>106547471
>>106546717
Anonymous No.106547511 >>106547530
>>106547425
I see that you are projecting again,.
Anonymous No.106547530 >>106547581
>>106547511
That is yourself you are describing. Now cease your trolling, low-IQ retard, and off yourself.
Anonymous No.106547543 >>106547561
>>106547471
Based on reality you fuckwit.
Anonymous No.106547561 >>106547602
>>106547543
What reality? Your delusional one? Multiple mutable references implies potential data race which implies UB, thus not ok and compiler may apply no aliasing specific optimizations.
Anonymous No.106547577 >>106547823
>>106547347
#[derive(serde::Deserialize, serde::Serialize)]
struct Foo {
a: Option,
b: Option,
c: Option,
d: Vec
}

fn main() {
println!("{}", serde_json::to_string(&serde_json::from_str::("").unwrap()).unwrap());
}

% du -hs .\target\release\
21M .\target\release\
% du -hs .\target\release\serde-sz.exe
160K .\target\release\serde-sz.exe
Anonymous No.106547581 >>106547604 >>106547795
>>106547530
Ask a concurrency expert if you need a mutex when you have 2 pointers to the same object in the same thread.
Anonymous No.106547592
>>106532441
It should be illegal to be this retarded online
Anonymous No.106547602 >>106547606 >>106547759
>>106547561
Data race in a single thread? Sir, this is a no nigger zone.
Anonymous No.106547604 >>106547662
>>106547581
You are confusing me with someone else, zero-IQ, incompetent troll. Now take your meds and off yourself.
Anonymous No.106547606 >>106547662
>>106547602
...yes? Are you retarded?
Anonymous No.106547662 >>106547683 >>106547698 >>106547759
>>106547604
>>106547606
Thank you for confirming how much braindead you are.
Anonymous No.106547683
>>106547662
Yet that is yourself, not me, you are describing. Off yourself, retarded, moronic troll.
Anonymous No.106547698
>>106547662
Single thread doesn't mean anything
Signals
Concurrency

No reason to have multiple mutable references if your software is sequentially working through things anyway.
Anonymous No.106547734 >>106547829
>>106547357
the C committee "muh imposter syndrome" nigger (real one) and his posse of mastoclown trannies (real ones) are not relevant people, nor are their manic fanatic mastoclown circlejerks are relevant in the real world.
Anonymous No.106547759 >>106548245
>>106547602
>>106547662
>what is an interrupt
Anonymous No.106547795 >>106548245
>>106547581
https://docs.rs/tokio/1.47.1/tokio/sync/struct.Mutex.html
Yes. Even in a single threaded executor. Tasks could race without explicit locking, thus why tokio provides sync primitives even for single threaded executors.
Anonymous No.106547823
>>106547577
tbf 10x lies are quite on the low end when it comes to made up rust target sizes and compile times.
usually the made up numbers are 50x-100x.
Anonymous No.106547829 >>106547861 >>106547939
>>106547734
Isn't most of the Rust community and large parts of the C and C++ communities on Mastodon? I don't hang out on Mastodon, though.
Anonymous No.106547861
>>106547829
>Rust community
NTA, but from my experience it's usually Discord or Matrix.
Anonymous No.106547939 >>106548111
>>106547829
Rust community is not a monolith, despite popular /g/eet beliefs.
For the Rust project itself, zulip is where all the "real" chat happens. Otherwise, you don't have to be anywhere.
I personally only use ##rust@libera for lowkey chat, and would never come near Discord/Xitter/Mastoclown/BlueSky/...
Anonymous No.106548111 >>106548249
>>106547939
https://github.com/rust-lang/ lists Mastodon and Bluesky accounts, and no Twitter/X accounts.
Anonymous No.106548245 >>106548288 >>106548605
>>106547759
>what is an interrupt
You're right, interrupts are out of scope and references inside an interrupt routine should be treated specially. In that case yes you would need some protection, but otherwise it is fine.

>>106547795
>Yes. Even in a single threaded executor.
bullshit
>Tasks could race without explicit locking
This can only happen if the taks run on multiple threads.

Do tasks needs synchronization? Sure. But if we're talking about single threaded concurrency, you don't a mutex to make the "synchronization" (state machine-like handling in reality) work.
Anonymous No.106548249 >>106548543
>>106548111
so?
the single person behind these "announcements" accounts made the X account inactive a while ago.
i don't think a single person gives a fuck.
there are rust people on every platform. i don't even have to look to know that rust discourse in e.g. telegram is infinitely bigger than in bluesky.
Anonymous No.106548288 >>106548305 >>106548438 >>106548605
>>106548245
>>Yes. Even in a single threaded executor.
>bullshit
>>Tasks could race without explicit locking
>This can only happen if the taks run on multiple threads.
Preemptive single threaded schedulers exist.
Anonymous No.106548289 >>106548305
stop feeding the llm jeet info. next you're going to explain preemption to "it".
just make fun of it, or leave it alone.
Anonymous No.106548305
>>106548288
>>106548289
prophetic
Anonymous No.106548438 >>106548472 >>106548605 >>106548802 >>106548866
>>106548288
OK, I see that for a preemptive single threaded you have essentially the same problem than with an interrupt routine. But if the scheduler is not preemptive, it is fine.

I admit than I wasn't exactly aware of those issue before though, thanks for that. Although interrupts and preemption (via signals, via interrupts) are definitely not included by what I meant by "single threaded". And those ARE edge cases, if you're honnest.
Anonymous No.106548472 >>106548605 >>106548800 >>106548800
>>106548438
>And those ARE edge cases
This is typical in systems programming.
Anonymous No.106548543 >>106548751
>>106548249
How does the Rust activity in Telegram compare to the Rust activity in Reddit and Hacker News?
Anonymous No.106548602 >>106548959
why are freetards such commies?
Anonymous No.106548605 >>106548840 >>106548996 >>106549018
>>106548245
>>106548288
>>106548438
>>106548472
Jumping into the conversation.

Isn't async/await in Rust, and thus also Tokio, cooperative and not preemptive? Or is it different definitions of cooperative and preemptive in a different context that are being used?
Anonymous No.106548751 >>106548783
>>106548543
why do you care?
if you're Russian or Brazilian in particular, and interested in rust, you're already there.
the world is much bigger than anglophone circlejerk/manufactured hype platforms.
Anonymous No.106548783
>>106548751
Aren't most of the main developers in Rust situated in the USA or Europe, at least judging by Github Insights?
Anonymous No.106548784
>>106532364 (OP)
ebussy streaming on twitch ? Would be funny if 'teens raided him with thugs
Anonymous No.106548800 >>106548834 >>106548840 >>106549080
>>106548472
>>106548472
Even in an OS the majority of the code won't have to deal with mutable shared state between 2 threads, 1 thread and 1 ISR or 2 taks running on a preemptive scheduler.
So yes, it is an edge case in the type system. There is no need to cuck the type system for 99% of the code while the 1% that pose problem can't be dealt with specially. This is complete retardation.
And let's face it, Rust is used more for shit like ripgrep than for embedded OSes and hypervisors.
Anonymous No.106548802 >>106548850
>>106548438
>honnest
ESL?
Anonymous No.106548834
>>106548800
>while the 1% that pose problem can't be dealt with specially.
*can be dealt with specially
with special kinds of references made for dealing with concurrency
Anonymous No.106548840 >>106548996 >>106549018
>>106548800
Why not answer >>106548605 ?

Are we talking preemptive/cooperative at the OS level, or the application or programming language runtime level?

Go is more or less preemptive AFAIK, while Rust's async/await is cooperative.
Anonymous No.106548850 >>106548866
>>106548802
>things that don't matter
autism?
Anonymous No.106548866
>>106548438
>>106548850
Off yourself, zero-IQ, nitwit troll.
Anonymous No.106548959
>>106548602
They aren't. That same picture is a 4chan banner you know.
It is a joke
Anonymous No.106548996
>>106548605
>>106548840
>Isn't async/await in Rust, and thus also Tokio
Dunno about Tokio, but embassy supports preemptive scheduling.
Anonymous No.106549018 >>106549042
>>106548605
I don't know if Tokyo is cooperative, but if it is the anon is even more full of shit than I thought.
>Or is it different definitions of cooperative and preemptive in a different context that are being used?
Relevant question with this lot but no, there is only definition for those words in the context of concurrency.

>>106548840
Are we talking preemptive/cooperative at the OS level, or the application or programming language runtime level?
It's the same. You need timers and interrupts for preemption no matter at what level (OS, user space program), it's native code.
Erlang's preemptive scheduler manages to have userspace preemption without interrupts, by counting the number of bytecode instruction executed. It uses a conditional at each instruction to know if it needs to context switch to another task or not.

Go's preemptive scheduler work by having a thread do a timer with a system call and when it's up, it sends a signal the kill system call to the other threads. The other threads which have each their own scheduler do a context switch in their signal handlers.
see: https://www.sobyte.net/post/2022-01/go-scheduling/
Anonymous No.106549042
>>106549018
*there is only definition for those words
*it sends a signal with the kill system call
Anonymous No.106549080 >>106549129
>>106548800
>Even in an OS the majority of the code won't have to deal with mutable shared state between 2 threads, 1 thread and 1 ISR or 2 taks running on a preemptive scheduler.
As soon as you have async, all the data shared between any two tasks will have to take synchronization into account.
Anonymous No.106549129
>>106549080
Thanks, that's sums it up nicely.
Anonymous No.106549383 >>106549396
>>106532364 (OP)
>glib
RefCell or some type of Rc is required due to Cnility
Anonymous No.106549396 >>106549473
>>106549383
RefCell is not a type of Rc(reference counting).
Anonymous No.106549473
>>106549396
I know it's interior mutability but It's commonly wrapped in an Rc. Dynamic borrow checking sucks but probably can't be helped in the pOOP patterns glib wants
Anonymous No.106549688 >>106549795
>>106532364 (OP)
this syntax is the most pajeet-looking shit I've seen in my life
Anonymous No.106549795
>>106549688
Why?
Anonymous No.106550201 >>106550300 >>106551060
>>106532364 (OP)
Does a grown man really need all these dots?
Anonymous No.106550292
>>106532364 (OP)
>build a community that constantly talks about memory safety
>implying they care about more safe programs
>fall for the rust meme, finally check it out
>to install it you run a bunch of random scripts in the shell
>ok weird but I'm just going to go ahead and learn anyways
>the entire community that talks about memory safety just tells you to install 50000 crates instead of answering your questions

why is the language that always talks about safety so okay with packages from random chinese developers that have very low level access to your system?

something smells glowy about rust. Also it's not fun to write.
Anonymous No.106550300
>>106550201
I use dots too for visible whitespace but they're lighter in my theme.
Anonymous No.106550323 >>106550642
>>106532364 (OP)
Rust is King.
Anonymous No.106550642
>>106550323
Tcl is a lot more vital than Rust.
Anonymous No.106551060
>>106550201
I use the rainbow indent extensions, they're much easier to differentiate, and they highlight the indents that aren't properly formatted.
Anonymous No.106551270
>>106532364 (OP)
Tbh, if you have problems understanding the intricacies of Rust, you can just some AI like ChatGPT or Grok to explain them to you. They're both trained on official docs and can answer any question you have. Example prompt: "Explain Rust's borrow checker to me like I'm 12 years old."
Anonymous No.106551407
>>106547092
>no reply
lol
Anonymous No.106551706
>>106532364 (OP)
>>106532441
he's using glib, so he's refcounting all over the place anyway
Anonymous No.106551722
why do you torture yourself with Rust when C++ exists? or even C (if you are this kind of person).