3 ms·
> 6 different string types have fun living your life pretending all strings are of the same type. spoiler alert: it's the wrong kind of fun. it's a bit easier
by baq 4y ago
> 6 different string types
have fun living your life pretending all strings are of the same type. spoiler alert: it's the wrong kind of fun. it's a bit easier if you're from a native English speaking country, but only until you get blown up by utf-8 (if you're lucky) in production.
- deleted 4y ago[deleted]
- petmon 4y agoIt's common in other programming languages for string literals to have type string. It's weird and confusing that they do not in both Rust and in C++.
- baq 4y agoIt might be acceptable in higher level languages where some things will simply break in corner cases, at which point the developer will just say 'don't do that' and all is fine. If you're aiming at a true low-level bare-metal-capable syscall-winapi-native-speaker language, this is not an option.
- ModernMech 4y agoIt’s weird and confusing, but also performant. Remember Rust is first and foremost a systems language. You can get a 10x speed boost by using the right string (str vs string) in certain circumstances.
- UncleMeat 4y agoA fun example (https://www.youtube.com/watch?v=-7ebQqzGRKE https://www.youtube.com/watch?v=-7ebQqzGRKE) of the opposite happening, where C++'s silently different handling of various sorts of strings causes a bug.