Thread 105934718 - /g/ [Archived: 188 hours ago]

Anonymous
7/17/2025, 11:51:49 AM No.105934718
1752745657
1752745657
md5: df9bb6a158f227304846ad6acb1beace๐Ÿ”
Is functional programming the best way to write GUI code?
Replies: >>105935369 >>105935674 >>105935840 >>105936015 >>105936142 >>105936383 >>105936764 >>105938349 >>105938382 >>105938578 >>105938908 >>105939892 >>105940330 >>105940533 >>105941803 >>105942017 >>105943548 >>105943907 >>105946634
Anonymous
7/17/2025, 12:04:43 PM No.105934787
Why are people so afraid of OOP? I understand it makes some things harder to read/follow in the moment, but if there is any complexity in the system functional programming seems like a fucking nightmare desu.
Replies: >>105940316 >>105940707 >>105944966
Anonymous
7/17/2025, 12:42:49 PM No.105935039
Functional programming has always seemed silly to me.

Like I can understand engineers and scientists using it for numerical analysis of equations but for literally anything else it seems like pure cargo cult cope. They should know by now that engineers and scientists don't give a shit about their matlab/julia/spark scripts or whatever after the svg has been exported and put in the latex doxument. And no, software developers are NOT engineers. They do not have the same training, and they cannot deliver the safety and secure the evidence of safety like engineers can.
Replies: >>105935689
Anonymous
7/17/2025, 1:31:34 PM No.105935369
>>105934718 (OP)
Functional programming is probably the worst way to do GUI
GUIs are by definition stateful unless you're doing something super basic like a dialog box. Funtional programming tries to be as stateless as possible
Anonymous
7/17/2025, 2:14:47 PM No.105935674
>>105934718 (OP)
functional programming is the worst way to make a program with complex state like GUI or game.
Anonymous
7/17/2025, 2:16:46 PM No.105935689
>>105935039
you don't seem to know what it is
Anonymous
7/17/2025, 2:33:55 PM No.105935840
>>105934718 (OP)
I just do react way, don't care about the pseudo science like functional, procedural, oop, data driven, etc
Anonymous
7/17/2025, 2:57:13 PM No.105936015
IMG_0147
IMG_0147
md5: c1d74c8c7da0b3f41825aa6753676d80๐Ÿ”
>>105934718 (OP)
>+= in initializer
kiiiiinoooooo
Anonymous
7/17/2025, 3:16:19 PM No.105936142
>>105934718 (OP)
That is not functional it's more like OOP + declarative.
Anonymous
7/17/2025, 3:45:22 PM No.105936383
>>105934718 (OP)
>import scala.swing._
>compared to import java.swing.*;
>mfw scalaniggers use _ instead of *
Replies: >>105939937
Anonymous
7/17/2025, 4:30:53 PM No.105936764
>>105934718 (OP)
Depends on the approach.
Functional programming makes most sense for immediate mode gui.
OOP makes most sense for retained mode gui.
Replies: >>105938711
Anonymous
7/17/2025, 6:31:19 PM No.105937891
This is not OOP, it's composition using objects. OOP is about sending messages between objects
Anonymous
7/17/2025, 7:16:55 PM No.105938349
>>105934718 (OP)
dynamic languages are the best
Anonymous
7/17/2025, 7:20:06 PM No.105938382
>>105934718 (OP)
ahhh, functional programming. where people would rather write a 150 line ungodly mess with 3 layers of recursion that performs like shit instead of solving the problem by writing 5 lines and introducing a tiny bit of state. all the faggots glazing fp right now who never even used it will be in for a rude awakening when it becomes mainstream.
Replies: >>105938464
Anonymous
7/17/2025, 7:27:11 PM No.105938464
>>105938382
But it's OOP where you write 1500 lines of ungodly mess with 3 layers of SingletonBeanFactory. FP generally gives you very succinct, but difficult and abstract code.
Replies: >>105938566 >>105938590 >>105938709
Anonymous
7/17/2025, 7:36:08 PM No.105938566
>>105938464
FP performs horribly on any program which makes generous use of states.
One bright exception is the more pragmatic OCaml which also supports loops, and Scala.
Replies: >>105938647
Anonymous
7/17/2025, 7:37:31 PM No.105938578
>>105934718 (OP)
>nested 5 deep
NGMI
Anonymous
7/17/2025, 7:38:54 PM No.105938590
>>105938464

