5 ms·
My broad feelings on many of the issues in Rust, including what's presented here, is that they come from starting with a C-like language as a base. The memory s
by LiamPowell 2y ago
My broad feelings on many of the issues in Rust, including what's presented here, is that they come from starting with a C-like language as a base. The memory safety and thread safety features in Rust are very impressive, but many other things feel like they're lacking and non-safety features that were added later feel tacked on rather than being a core part of the language.
I feel that if Rust had started with a language like Ada and applied their innovations there then we would have ended up with a much nicer result.
- orf 2y ago“Don’t let perfect be the enemy of good” - how much of Rust’s success comes from the fact that it started from a C-like base? Doing it differently might end up with a better result from a purist viewpoint, but I’d wager that adoption would have been far worse.
- LiamPowell 2y agoProbably true, although I wonder how much comes from acting like C semantically and how much comes from looking like C. If Rust had taken Ada and made it look like C then would it still be so popular? My guess is that it would be since there's already a steep learning curve for a C developer to pick up Rust. For a developer who's willing to go through all that I don't think a few more new concepts would be a major issue.
- estebank 2y agoOr it could have killed it on the vine because the syntax was too esoteric and would have pushed the target demographic away before they even tried it. It's hard to test the counter factual in this case. A common topic of conversation in the rust project is the concept of "weirdness budget": the idea that you can only be so different from what your expected userbase already knows before you become too hard to learn. I don't think you could introduce the borrow checker on a language like Erlang if you're aiming at systems programming. But now you could make a language that is slightly more weird (introducing other features) than Rust when targeting existing Rust programmers.
- tialaramex 2y ago> starting with a C-like language as a base Which C-like language do you believe was the base of Rust? If you're judging because the syntax looks like a semi-colon language that's just a thin disguise, to make it easier to onboard people from those languages.
- deleted 2y ago[deleted]
- LiamPowell 2y agoNot a specific C-like language, but that family of languages in general and the design decisions from them: A number is just a number even if two numbers represent completely incompatible things. If one integer represents a chmod value and one represents a number of files then you can add them together and the compiler will do nothing to stop you even though adding the two is always nonsensical. There's ways around this by creating your own types, but it's not a trivial process. In Ada I can just declare two different numeric types with identical ranges (type A is range 1..200) and the two will be incompatible. Somewhat related to the above, all array indexes are just numbers. In Ada we can define a type and then use that type as an index of an array type, so if a value is the index type then it must be a valid array index. In Rust if I declare an array as having 5 elements then pass it to a function where I try to access element 6 then nothing will try raise an error at compile time. Continuing on from the last point, arrays are only indexed by numbers rather than any discrete type. In Ada and enumeration is a valid type to use as an array index, or a range from 5 to 15, or -123 to 7. I'm sure this is something you can do with a generic in Rust, but it's going to be more clunky than having native language support. Structs are just basic collections of fields. In Ada we have discriminated records that allow for some struct fields which can only be set at instantiation to control things like the number of elements in an another field which is an array. An example of where this could be used is in a ring buffer which is fully contained within a simple struct without the need for extra memory allocation. (I'm aware this conflicts with the other examples about arrays, in short there's a second type of array declaration with a variable subrange as an index). Maybe you can do this with generics in Rust, but it's not as clean, especially if you want to, for example, add a procedure to the ring buffer that takes another ring buffer as a parameter. These are just off the top of my head as someone who's only briefly looked at Rust, I'm sure there's many more examples. The exact syntax might not match C, but many of the concepts come directly for C and derivatives. The Ada examples I've given exist in other languages too in various forms, I just happen to be an Ada dev so I know exactly how they work there.
- rcxdude 2y agoRust started with ocaml as a base, then evolved in a more C-like direction later on, mainly as a familiarity with the target programmers thing. It wasn't originally envisioned as the systems language that it became, it was much more high level, with a planned GC and everything, then the lifetimes stuff got developed and the contributers at the time pushed it into more and more control in the hands of the programmer.