I want off Mr. Golang's Wild Ride

IGotD- nise at nise.com
Sat Feb 29 15:48:40 UTC 2020


On Saturday, 29 February 2020 at 04:54:22 UTC, H. S. Teoh wrote:
>
> The most glaring point to me is Phobos' ubiquitous use of 
> `string` everywhere for filenames. The fact that strings are 
> assumed to be valid UTF-8 will almost certainly land us in the 
> same complaints as the author had about Go's handling of 
> pathnames.
>
> Changing that would be a major code breaker, though. So I'm not 
> sure if we should even attempt to!
>
>
> T

In Rust String::from does checks for valid UTF-8 every time, the 
question if the compiler can optimize away the check if it is 
known to come from a correct source.

I rather have a special constructor or method for creating a 
string from an unknown source that isn't necessarily proven to be 
correct UTF-8. I don't think that D should add a check for every 
constructed string at this point.

Also, if the OS service API is done correctly, it should do the 
check so that is it a valid path/filename.

Rust has done mistake with the naming, str and string are too 
close and can be confused.

The article is kind annoying because it is just about Go=great 
evil, Rust=god sent. Also Rust is just as strict when it comes to 
formatting as Go. If you depart from the standard code formatting 
without issuing #[allow(bad_style)] or 
#[allow(nonstandard_style)], the rust compiler will be 
complaining a lot. Cargo is just as annoying and will complain as 
well.



More information about the Digitalmars-d mailing list