12 ms·
So, typed pointers with an analog of the option type. Thank you. Could we say that Swift or even SML with typed refs has similar safety and zero-cost abstracti
by lngnmn 10y ago
So, typed pointers with an analog of the option type. Thank you.
Could we say that Swift or even SML with typed refs has similar safety and zero-cost abstractions?
- steveklabnik 10y agoWhile they may have some features that are zero-cost, it's not a defining feature of either language, and so they don't take it as far as Rust does. This was only one example, there are many more that those languages do not do, for various reasons.
- masklinn 10y agoSimilar safety, yes absolutely. Zero-cost abstraction not that I know of although I believe Swift has pretty good support for them and the long-term goal is to be in the same space as Rust (https://news.ycombinator.com/item?id=13077178 https://news.ycombinator.com/item?id=13077178)
- kibwen 10y agoDetermining whether an abstraction is zero-cost or not is often buried deep in a language's implementation, so you'd need an expert to determine whether a given abstraction in Swift or SML qualifies. But regarding closures specifically, I can say that it's very unlikely that either Swift or SML have a zero-cost implementation, since having stack-allocated closures is an immense and deliberate decision in language design (AFAIK only C++ and Rust do this).