Re:Fish (shell) porting to Rust from C++
by zozbot234 on Tuesday January 31, 2023 @12:07AM
(#34591421)
> Being allowed to mutate an integer (or object) through two different pointers on the same thread is perfectly safe
Not safe in the presence of variant records (i.e. enums in Rust), since one pointer might be used to derive a pointer to a field of one variant, and the object might concurrently be switched to a different variant. This is why Cell<> only relies on explicit get and set methods in the general case, where the entire object gets replaced. It's a well-known problem in temporal safety.
Re:Fish (shell) porting to Rust from C++
by nyanpasu64 on Tuesday January 31, 2023 @04:21AM
(#34593061)
I find that Rust prefers to prevent programmers from committing undefined behavior, rather than giving them the tools required to achieve tasks, when these requirements come in conflict (unsafe code is built to allow implementing general functionality with unchecked code, but is more difficult to write without UB than the equivalent operations in safe Java or unsafe C++, partly because mutating a & or aliasing a &mut is instant UB)
You have a very odd definition of a general purpose language. All the functional ones are out, because immutability doesn’t let you mutate through any pointer.
Re:Fish (shell) porting to Rust from C++
by nyanpasu64 on Tuesday January 31, 2023 @04:23AM
(#34593075)
In my observations, immutability-focused functional languages are generally either non-Turing-complete and built as configuration/declarative languages, or find niche usage and do not replace JS/C++/Java/C# for mainstream programmers building a spreadsheet or word processor (and aren't built for low-level programmers to replace C++ for a browser engine or video game or non-allocating real-time audio engine).
And on a more personal level, I dislike the Rust community (and language, eg. for loops depend on trait resolution)'s heavy use of functional, generic, and higher-order function abstractions (rather than explicit imperative code amenable to sequential reasoning). I feel heavy use of generics is confusing in a language used to teach programming to students (and I think usefully learning mainstream programming revolves around algorithmic reasoning from the level of memory and bytes through structured programming, rather than pure functions and iterator combinators).