Biggest mental shift while switching from classic to scientific programming: explicit “for” loops are now extremely expensive. Instead, you express as much as you can by chaining hyperoptimized lower-level “for” loop primitives, eg matrix multiplies. Fun & new way of thinking.

May 13, 2022 · 6:59 PM UTC

18
18
2
288
Replying to @gdb
And if you started with scientific it’s the total opposite. For me loops feel haram
Replying to @gdb
Python libraries for DS is a mix of imperative and declarative programming with C bindings
Replying to @gdb
Don't you just mean writing code that runs fast on a GPU vs a CPU.
Replying to @gdb
This has at times felt like an antipattern when the data has semantics lost in translation from a loop to various tensor operations. Named tensors can help but feels like still more room for improvement to have clear intent and performance
1
Replying to @gdb
Fortuitous initials @gdb! Can you be more specific? Talking about loops in a high-level language vs some sort of dsl that bottoms out in vectorized routines, possibly on non-CPU hardware?
Replying to @gdb
Many years ago, I did exactly that in the code written for my master thesis. All existing „for“ loops were converted to matrix operations. The program ended up being 4 to 10 times faster. I never thought of it as something special until I read your tweet :)
1
Replying to @gdb
Psst... Do...While.
Replying to @gdb
Yep, rewriting client UI <> server backend frameworks to work this way end-to-end (fullstack GPU dataframes) is the basic future graphistry has been living for the last 5+ years. Community effort to make that practical - @RAPIDSai , @ApacheArrow , etc :)
1
Replying to @gdb
Not Loop but loop.