Re:What Learning APL Taught Me About Python
by kwertzzz on Thursday August 17, 2023 @04:22AM
(#37158698)
Interestingly most (if not all) python examples also work in julia.
Instead of using sum one can also use count, which might be more readable:
julia> count(age > 17 for age in ages)
Or even shorter:
julia> count(ages .> 17)
Under the hood many of the functions are implemented using the reduce function (similar to / in APL):
julia> reduce(+,ages .> 17)
I think many languages in data science have been influenced by APL. But sometimes this influence come from an intermediate language like matlab.
Re:What Learning APL Taught Me About Python
by leephillips on Thursday August 17, 2023 @12:41PM
(#37164406)
Yes. One of the “repercussions” of the author’s experience with APL might have led to him recoiling from the verbosity of his Python examples and exploring languages, like Julia, that can get closer to the APL spirit.
Your rewritten Python and JS, by showing the operation as length instead of sum, and making a shorter filtered list, hide the connection even further instead of helping to reveal and clarify it.
> "which I feel is more readable (but less efficient) than the APL inspired approach"
I know how to read it, but just look at:
what's readable about so much repetition, what's readable bout having to spot the single character plural change in the middle of 8 short words? that's more symbols than the APL one has, the language people reject because of the heavy use of symbols(!). Why does the [] indicate loopy-listy code but so does 'for'? In PowerShell arrays have a property .Count to use instead of Length - what's readable about counting the number of ages by indirectly looking at the length of something? Is this "it's readable because I'm familiar with it" rather than "because it's objectively readable"?