Thread overview | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 28, 2020 I want off Mr. Golang's Wild Ride | ||||
---|---|---|---|---|
| ||||
https://fasterthanli.me/blog/2020/i-want-off-mr-golangs-wild-ride/ This is a very worthwhile read. There's a lot for us to learn here. |
February 28, 2020 Re: I want off Mr. Golang's Wild Ride | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Fri, Feb 28, 2020 at 02:50:05PM -0800, Walter Bright via Digitalmars-d wrote: > https://fasterthanli.me/blog/2020/i-want-off-mr-golangs-wild-ride/ > > This is a very worthwhile read. There's a lot for us to learn here. 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 -- The fact that anyone still uses AOL shows that even the presence of options doesn't stop some people from picking the pessimal one. - Mike Ellis |
February 28, 2020 Re: I want off Mr. Golang's Wild Ride | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On 2/28/2020 8:54 PM, 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!
This is an interesting problem. I don't know about Rust, but in D a string's contents are not guaranteed to contain valid UTF-8. For the string algorithms I've worked on, I always made them to be tolerant of bad UTF, for the simple reason that bad UTF is everywhere and having the program aggressively halt on it is overkill. The only time validity is checked is when decoding is attempted, or *cough* autodecode *cough* is running, which I'd circumvent.
So I expect we are in good shape there.
Things we must specifically review, however, are:
1. the way stat is dealt with
2. the way file extensions are determined
3. the \ vs /
and more generally, follow the principles outlined in the article.
|
February 29, 2020 Re: I want off Mr. Golang's Wild Ride | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Am 29.02.2020 um 06:50 schrieb Walter Bright: > On 2/28/2020 8:54 PM, 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! > > This is an interesting problem. I don't know about Rust, but in D a string's contents are not guaranteed to contain valid UTF-8. For the string algorithms I've worked on, I always made them to be tolerant of bad UTF, for the simple reason that bad UTF is everywhere and having the program aggressively halt on it is overkill. The only time validity is checked is when decoding is attempted, or *cough* autodecode *cough* is running, which I'd circumvent. > > So I expect we are in good shape there. > > Things we must specifically review, however, are: > > 1. the way stat is dealt with > > 2. the way file extensions are determined > > 3. the \ vs / > > and more generally, follow the principles outlined in the article. This is why there are UnixPath, WindowsPath and InetPath types defined in vibe.d (with NativePath being an alias to WindowsPath or PosixPath). Typing everything as `string` is a recipe for disaster, unless the library semantics happen to exactly match the handled path type. https://vibed.org/api/vibe.core.path/ I'm still not happy with the way absolute paths are handled in terms of path segments in the current design, I just haven't found a way to improve it without breaking existing code in strange ways. (OT: Can you please quickly check your inbox/spam folder? I've send a mail a few days ago, as well as a copy today, regarding code.dlang.org) |
February 29, 2020 Re: I want off Mr. Golang's Wild Ride | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Friday, 28 February 2020 at 22:50:05 UTC, Walter Bright wrote:
> https://fasterthanli.me/blog/2020/i-want-off-mr-golangs-wild-ride/
>
> This is a very worthwhile read. There's a lot for us to learn here.
I tried Go a while back, but when I found that it enforces K&R style to the point of issuing errors if I used Allman-style curly braces, I just lost interest.
Yeah, it doesn't take much. :)
|
February 29, 2020 Re: I want off Mr. Golang's Wild Ride | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ron Tarrant | On Saturday, 29 February 2020 at 08:56:36 UTC, Ron Tarrant wrote:
> On Friday, 28 February 2020 at 22:50:05 UTC, Walter Bright wrote:
>> https://fasterthanli.me/blog/2020/i-want-off-mr-golangs-wild-ride/
>>
>> This is a very worthwhile read. There's a lot for us to learn here.
>
> I tried Go a while back, but when I found that it enforces K&R style to the point of issuing errors if I used Allman-style curly braces, I just lost interest.
>
> Yeah, it doesn't take much. :)
Funny, I read the spec, when I realized that I wasn't able to use Allman, I instantly ditched GO, didn't even try Hello World to this day.
I thought I was alone.
|
February 29, 2020 Re: I want off Mr. Golang's Wild Ride | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ron Tarrant | On Saturday, 29 February 2020 at 08:56:36 UTC, Ron Tarrant wrote:
> I tried Go a while back, but when I found that it enforces K&R style to the point of issuing errors if I used Allman-style curly braces, I just lost interest.
>
> Yeah, it doesn't take much. :)
Same :) I don't want to live in the Go team dystopia.
|
February 29, 2020 Re: I want off Mr. Golang's Wild Ride | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ron Tarrant | On Saturday, 29 February 2020 at 08:56:36 UTC, Ron Tarrant wrote:
> On Friday, 28 February 2020 at 22:50:05 UTC, Walter Bright wrote:
>> https://fasterthanli.me/blog/2020/i-want-off-mr-golangs-wild-ride/
>>
>> This is a very worthwhile read. There's a lot for us to learn here.
>
> I tried Go a while back, but when I found that it enforces K&R style to the point of issuing errors if I used Allman-style curly braces, I just lost interest.
Even I totally prefer K&R style, on the other hand forcing one style in a language is a mistake for me.
Matheus.
|
February 29, 2020 Re: I want off Mr. Golang's Wild Ride | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ron Tarrant | On Sat, Feb 29, 2020 at 08:56:36AM +0000, Ron Tarrant via Digitalmars-d wrote: [...] > I tried Go a while back, but when I found that it enforces K&R style to the point of issuing errors if I used Allman-style curly braces, I just lost interest. > > Yeah, it doesn't take much. :) For me, the fact the Go didn't (and still doesn't) have generics is a showstopper for me. I just can't imagine writing / maintaining code of any non-trivial size without generics of *some* sort. I'm the kinda guy who's into heavy meta-programming, so having no generics whatsoever is just ... unpalatable. With D, though, I'm in metaprogramming heaven with templates, static if/foreach, CTFE, and string mixins. :-P T -- Almost all proofs have bugs, but almost all theorems are true. -- Paul Pedersen |
February 29, 2020 Re: I want off Mr. Golang's Wild Ride | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | 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.
|
Copyright © 1999-2021 by the D Language Foundation