3 ms·
No, it doesn't work swimmingly. All of those projects have ended up either using void∗ or macros, or both, in order to roll their own generic data structures.
by pcwalton 9y ago
No, it doesn't work swimmingly. All of those projects have ended up either using void∗ or macros, or both, in order to roll their own generic data structures.
> Look at Redis,
https://github.com/antirez/redis/blob/unstable/src/adlist.h https://github.com/antirez/redis/blob/unstable/src/adlist.h — generic doubly-linked list with void∗
https://github.com/antirez/redis/blob/unstable/src/dict.h https://github.com/antirez/redis/blob/unstable/src/dict.h — generic hash table with void∗
> or git
https://github.com/git/git/blob/master/hashmap.h https://github.com/git/git/blob/master/hashmap.h — generic hash table with void∗
https://github.com/git/git/blob/master/list.h https://github.com/git/git/blob/master/list.h — generic doubly linked list implemented with macros
> or postgresql
https://github.com/postgres/postgres/blob/master/src/include/lib/ilist.h https://github.com/postgres/postgres/blob/master/src/include... — generic doubly linked list implemented with macros
https://github.com/postgres/postgres/blob/master/src/include/lib/rbtree.h https://github.com/postgres/postgres/blob/master/src/include... — generic red-black tree with void∗
- KirinDave 9y agoI agree strongly. "It works" is an encoding of, "I can write tests which perform correctly" and not "My code is stable in the face of aggressive input." Go definitely follows along with C in this tradition. It's better than C, because you have slightly more safety interpreting memory as executable and in bounds checking. However, it does very little to stop destructive bugs or let programmers escape copy-paste code hell where regressions keep resurfacing because it's most expedient to copy-paste code.