Then again, maybe even that is wrong! "Notation as a tool for thought" and all that. Maybe "dimension-munging" in APL really is the best way to do these things, once you really understand it.
For example, I just cut-and-pasted the author's own cri de coeur into Claude: https://claude.ai/share/1d750315-bffa-434b-a7e8-fb4d739ac89a Presumably at least one of the vectorized versions it replied with will work, although none is identical to the author's version.
When this cycle ends, high-level programs and functions will be as incomprehensible to most mainstream developers as assembly is today. Today's specs are tomorrow's programs.
Not a bad thing, really. And overdue, as the article makes all too clear. But the transition will be a dizzying one, with plenty of collateral disruption along the way.
I don’t use numpy often enough - but this explains the many WTF moments why it’s so annoying to get numpy pieces to work together.
https://news.ycombinator.com/item?id=44072775
https://news.ycombinator.com/item?id=44063553
NumPy definitely has some rough edges, I sympathize with the frustrations for sure.
Mathematical operations aren't obliged to respect the Zen of Python, but I like the thought that we could make it so that most have an obvious expression.
Also I both understand the need for declaring the matrices up front and think it's a bit of a shame that it is not seamless.
Here are some (ill-advised?) alternatives:
X, Y, Z = dp.Slots()
with dp.Slot() as X:
...
import dp.Slot as new
X = new['i','j'] = ...
X = dp['i','j'] = ...
I like your alternatives! I agree that having to write
X = dp.Slot()
before assigning to X is unfortunate. I settled on the current syntax mostly just because I thought it was the choice that made it most "obvious" what was happening under the hood. If you really want to, you could use the walrus operator and write (X := dp.Slot())['i','j'] = ...
but this cure seems worse than the disease...Actually, doing something like
X = new['i','j'] = ...
could simplify the implementation. Currently, a Slot has to act both like an Array and a Slot, which is slightly awkward. If new is a special object, it could just return an Array, which would be a bit nicer.
the__alchemist•1h ago