OOP can be as simple as you want it to be. Don't blame the overengineering overabstracting faggots for making it worse with their conventions. You can make OOP very tight and simple while still being intuitive.
Replies: >>105938647
Anonymous
7/17/2025, 7:44:36 PM No.105938647
maxresdefault
maxresdefault
md5: ed8c7048cc8ca360eaab312a4ccc349a๐Ÿ”
>>105938566
Pure FP sure. But you don't even have to go full OOP like OCaml, Rust is a good example on how to use FP style in performant way. It was inspired by OCaml too.

>>105938590
Of course you can do it sanely. I'm just saying that the implication that FP typically produces more code than OOP is just plainly wrong, it's the other way around. OOP comes with unavoidable declarations that generally take quite a lot of LoC, while FP can often be reduced to absurdly small sizes.


Pro tip: the current meta is to use OOP to structure your data/responsibility and FP to express how to manipulate that data.
Replies: >>105938664 >>105940701
Anonymous
7/17/2025, 7:46:12 PM No.105938664
>>105938647
Sure, but Rust has that disgusting borrow checker
Replies: >>105938669
Anonymous
7/17/2025, 7:46:43 PM No.105938669
>>105938664
That's completely irrelevant to the conversation.
Anonymous
7/17/2025, 7:48:18 PM No.105938692
How similar is reactive programming to functional? Everything frontend seems reactive these days
Replies: >>105938731
Anonymous
7/17/2025, 7:50:13 PM No.105938709
>>105938464
i never said i'm an OOP fag. procedural code is the only one that makes sense
Anonymous
7/17/2025, 7:50:18 PM No.105938711
>>105936764
fucking this.

Functional programming is just for prototying and thats it.
Anonymous
7/17/2025, 7:51:43 PM No.105938731
>>105938692
It's not very similar to actually writing functional programming, but it can(but doesn't have to) be built on top of functional concepts like React hooks.
Anonymous
7/17/2025, 7:54:51 PM No.105938762
what no one seems to understand that both fp languages and rust are trying to solve the same problems that arise from shared mutable state.

fp tries to solve it by eliminating the mutable part while rust tries to solve it by eliminating the shared part. in the meantime OOP is playing in the puddle next to them like a child giggling and declaring they already solved the problem by smearing state all over your screen.

also rust is procedural not fp
Replies: >>105938840
Anonymous
7/17/2025, 8:02:42 PM No.105938840
>>105938762
rust is also gay and unneeded
Replies: >>105938858 >>105938864
Anonymous
7/17/2025, 8:04:20 PM No.105938858
>>105938840
let me guess, OOP nigger...
Anonymous
7/17/2025, 8:04:36 PM No.105938864
>>105938840
People have been begging for a C++ alternative for decades.
Replies: >>105938880 >>105941488
Anonymous
7/17/2025, 8:05:06 PM No.105938871
Dont care about OOP. Tired of hearing about Rust. Shitty thing
Anonymous
7/17/2025, 8:05:37 PM No.105938880
1tgd4r
1tgd4r
md5: 35eaf64c3c43c591ec392b82fb7e57be๐Ÿ”
>>105938864
>People

