I am continually impressed by the ability of LLMs to take trivial ideas and turn them into lengthy and obtuse blog posts with unnecessary analogies.
swiftcoder 59 minutes ago [-]
Honestly, this just looks like one of those lingo-heavy-but-surface-level blog posts that used to make functional programming spaces so insufferable to everyone on the outside
mahboi 24 minutes ago [-]
These things are so divorced from the reality of programming, even when they involve actual code instead of fancy lingo. Like in Scala, not a pure functional language, tutorials used to find the most convoluted higher-order functional way to do simple things.
bioneuralnet 1 hours ago [-]
Yet another encroachment on traditionally human activity.
moritzwarhier 1 hours ago [-]
I am the
Option<Walrus>
ninalanyon 28 minutes ago [-]
I've done this for years. Not every time of course but where it makes the code easier to understand and maintain.
Speed was almost never the reason.
alterom 8 minutes ago [-]
I take it you never rewrote a Matlab for loop as a vector/matrix op for insane speedups then :)
wallstop 44 minutes ago [-]
What is missing here is any benchmarks backing up this argument for code structure.
The same technique is applied as an optimization, when deemed safe, in all current gen c compilers (gcc, llvm, etc).
I'm very confused why neither measurements nor references to when this is done automatically in most modern languages is included in the article.
cogman10 20 minutes ago [-]
At least in JVM land, it's pretty easy to thwart that optimization. Particularly if the condition is on a mutable yet unchanged in the loop value.
For example:
var map = new HashMap<String, String>();
map.put("foo", "bar");
for (var i : items) {
if ("bar".equals(map.get("foo")) {
doStuff(i);
}
}
Even though `map` isn't mutated, it's hard enough for the JVM to detect and the underlying `get` functions are complex enough that it'll run the `get("foo")` every time, which can be quiet expensive.
aappleby 21 minutes ago [-]
I have always phrased this as "Never do one of something".
OutOfHere 7 minutes ago [-]
I like it, but to do fizzbuzz in this way, you'd have to separate what's inside the loop into a reused function.
alterom 8 minutes ago [-]
TL;DR in one sentence:
"the loop runs without a branch, and is a candidate for vectorization".
That's it, that's the article. This matters a lot in huge-scale / scientific computing / HPF, where if you can express something as an operation on vectors on matrices, you win big (those ops parallelize well, can be run on GPUs, clusters, what have you).
apefulsin 27 minutes ago [-]
[dead]
Rendered at 21:18:51 GMT+0000 (Coordinated Universal Time) with Vercel.
Speed was almost never the reason.
Of note, as of C#9 (and maybe prior), the dotnet runtime does this automatically whenever it is deemed safe. https://devblogs.microsoft.com/dotnet/performance-improvemen...
The same technique is applied as an optimization, when deemed safe, in all current gen c compilers (gcc, llvm, etc).
I'm very confused why neither measurements nor references to when this is done automatically in most modern languages is included in the article.
For example:
Even though `map` isn't mutated, it's hard enough for the JVM to detect and the underlying `get` functions are complex enough that it'll run the `get("foo")` every time, which can be quiet expensive."the loop runs without a branch, and is a candidate for vectorization".
That's it, that's the article. This matters a lot in huge-scale / scientific computing / HPF, where if you can express something as an operation on vectors on matrices, you win big (those ops parallelize well, can be run on GPUs, clusters, what have you).