Idea Julia Lite or 'Juliette'?

With Julia, you have to learn one rule about vectorization: if you want elementwise/broadcasting operations, use a dot. This applies to every function, from + to exp to less-algebraic functions like occursin or first.

It’s true that this is different from e.g. Matlab, and new languages take time getting used to. But it’s not a rule that is hard to explain, I think, whereas adding lots of exceptions to a rule makes things harder to learn in the long run.

That’s the main reason why we removed array + scalar. It was initially removed on algebraic grounds (https://github.com/JuliaLang/julia/pull/5810), then that change was reverted because it was too inconvenient (https://github.com/JuliaLang/julia/pull/7226) for + to be an exception to all the other vectorized operations that we had at the time, and then finally it was removed again (https://github.com/JuliaLang/julia/pull/22932) when all of the other implicit vectorization had been removed in favor of “dot calls” and + was the last holdout. (Moreover, it turns out that there are strong reasons to encourage people to use “dot calls” uniformly for vectorization, besides mere consistency, because they enable loop fusion optimization.)

Believe me, your concern about array + scalar was considered very seriously over a long period of time as you will find if you read the linked issues. Although the end result is that Julia is indeed different from Matlab or Numpy, this difference is compensated by having a rule that you have to learn only once, for all functions.

30 Likes