Retards and trannies aren't people.
Replies: >>105938905
Anonymous
7/17/2025, 8:07:24 PM No.105938893
>I am tired of hearing about Rust
>so I am going to incite a discussion about Rust
Anonymous
7/17/2025, 8:08:35 PM No.105938905
>>105938880
These "retards" design C++.
Replies: >>105940299
Anonymous
7/17/2025, 8:08:40 PM No.105938908
>>105934718 (OP)
Functional programming is not well suited for GUI code because in GUIs, things are SUPPOSED to have side effects. However, for small, local calculations, functional is okay.
Replies: >>105939892 >>105940098
Anonymous
7/17/2025, 9:37:18 PM No.105939892
>>105934718 (OP)
>functional programming
>picture of scala
nice b8
>>105938908
>Functional programming is not well suited for GUI code
Is that why most ui toolkits are declarative or provide a declarative flavor?
>things are SUPPOSED to have side effects.
>le functional means NO side effects maymay xdd
Face the truth: imperative & OO bloat is THE problem with GUIs with all the nulls, side effect poop flinging, and inheritance bloat
Replies: >>105939959
Anonymous
7/17/2025, 9:41:16 PM No.105939937
>>105936383
Scala would be so much better outside the JVM
>no slow comp time
>no leaky abstractions
>no half-baked/humiliation ecosystem using java-focused libs
Anonymous
7/17/2025, 9:42:57 PM No.105939959
>>105939892
If something has side effects it is not a function โ€” it is a method or a procedure.

Procedural programming will just keep winning forever, sorry hipsterโ€“paradigm fags.
Replies: >>105940042 >>105940139
Anonymous
7/17/2025, 9:51:29 PM No.105940042
>>105939959
So this is your brain without moan ads.
Replies: >>105940083
Anonymous
7/17/2025, 9:55:01 PM No.105940083
>>105940042
All the most important software in the world is procedural โ€” with perhaps a pseudo objectโ€“oriented system boltedโ€“on.
Anonymous
7/17/2025, 9:56:32 PM No.105940098
>>105938908
>QML
>Glade
>flutter
>jetpack compose
>most famous web UI frameworks
Imperative bros, it's ove-NullRef[Segmentation fault]
Anonymous
7/17/2025, 9:58:11 PM No.105940117
1748725680835832
1748725680835832
md5: 6f8347ef8f5643ace51801e550190771๐Ÿ”
>whole thread is retards not knowing the difference between functional programming and pure functions
every time i come back to this board it reminds me how retarded the average programmer actually is
Replies: >>105940232 >>105940250
Anonymous
7/17/2025, 10:01:00 PM No.105940139
>>105939959
>If something has side effects it is not a function
i'm not a mathematician, i don't use their intentionally gimped definitions of shit. go back to the blackboard, grandpa.
Replies: >>105940263
Anonymous
7/17/2025, 10:10:45 PM No.105940232
>>105940117
I gave up 4 years ago when some mouthbreather trying to prove a point with a shitty script that piped see into itself 5 time. When you have like three ways of doing the same task better and one of them is using the -e builtin avilable on pretty much every system from the last 18 years still operating today.
Replies: >>105940272
Anonymous
7/17/2025, 10:13:08 PM No.105940250
>>105940117
I know the difference and I for one say it is bullshit. Play semantics all you want โ€” you're still wrong.
Anonymous
7/17/2025, 10:14:09 PM No.105940263
>>105940139
Sorry but you're using procedures โ€” you're a procedural programmer kiddo.
Anonymous
7/17/2025, 10:14:57 PM No.105940272
>>105940232
tried* to prove a point with a sed script. I'm half assing even redacting a paragraph.
Anonymous
7/17/2025, 10:17:32 PM No.105940299
>>105938905
Indeed, look at how poorly C++ is designed.
Replies: >>105940643
Anonymous
7/17/2025, 10:19:37 PM No.105940316
>>105934787
We aren't afraid of it. We just realize it is almost always a waste of time.
Replies: >>105940594
Anonymous
7/17/2025, 10:20:47 PM No.105940330
>>105934718 (OP)
Is there anything like this for C# and for C++?
Replies: >>105940691
Anonymous
7/17/2025, 10:36:22 PM No.105940533
>>105934718 (OP)
imgui is the best way if you dont care about muh styling
Anonymous
7/17/2025, 10:42:34 PM No.105940594
>>105940316
This. ~90% of the benefits of OO can be had with simple structs.
Anonymous
7/17/2025, 10:48:22 PM No.105940643
>>105940299
And now you understand why Rust is needed and why people wanted an alternative.
Replies: >>105940860
Anonymous
7/17/2025, 10:51:48 PM No.105940691
>>105940330
Please don't use C# for product UI unless you have an internal tool or windows-only view
The best they have is blazor on MAUI aka .net on WASM on webview on .net on glue to host OS
Anything can break if use MAUI alone so forget about MVU solutions.
Anonymous
7/17/2025, 10:53:27 PM No.105940701
>>105938647
Rust's FP abstractions are only fast because the Rust compiler knows how to convert those abstractions back to imperative style code. Stray outside the abstractions Rust provides and see how well it performs.
Replies: >>105941209
Anonymous
7/17/2025, 10:54:13 PM No.105940707
>>105934787
The only benefit to I see from OOP is containerizing thing. I do this with structs and c files making OOP obsolete.
Replies: >>105940879
Anonymous
7/17/2025, 11:08:01 PM No.105940860
>>105940643
Isn't Rust failing in every area that it claims to be made for? Last I checked it was pretty much dead in embedded with only a few niche products using it because no one wanted to rewrite decades of C libraries/drivers/etc etc in Rust and Rust compiler only really supporting x86 and arm as first class targets. Linux kernel devs had a meltdown with only one or two trannies willing to use it who have now quit meaning no one is really using Rust anymore. MS is using it in some areas for windows but none of the big, commonly used API's are being changed over from C to Rust and modern Windows is basically dead because of a bunch of buggy ai slop being pushed and with shit like the UI being re-written in fucking javascript of all things. It is doa in game dev because it turns out games require a lot of shared state. The biggest compiler re-written in Go because it turns out shared state and circular datastructures are useful in compilers, something Rust can't do without jumping through a bunch of hoops. The only area Rust has seemed to taken off in is in making Rest API's / crud apps and it isn't really Rust but Rust + 3rd party runtime which bastardises the language and makes it something akin to typed Javascript. It's a far cry from being a C++ replacement, more like a Java/C# replacement/Typescript replacement. It seems Rust looks like it's a good idea on paper but as soon as it's used for anything remotely complex with any sort of complex state, the language is unable to make any sort headway into that area of programming.
Replies: >>105941209 >>105941223
Anonymous
7/17/2025, 11:10:51 PM No.105940879
>>105940707
>structs and c files
That's basically OOP
Replies: >>105940933
Anonymous
7/17/2025, 11:16:04 PM No.105940933
>>105940879
What is your definition of OOP? What are the main characteristics of it in your opinion?
Replies: >>105941244 >>105942039 >>105943337
Anonymous
7/17/2025, 11:46:47 PM No.105941209
>>105940701
That's literally why I said
>Rust is a good example on how to use FP style in performant way

