12 ms·
AMA I am the speaker.
by acehreli 4y ago
AMA I am the speaker.
- toxik 4y agoDid Rust eat your (the D community’s) lunch?
- acehreli 4y agoIt is definitely chewing on it. :) D's advantage over Rust is its familiar syntax and semantics. C, C++, Java, C#, Python, etc. programmers feel at home once they learn some differences. I heard others say "D is what C++ should have been" and "Compiled Python". I did use Rust for a brief period in a project where the experienced Rust programmer among us was throwing '&' characters here and there to make the code compile, seemingly randomly in many cases. Personally, I remember fighting with impedance issues with the many different string types of Rust. All of this spells a steeper learning curve to me. I think D is familiar to programmers of many other languages.
- primeblue 4y ago
- glandium 4y agoThe inconvenient truth about strings is that strings are hard, and even Rust doesn't have enough string types.
- WalterBright 4y agoD doesn't actually have string types, either, what it does have is `string` is just an alias for: const(char)[] meaning you can treat it like any other array.
- tialaramex 4y agoWhile researching this comment I read some of the D library documentation and found what I think is probably a docbug at this URL: https://dlang.org/phobos/std_utf.html#.byUTF https://dlang.org/phobos/std_utf.html#.byUTF "Throws: UTFException if invalid UTF sequence and useReplacementDchar is set to UseReplacementDchar.yes" My guess is that this is a mistake and should instead say UseReplacementDchar.no since it makes sense to throw an exception if you can't use U+FFFD here, rather than do both. Anyway, in my view this is bad the same way the Billion Dollar Mistake is bad, and Rust made the right choice here. Arrays of stuff are great, but they aren't strings. Having to sprinkle "or maybe not" cases all over these libraries because of course these might not really be strings, results in exception fatigue from your developers, which in turn results in lower quality software and more effort for the conscientious developers who stick it out. D's strings are less stupid than C's (and thus some of the C++ strings) but they're still just arrays which are maybe but maybe not actually text.
- acehreli 4y agoD's string is not text by itself because it is an array of UTF-8 code units. However, we have this infamous feature called auto-decoding in the standard library that presents strings as unicode code points. On the other hand, D's dstrings are more like text because they are not only UTF-32 but also random-accessible code points. (D does not address multiple representations of graphemes at language level. For example, at language level, ğ is different from "g and combining breve" but there are std.uni and std.utf modules that help.)
- tialaramex 4y ago> D's string is not text by itself because it is an array of UTF-8 code units. Bytes. It's an array of bytes. D's char type isn't actually restricted to UTF-8 code units, char x = '\xFF'; works just fine even though that's not UTF-8.
- acehreli 4y agoI see what you mean but array of bytes is something else in D: byte[].
- Kranar 4y ago> Personally, I remember fighting with impedance issues with the many different string types of Rust. It's because Rust gives very low-level control over strings. If what you want is a string the same way as they work in other languages, including D, then use String. If you want very fine control over memory allocation or want the string to be fixed length, then you use a type that guarantees those properties. String will work with anything, at the cost of having little control over its allocation or representation.