3 ms·
I'm... intimately familiar with generics in Swift. :) Like all systems it has trade-offs, but the decision it makes line up with the decisions you said Go wante
by dbaupp 9y ago
I'm... intimately familiar with generics in Swift. :) Like all systems it has trade-offs, but the decision it makes line up with the decisions you said Go wanted to also make.
In any case, that specific concern doesn't apply to Go, since it doesn't have overloading.
> Repeating that Go ignores "already researched and widely-implemented solutions" is getting old, really
Sure, but that still isn't the point of this discussion: it's not what people should be doing, or the underlying truth, it's what people are doing in practice and they are complaining about the Go team seemingly ignoring the past 40 years of programming language development, not complaining that they're not inventive enough.
- ngrilly 9y agoYou're right about the issue I mentioned which is irrelevant since there is no overloading in Go. Thanks for pointing it out. I didn't know you worked on Rust and now on Swift :-) What strategy does Swift use to compile a generic function or method? Does it generate only one polymorphic version of the code, or multiple specialized versions for each expected parameter types (often called code specialization or monomorphization)?
- dbaupp 9y agoOne polymorphic version, like OCaml or Haskell, not specializing like C++ or Rust. The compiler can and does specialize functions as an optimization, but that's not necessary nor part of the semantic model.
- ngrilly 9y agoI always thought that generating one polymorphic version would be a better fit for Go than generating multiple specialized versions. It's interesting that Swift adopted this approach and confirms what you said earlier about Swift having essentially the same constraints as Go and being a good source of inspiration of Go. What's the status of Swift on Linux, to write web services and connect to databases?
- dbaupp 9y agoThere's lots of testing for Swift on Linux (e.g. every pull request runs tests on macOS and Linux), and Apple recently announced https://github.com/apple/swift-nio https://github.com/apple/swift-nio which seems to have been very well received, e.g. the Vapor framework is completely switching to it for Vapor 3.
- ngrilly 9y agoThanks for the link. Does Swift provide something similar to goroutines?