>>105940860
>Isn't Rust failing in every area that it claims to be made for?
It's used in every relevant OS, even in Android. A lot of large companies use it in production. It seems pretty successful for me.

>Last I checked it was pretty much dead in embedded
Embassy seemed to be quite a hot topic recently.

>Rust compiler only really supporting x86 and arm as first class targets
Rust supports much more than this. x86 and arm are first tier meaning that it gets automatically tested on that hardware. Compilers like GCC are not automatically tested on any other architectures as well, so their support is more like Rust's tier 3 support. Even Linux doesn't get automatically tested on any hardware upstream and it's downstream responsibility to detect and report issues.

>Linux kernel devs had a meltdown with only one or two trannies willing to use it who have now quit meaning no one is really using Rust anymore
The drama only involved Hector and some C boomer. Both of them quit in result. Hector was never essential to Rust for Linux, he was just working on the GPU driver for some apple shit and joined Linux after R4L was already in works.

>MS is using it in some areas for windows but none of the big, commonly used API's are being changed over from C to Rust
C ABI is the standard way of doing FFI. No matter if you write in C, C++ or Rust, you are going to use C ABI for FFI because this is the only stable ABI of the three and it's simple. Even if you are not using C directly. This has very little to do with practical differences in language, it's a common convention. These Windows APIs probably do not use C but C++ or some other Microsoft invention behind the FFI interface.
Anonymous
7/17/2025, 11:47:48 PM No.105941223
>>105940860


>It is doa in game dev because it turns out games require a lot of shared state
This is not a problem in practice. It's trivial to share state in Rust. Lifetimes even ensure that you are not causing UB by doing so.
The reason why Rust is not good for gamedev is because it heavily favors waterfall approach. It is not a flexible language that you can quickly prototype shit in, And quick prototyping and iteration is essential for gamedev.
Rust never claimed to be designed with gamedev in mind. If you want a language made for gamedev, look at Lua, Squirrel, GDScript, etc. They are very different from systems programming languages like Rust or C++.

>The biggest compiler re-written in Go because it turns out shared state and circular datastructures are useful in compilers
Since when GCC has been rewritten in Go? What are you even talking about.

>something Rust can't do without jumping through a bunch of hoops
It is easy to write shared state and circular data structures in Rust. You do that in the same way you would do in C or C++.

>The only area Rust has seemed to taken off in is in making Rest API's / crud apps and it isn't really Rust but Rust + 3rd party runtime which bastardises
I don't recall any popular Rust based project related to Rest APIs. CLI tools, encoders, compression libraries, desktop software seems to be more popular.

>It's a far cry from being a C++ replacement, more like a Java/C# replacement/Typescript replacement
Rust is a systems programming language. It's not a replacement for a managed languages like Java/C#/Typescript.

>It seems Rust looks like it's a good idea on paper but as soon as it's used for anything remotely complex with any sort of complex state, the language is unable to make any sort headway into that area of programming.
I wrote quite some programs in Rust, including a game engine and never had any problems with complex state.

What exact problems did you actually had with complex state in your program?
Replies: >>105941341
Anonymous
7/17/2025, 11:49:24 PM No.105941244
>>105940933
Objects that can be instantiated that have methods.
Anonymous
7/18/2025, 12:01:50 AM No.105941341
>>105941223
Concurrently working on arrays where you have to give each thread a section of each array to work on without incurring additional copies. As far as I can tell even something as simple as doing vector math without copies requires jumping through a bunch of hoops. In C you can just spin up a thread and have it work on the section you hand it while other threads work on sections and have it updated in place. In Rust you have to prove those threads can't overlap thus requiring extra copies or moving parts of the array in and out of the original data structure/doing the work sequentially/using a third party library to do it for you. I've had people throw a bunch of examples at me how to do it on here, calling me retarded etc like you're insinuating and Rust, every single time tells me it's breaking borrowing/ownership rules. It always needs a copy or some sort of wrapping in a smart pointer which means I might as well use Go, have a better garbage collector than basic bitch reference counting and get access to green threads.
Replies: >>105941412
Anonymous
7/18/2025, 12:10:30 AM No.105941412
1750103340403
1750103340403
md5: 85e0cb1be8bba89ac81514654e5190bc๐Ÿ”
>>105941341
>Concurrently working on arrays where you have to give each thread a section of each array to work on without incurring additional copies
Pic related.

>As far as I can tell even something as simple as doing vector math without copies requires jumping through a bunch of hoops
impl Vector {
fn add_assign(&mut self, other: &Vector) {
self.x += other.x;
self.y += other.y;
self.z += other.z;
}
}


>In C you can just spin up a thread and have it work on the section you hand it while other threads work on sections and have it updated in place. In Rust you have to prove those threads can't overlap thus requiring extra copies or moving parts of the array in and out of the original data structure/doing the work sequentially/using a third party library to do it for you.
Pic related.

