Re:C Template Library
by ummonk on Wednesday December 30, 2020 @03:03AM
(#25579616)
I recall a few years back doing something like this implementing a binary heap just as a hobby project (https://github.com/Equationist/ctl/blob/master/pqueue.h). I was curious to see how unoptimized it was vis a vis the STL, and ran compiled equivalent test code for both my priority queue and the STL's C++ implementation, with just integers. I was kind of shocked to find that my implementation was like 30% faster when both were compiled at -O3 levels. Seeing this backport I guess there isn't anything fancy in the STL implementations, so it's less surprising that my naive implementation could be just as fast (or happen to be faster).
[ Parent
| on HN ]
There's this theory that humans are antennas, and that we pick up "wavelengths from above" to build and create the world we live in. Not only did we decide on the same project name and idea, but we also used the same pre-processor hacks. How surreal.
As for your pqueue implementation, the efficacy of an optimizing compiler lies in the inherent complexity of the language. I can imagine the optimization backend for gcc is simpler (and more effective) than g++, but I am not an expert on compiler internals.
Its more likely that humans are redundant. That is, it is probable in a field of millions that two people come up with the same idea and implementation. I think the birthday paradox is a similar corollary on a smaller scale.
These kinds of macro hacks are pretty widespread, aren't they? To me, klib and its khash hash table is the most well-known implementation, see: https://github.com/attractivechaos/klib
And I've written similar things myself (hash table and vectors).
Re:C Template Library
by pwdisswordfish5 on Wednesday December 30, 2020 @05:36AM
(#25580522)
gcc and g++ use the same backend.
Where have you heard that theory? I've wondered about it myself, but other than some songwriter-specific conversation, I'm not sure I'm familiar with other people talking about it, and I'd like to be.
I'm not sure where I heard it, but if you are interested in an article:
https://www.sciencedaily.com/releases/2014/01/140116085105.h...
Re:C Template Library
by joshuaissac on Wednesday December 30, 2020 @09:21AM
(#25581892)
It sounds somewhat similar to Sheldrake's morphic resonance ideas.
In other words, it's 100% BS; in Sheldrake's case, wholly contradicted by his own examples.
FreePascal has a lot of containers, perhaps more than the STL, but they all suck
I wanted a good hash map, so I spend a lot of time comparing them. There are like 10 separate map implementation in FreePascal, but they are all slower than C++'s std::unordered_map.
Then I compared another dozen of libraries, and found the fastest one that is like 50% faster than std::unordered_map. But it was a rather straight forward implementation of non-linear open addressing.