3 ms·
Julia also has reference semantics for everything. That said, it turns out that if you make it idiomatic to create immutable structs, the difference between ref
by adgjlsfhk1 4y ago
Julia also has reference semantics for everything. That said, it turns out that if you make it idiomatic to create immutable structs, the difference between reference semantics and copy semantics disappears, and lets the compiler pick the faster one (which fixes a common performance bug in C++ where users end up copying a ton of data around by accidentally copying a bunch of data)
- IshKebab 4y agoYeah I always thought that "make everything immutable!" was partly - maybe even mostly - a workaround for the fact that it's so hard to copy data in most languages. I agree C++ makes it too easy to accidentally copy data, but at least you can copy data!
- adgjlsfhk1 4y agobut the only reason you want to copy data is that it makes manual memory management easier. otherwise paying a reference is almost always cheaper.