>t always needs a copy or some sort of wrapping in a smart pointer which means I might as well use Go, have a better garbage collector than basic bitch reference counting and get access to green threads.
Pic related.
Replies: >>105941428 >>105941524
Anonymous
7/18/2025, 12:12:22 AM No.105941428
>>105941412
You're not doing any work.
Replies: >>105941450
Anonymous
7/18/2025, 12:15:02 AM No.105941450
>>105941428
Each threads fills it's own section of array with it's id. They all work in parallel and do not take any extra copies or smart pointers or anything. It is sound and supported by std to just split a mutable slice into multiple, non-overlapping slices and it doesn't take any extra runtime checks to do so.
Replies: >>105941489
Anonymous
7/18/2025, 12:20:24 AM No.105941488
pb
pb
md5: a42369cece4389ad4aece6fccc76cd18๐Ÿ”
>>105938864
Skill issue. That is how we got Java and trash tier coders everywhere.
Anonymous
7/18/2025, 12:20:25 AM No.105941489
>>105941450
ok but you're still not doing any work here on the underlying array. Also .fill() says it clones the passed element which isn't a copy? Also why would I want the ID of the thread here? I want to edit the underlying array.
Replies: >>105941519
Anonymous
7/18/2025, 12:24:43 AM No.105941519
nextline
nextline
md5: aeec50e90722ade0178539172dcc627d๐Ÿ”
>>105941489
You are kind of dense, aren't you?

>but you're still not doing any work here on the underlying array
slice::fill is the work here. It fills chunk, which is a part of buffer. The buffer is the underlying array and it gets changed, look at the print.

>Also .fill() says it clones the passed element which isn't a copy?
It's a memset.

>Also why would I want the ID of the thread here? I want to edit the underlying array.
It's called an example. By each thread filling their own chunk of underlying array, this example shows that it is possible to "give each thread a section of each array to work on without incurring additional copies", which is what you asked about.


Jfk, how did you even found your way to /g/
Replies: >>105941561 >>105941587
Anonymous
7/18/2025, 12:25:09 AM No.105941524
pepe-nervous
pepe-nervous
md5: e4d323c3a2ee87b8152c936848d99101๐Ÿ”
>>105941412
WTF, one second to compile a dozen lines of code that is not even optimized? Holy shit, rust compilation is slow AF!
Replies: >>105941534
Anonymous
7/18/2025, 12:26:22 AM No.105941534
>>105941524
It's being compiled inside the browser though. I don't have the code anymore to test it natively though.
Replies: >>105941675
Anonymous
7/18/2025, 12:29:16 AM No.105941561
>>105941519
>Jfk
I mean jfc. It's too late for me, I need sleep.
Anonymous
7/18/2025, 12:33:14 AM No.105941587
Screenshot from 2025-07-17 23-32-46
Screenshot from 2025-07-17 23-32-46
md5: 37ddf0a10ed3d6618b204431a206f395๐Ÿ”
>>105941519
Fill
>Fill self by cloning value.
I guess the documentation is wrong?
Replies: >>105941665
Anonymous
7/18/2025, 12:38:20 AM No.105941635
I got into functional programming cause of how delightful it was to do frontend with Elm which is essentially GUI.
MVU/TEA is great, I've ported the pattern to TypeScript in case I'm forced to use it. Moved on to PureScript and then to Haskell. Miso is looking fine these days.
Anonymous
7/18/2025, 12:41:35 AM No.105941665
>>105941587
We had this very conversation already.
Do you understand how memset works?

