3 ms·
One could approach it the other way. Once more projects adopt all kinds of wrapper functions and types, the deficiency of Go will become a more widespread knowl
by neonsunset 2y ago
One could approach it the other way. Once more projects adopt all kinds of wrapper functions and types, the deficiency of Go will become a more widespread knowledge as compiler will get progressively less able to cope with added abstractions.
Hopefully it will put the common fallacy of "Go or Rust" to rest as the weight class and capabilities are on opposite ends of spectrum, with much closer comparison being "Rust or C# or Swift or Kotlin" if one looks for a Rust alternative that makes a tradeoff of not forcing many small decision to reduce decision fatigue by conceding to a reasonable extent certain areas Rust excels at.
In any case, for its touted simplicity Go sure doesn't look like a simple and straightforward to follow language anymore.
The 3-step approach to iteration is also well solved[0] in C#, and works even in rather complex cases like `File.ReadLines(...)` where the line iterator internally handles IO, file handle acquisition and disposal. Just `foreach (var msg in File.ReadLines("messages.jsonl"))` and you won't be able to make a footgun out of it.
This also applies to the usage chained with filter/map/etc.
var messages = File
.ReadLines("messages.jsonl")
.Select(line => JsonSerializer.Deserialize<Message>(line))
.ToArray();
[0]: https://sharplab.io/#v2:EYLgtghglgdgPgAQEwEYCwAoBAGABAlAOgEkB5Abkx3yIBlYBHSrPAwgFQFMAPAF0IBSAZwD2MZpgBmIgE6cIAYwAWuABQA3CDNxhOQoRADmnXLFwAxKABtOmXPdyEASvIAm9GHtUAiXfqN6hABWojBW3gCUdg6EAMqcNgq8qlawJgC8AHy4wmLxMlAQqQBenDKEACJ6ZYUlnAA8ALJ6BsaZKWlRGA49uAD8fbi8SjIiAO64nhMAotwKnAAOvFBiPuYiAK4wrricYEsAnripnoRnkRFdAN7R9gQAnKp+rZyEAIIbw7IRzAC+mJg5ApZDtmv5jKoCHgPl8ZAAaGh4Lh8H5AA= https://sharplab.io/#v2:EYLgtghglgdgPgAQEwEYCwAoBAGABAlAOgEk... note .GetEnumerator() and .Dispose() calls