New trends in programming languages
medium.com
New trends in programming languages
1–8 of 8 posts
Re: New trends in programming languages
#2Re: New trends in programming languages
#3Re: New trends in programming languages
#4Re: New trends in programming languages
#5 auto values = new std::unordered_set();
in their C++ benchmark code you already know it's gonna be a good article.Re: New trends in programming languages
#6When you see this line auto values = new std::unordered_set (); in their C++ benchmark code you already know it's gonna be a good article.
template optional minimum_coins2(T target, std::vector denominations) {
std::unordered_set values, newvalues;
values.insert(target);
auto k = 0;
while (values.size() > 0) {
k += 1;
for (auto v : values) {
for (auto d : denominations) {
if (v == d)
return k;
else if (v > d)
newvalues.insert(v - d);
else
continue;
}
}
swap(values, newvalues);
newvalues.clear();
}
return {};
}c++ 180ms, julia 270ms (using a value of 9070)
Re: New trends in programming languages
#7When you see this line auto values = new std::unordered_set (); in their C++ benchmark code you already know it's gonna be a good article.
Re: New trends in programming languages
#8When you see this line auto values = new std::unordered_set (); in their C++ benchmark code you already know it's gonna be a good article.
Sorry, C++ newbie, why is this significant?
All together whoever wrote the code has no idea how to write C++ and was probably just happy that the code didn't crash. (Also this essentially just benchmarks the unordered_map implementation that happens to come with whatever standard library they're using instead of anything intrinsic to the language. How fast unordered_map does certain operations can vary wildly between different implementations, and if you really needed a similar data structure that delivers absolute maximum performance for your use case you would write it yourself.)
Also these "language x is this fast" comparisons are generally useless anyway, if you care about a 5x compute speedup or less you're going to use a native language and fiddle with it until the compiler gives you the binary code you want essentially (which in return means they're all equally fast if you do things correctly), and if you don't care about a 5x speedup you can use whatever language you want, they're all fast enough.
The only "language benchmarks" that are actually useful are ones that compare different coding paradigms, for example using exceptions vs not using exceptions, or inheritance vs function pointers, etc. - but these kinds of things require a fairly good understanding of the language and compiler options, and their conclusion is very often "it depends".