>pic
You are mutating the same vector(data.a) which you are using to calculate maffs in other threads. None of this is atomic. This is an undefined behavior and Rust caught it.
Even if you use atomics, the output is going to be nondeterministic, you have to rethink your algorithm. You probably want to do a copy or precalculate maffs before mutating the array.
Replies: >>105941673
Anonymous
7/18/2025, 12:42:25 AM No.105941673
>>105941665
Ok so Rust does need to do extra copies. That was my original point. Thank you for admitting it and we are now on the same page.
Replies: >>105941693
Anonymous
7/18/2025, 12:42:50 AM No.105941675
>>105941534
IIRC, that's not compiling inside a browser. That's compiling inside a VM that's accessible from a web app.
Anonymous
7/18/2025, 12:44:27 AM No.105941693
tired-confused
tired-confused
md5: 259b82b3e5e4b0f651779d045813a009๐Ÿ”
>>105941673
Holy retard
Replies: >>105941719
Anonymous
7/18/2025, 12:48:27 AM No.105941719
Screenshot from 2025-07-17 23-47-29
Screenshot from 2025-07-17 23-47-29
md5: 363506dde76e7637d870ba8a9c3ce540๐Ÿ”
>>105941693
You keep moving the goal posts. Do this concurrently, in place or fuck off and admit you're a ingenious rust shill who has an agenda. This is basically your code and it doesn't work lol.
Replies: >>105941761 >>105941826
Anonymous
7/18/2025, 12:50:42 AM No.105941735
>I am going to shoot straight down
>*warning, feet is in the way*
>shitty gun, I do not have to move my feet to shoot my other guns
Replies: >>105941773
Anonymous
7/18/2025, 12:53:25 AM No.105941761
>>105941719
You can do maffs on the chunk, but you can't do it on the data you took the chunks off of.
Anonymous
7/18/2025, 12:54:21 AM No.105941773
>>105941735
>Does not address the point
>Doesn't post code
>Resorts to story telling and ad homiem to score points
I can't wait to see your game engine.
Anonymous
7/18/2025, 12:59:13 AM No.105941803
biden huh
biden huh
md5: 9e055e30233764c25f3ce2ba15d0e2ce๐Ÿ”
>>105934718 (OP)
>scala.swing
Anonymous
7/18/2025, 1:04:04 AM No.105941826
>>105941719
struct Data {
a: Vec<usize>,
b: Vec<usize>,
c: Vec<usize>,
}

fn maffs(a: &[usize], b: &[usize], idx: usize) -> usize {
return a[idx] * b[idx];
}

fn update(data: &mut Data) {
use std::thread;

thread::scope(|s| {
let &mut Data { ref b, ref c, ref mut a } = data;

for (id, chunk) in a.chunks_mut(4).enumerate() {
s.spawn(move || {
chunk.fill(maffs(b, c, id));
});
}
})
}
Replies: >>105941880
Anonymous
7/18/2025, 1:10:13 AM No.105941880
>>105941826
Wow you're the first person to give me a working answer after months of going tit for tat with Rust faggots over this and them giving me non working example after non working example. Thank you.
Replies: >>105941931
Anonymous
7/18/2025, 1:15:15 AM No.105941931
>>105941880
Well, probably because your initial code was straight up, unsalvageable undefined behavior in any language. You can't read and write to the same memory location from different threads and not have at least non determinism or UB. It wasn't even matter of splitting the array, your first thread was writing to the same exact location from which threads 2-4 were reading from(data.a[1..4]).
Replies: >>105942044
Anonymous
7/18/2025, 1:25:59 AM No.105942017
>>105934718 (OP)
Take a look at xmonad/haskell and get back to us.
https://github.com/xmonad/xmonad/tree/master/src/XMonad
Anonymous
7/18/2025, 1:29:14 AM No.105942039
>>105940933
OOP is when class invariants are the primary method of proving semantic correctness.
Anonymous
7/18/2025, 1:30:12 AM No.105942044
>>105941931
No the code wouldn't compile because data being moved. The compiler was telling me the problem was the same when I removed access to the array we are mutating. The &mut data {ref...} solves the problem but yes the code was bad. I meant to pass another index for A to ensure unique access to the element.
Anonymous
7/18/2025, 4:55:52 AM No.105943337
>>105940933
I go by Alan Kay's definition
Anonymous
7/18/2025, 5:35:33 AM No.105943548
>>105934718 (OP)
Im not a programmer. What's the difference? I languages have functions.
Replies: >>105943570
Anonymous
7/18/2025, 5:41:08 AM No.105943570
>>105943548
all
Anonymous
7/18/2025, 6:40:36 AM No.105943907
>>105934718 (OP)
I always thought the old school VB was the best for UI. Object based, but not OOP.
Anonymous
7/18/2025, 10:05:48 AM No.105944966
>>105934787
Inheritance is why OOP is bad
Anonymous
7/18/2025, 3:24:57 PM No.105946634
>>105934718 (OP)
Yes.