https://www.arraycast.com/episodes/episode111-ideal-array-la...
User-Extensible Rank Polymorphism is just beautiful with the broadcast dot syntax. I don't think any other language has this clean and flexible implementation.
Others -- GPU programing, parallelism, etc. are pretty good with Julia. Real shame it hasn't taken off.
https://juliahub.com/industries/case-studies
Many languages could dream to have even a third of such high profile case studies.
I like to play with it, but just it.
Just to be clear, I guess that Julia's broadcast (dot) syntax is an implementation of "User-Extensible Rank Polymorphism"; is that right? Or does Julia's dot syntax include more than UERP?
> IMO this is what makes something an array language.
Great to hear. So what is it?
schema do
input do
array :regions do
float :tax_rate
array :offices do
float :col_adjustment
array :employees do
float :salary
float :rating
end
end
end
end
trait :high_performer, input.regions.offices.employees.rating > 4.5
value :bonus do
on high_performer, input.regions.offices.employees.salary * 0.25
base input.regions.offices.employees.salary * 0.10
end
value :final_pay,
(input.regions.offices.employees.salary + bonus * input.regions.offices.col_adjustment) *
(1 - input.regions.tax_rate)
end
result = schema.from(nested_data)[:final_pay]
# => [[[91_000, 63_700], [58_500]], [[71_225]]]
If i'm reading the syntax correctly, this would translate in kdb/q to a raze (flatten) on the 3 dimensions (regions, offices, employees). Probably more likely to be expressed as a converge but in either case, the calculations here are not possible in a rank polymorphic way.
This is from a Ruby DSL I'm working on (Kumi). Probably the broadcasting semantics are very different from traditional rank operators in q/APL?
Edit: I realized that I missed the input structure:
Region 0: Office 0 has 2 employees, Office 1 has 1 employee
Region 1: Office 0 has 1 employee
Example 1: A function that can take as input a 4x2x8 matrix or a 3x7 matrix.
Example 2: A function that can take as input a 4x2x8 matrix and a 3x7 matrix and output a third matrix.
If rank polymorphism results in accepting both 4x2x8 and 3x7, then that means the function was a function on elements to begin with. Which is possible, but not the most interesting application of rank polymorphism.
Thanks, this is what I was ineloquently attempting to describe with "A function that can take as input a 4x2x8 matrix or a 3x7 matrix."
which shows that this feature request is complete jibberish
There are other cases like adding vectors to matrices and so on, but in the end this logic is defined in some custom add operator overload on a class or object in the language.
(I had no idea what it meant either until i searched for examples..)
> Numpy also needs to be paired with a JIT compiler to make python a real array language
See https://github.com/llvm/llvm-project/blob/main/flang/docs/Ar....
So "rank polymorphism" means being able to write expressions that work correctly regardless of how many dims the arrays involved have.
For example, in numpy you can write a function that handles both lists and matrices automatically, by taking advantage of broadcasting. (The J language takes this idea a lot further -- numpy is a fairly minimal implementation of the idea.)
⊢×0≠∧˝˘∧⌜∧˝ # Marshall & Dzaima (tacit!)
(≠⥊∧´)˘{×(⌾⍉∧)0≠} # Dzaima & Rampoina
{×(∧˝˘∧≢⥊∧˝)0≠} # Dzaima
Call me old fashioned and stuck in C style syntax but I can't imagine anyone describing this as beautiful art.The double-struck characters have disappeared from the second and third lines creating a fun puzzle. Original post https://www.ashermancinelli.com/csblog/2022-5-2-BQN-reflecti... has the answers.
Think about using matrix to describe geometric transformations instead of using standard functions.
[ cos(θ) -sin(θ) 0 0 ]
[ sin(θ) cos(θ) 0 0 ]
[ 0 0 1 0 ]
[ 0 0 0 1 ]
He created it intending to be +1 of APL. Accidentally came up with BQN instead of BQM. Sat with that for 1hr, really liked the name, then realized that it should be BQM which he hated, so he stuck with BQN.
That said, it's and incredibly designed language. I honestly have never read any language (especially not designed by a single person) with the level of creative thought as he put into BQN. Some really incredible insights and deep understanding. It's amazing reading his posts / documentation about it. The focus on ergonomics, brand new constructs and the consistency/coherence of how all of his decisions fit together is really impressive.
And a comfortable APL is clearly an oxymoron.
It can be faster than Fortran based library that is still being used by Matlab, Rust and Julia [1].
It will be interesting to compare Mojo moblas BLAS library with GLAS library performance in D.
[1] Numeric age for D: Mir GLAS is faster than OpenBLAS and Eigen (2016):
http://blog.mir.dlang.io/glas/benchmark/openblas/2016/09/23/...
Taking examples I am familiar w/, it is key that you can add a scalar 1 to a rank 2 array in numpy/matllab without having to explicitly create a rank 2 array of 1s, and numpy somehow generalizes that (broadcasting). I understand other array programming languages have more advanced/generic versions of broadcasting, but I am not super familiar w/ them