Re:The ups and downs of porting 50k lines of C++ to Go (2015)
by nemo1618 on Thursday March 14, 2019 @12:45AM
(#19386589)
Deleting from a slice is ugly and awkward because it's slow. Go, like C, confronts you with the real cost of what you want to achieve. A builtin like 'delete(a, i)' looks like an O(1) operation, when in reality it's O(n).
[ Parent
| on HN ]
Re:The ups and downs of porting 50k lines of C++ to Go (2015)
by edflsafoiewq on Thursday March 14, 2019 @06:14AM
(#19387853)
In what way does delete(a, i) look like an O(1) operation? It looks like a function call. You can never just look at a function call and see its complexity.
You make it sound like deleting an element being ugly is a design choice, but it can't be a choice since there is no alternative. Swap-and-pop is O(1), but it's ugly too.
Re:The ups and downs of porting 50k lines of C++ to Go (2015)
by apta on Thursday March 14, 2019 @04:38PM
(#19393436)
> A builtin like 'delete(a, i)'
Ironically, "delete" is built in in golang (how else do you delete an entry from a map)? Yet it says nothing about its cost.
Re:The ups and downs of porting 50k lines of C++ to Go (2015)
by kasey_junk on Thursday March 14, 2019 @08:22AM
(#19388547)
Yet copy is available.