On one particular project I started by "spamming" relevant interest based forums. Luckily I was a member of said forums for quite a while before I have released my first version. It was about 13 years ago. Strategy had worked and then I got CEO as a partner along with some investment so I no longer had to do it
TLDR but just the heading is already ugly. No single person no matter how nice they're should be able to control our future. Power corrupts, what fucking trust. We are supposed to be democratic society (well looking at what is going on around this is becoming laughable)
I do not have anything resembling problems described. Before I ask AI to create new code (except super trivial things). I first split application into smaller functional modules. I then design structure of the code down to main classes and methods and their interaction. Also try to keep scope small. Then AI just fills out the actual code. I have no problems reviewing it. Sometimes I discover some issues - like using arrays instead of maps leading to performance issues but it is easily spotted.
I have shared mutable state which is available through the whole application lifetime. Having ARC in this situation makes no sense, single mutex should be all I need.
That's also an option available to you: Mutex::new() is const, so there's no trouble putting one in a static variable. If the inner value can't be const-constructed, you'll need a way to prevent access before it's initialized; for that, you can use a OnceLock or just Box::leak() the Mutex once it's constructed and pass around a simple reference.
What would be disadvanatages of this approach? I don't like Arc's myself either, I would like to see what is best alternative for those in multi threaded apps.
Different commenter but yes, that's exactly what they mean.
The main disadvantage is strong coupling. The shared state inside the static makes it more difficult to test your code. There are ways to reduce this coupling, the most obvious being that you push as much logic as possible into functions that accept a reference rather than use your static directly. Then you minimize the size of the code which is difficult to test, and cover it with end to end testing.
The OnceLock does impose 1 atomic operation of overhead, whereas an Arc imposes 2 (in this case, it can be more if weak references are used). However neither are likely to be important when you consider the overhead of the Mutex; the Mutex is likely to involve system calls and so will dominate the overhead. (If there's little to no contention then the Mutex is a lot like an Arc.)
Your alternative would be to use `Box::leak()` as the parent comment describes, which would force you to pass a reference around (resulting in better coupling) and eliminate overhead from OnceLock. However, it's unlikely to result in any material performance benefit, and you could reduce coupling without departing from your current approach, so I don't think either approach is clearly or overwhelmingly better.
If you want to spawn multiple threads, all with access to a mutex, but without putting it behind an Arc, then you can simply spawn all your threads in a std::thread::scope(||{...}). These let you pass references &'scope Mutex<...>
I find Rc or Arc almost never the right tool for a job where I want to "share state" or such
I said "independent to the degree possible", not absolutely.
I do not live in a binary world. I accept things in between.
Being part of group should be voluntary, not forced
What I definitely do not want is my life to be dictated by a few imbeciles at the top who are bought by large corps to pretend to be "by the people for the people".
The solution to that is widespread active low level constant community engagement in policy and monitoring the people you hire to debate policy (politicians) and the various silo's created to enact policy (military, civil service, legal, emergancy response, etc.).
Some people think it sufficient to pay no attention and let things slide indefinitely because "ultimately we can just rise up and shoot the government".
Isn't it expected that in a system that favors individualism over collectivism that a few people will be able to amass disproportionately more wealth and power than everyone else with no incentive or societally enforced responsibility to share that wealth and power, thus creating a society were your life is dictated by a few imbeciles at the top, not who are not bought by large corps, but who own the large corps?
Collectivism has many problems as well including that some are "more equal" and amass the same disproportional wealth (maybe under the cover and not placated but it is still there).
Indeed. It then follows that the optimal arrangement will find a balance, ameliorating the flaws of system each with the strengths of the other.
Several Northern European countries (like the Netherlands, which GP finds congenial) pursue this, though pragmaticism (unlike ideology) never reaches an end-state, and remains a work in progress. The USA, from ~1933 until sometime in the 1970s, operated on this model. It's probably only possible to sustain in high-trust societies.
A city whose citizens mostly drive is less independent than a city whose citizens mostly ride bicycles. Bicycling infrastructure is orders of magnitude cheaper to maintain than the same for heavier, motorized vehicles. It's not just the roadways: you need service stations, tire shops, parking lots and garages. Gasoline engine cars need gasoline distributed to stations all over the place and emissions testing. All of these things take up lots of space because motor vehicles are big.
All that bicycles really need are a (much narrower) right of way and some cheap pavement. Maintenance can be done all at home, even in a small apartment. The apparent independence available to motor vehicle drivers is an illusion afforded by massive private and public investment.
Maybe, but the "loneliness epidemic" articles and frankly, my own experience lead me to believe that independance is overated. Community is not though.
Independent? You say independent, I say parasitic. Just like any ruling class of the Middle East, especially the UAE. They’re not independent, they’re very much dependent on the semi slave labor they manage to exploit. Anything that makes life worth living is the result of collective labor. People coming together and building or learning upon previous knowledge. Hell, even your understanding of yourself comes from the social relationships you form during your formative years. This desire to be what amounts to an outcast is a defect, an abnormality imposed by the mode of production that organizes the world right now.
This sounds like a wise parent explaining some higher truth to a kid. Except that it is not truth but some our of blue baseless conclusion you've managed to somehow extract from my sentence.
Look man I'm just telling you about my own life. I feel more independent when I have a smaller space and less stuff that's easier to account for or move around.
reply