News for hackers. Stuff that matters.
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).
Re:C Template Library by glouwbug on Wednesday December 30, 2020 @03:35AM (#25579800)
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.

Re:C Template Library by eezurr on Wednesday December 30, 2020 @10:29AM (#25582462)
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.

https://en.wikipedia.org/wiki/Birthday_problem

Re:C Template Library by kzrdude on Wednesday December 30, 2020 @08:38AM (#25581549)
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.
Re:C Template Library by wwweston on Wednesday December 30, 2020 @04:44AM (#25580170)
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.
Re:C Template Library by glouwbug on Wednesday December 30, 2020 @04:57AM (#25580265)
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.
Re:C Template Library by ncmncm on Wednesday December 30, 2020 @02:05PM (#25584827)
In other words, it's 100% BS; in Sheldrake's case, wholly contradicted by his own examples.
Re:C Template Library by benibela on Wednesday December 30, 2020 @05:32PM (#25587013)
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.