Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Go is similar to Swift when it comes to mandatory costly abstractions.

It’s only Rust (or C++, but unsafe) that have mostly zero-cost abstractions.



Swift, Rust, and C++ all share the same underlying techniques for implementing zero-cost abstrations (primarily, fully-specialized generics). The distinction in Swift's case is that generics can also be executed without specialization (which is what allows generic methods to be called over a stable ABI boundary).

Swift and Rust also allow their protocols to be erased and dispatched dynamically (dyn in Rust, any in Swift). But in both languages that's more of a "when you need it" thing, generics are the preferred tool.


To an approximation, but stdlib and libraries will have a bias. In practice, abstractions in Rust and C++ more commonly are actually zero-cost than in Go or Swift.

This is not a bad thing, I was just pointing out that Go doesn't have a performance advantage over Swift.


Swift have them too now (non-Copyable types).


> It’s only Rust (or C++, but unsafe) that have mostly zero-cost abstractions.

This just isn't true. It's good marketing hype for Rust, but any language with an optimizing compiler (JIT or AOT) has plenty of "zero-cost abstractions."




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: