Yes, Julia is often used for scientific programming, so it tries to respect the rules of the sciences.
Letâs look at the addition example using 2D position vectors from physics. You mentioned that you have some experience with these.
Code
using Plots
v0=[0,0]
v1=[1, 2]
v2=[-1, 1]
v3=v1+v2
plot([v0[1],v1[1]], [v0[2],v1[2]], arrow=true, linewidth=3, annotations=tuple(v1+[0.3,0.0]...,"[1,2]"), label="v1")
plot!([v0[1],v2[1]], [v0[2],v2[2]], arrow=true, linewidth=3, annotations=tuple(v2+[-0.3,0.0]...,"[-1,1]"), label="v2")
plot!([v0[1],v3[1]], [v0[2],v3[2]], arrow=true, linewidth=3, annotations=tuple(v3+[0.3,0.0]...,"[0,3]"), label="v1+v2")
plot!(xlabel="East-West Position", ylabel="North-South Position", aspect_ratio=:equal, legend=:topleft, legendfont=14, guidefont=16, tickfont=14)
In this example, you start at position [0,0]
. You walk 1 block East and 2 blocks North represented by the vector [1,2]
. You then walk 1 block West and 1 block North represented by the vector [-1,1]
. Your final position is the sum of your individual changes on position [1,2] + [-1,1] = [0,3]
.
Now letâs say you are at position [0,3]
and want to walk 2
. What does that mean? 2
in which direction? North? East? Both? [0,3] + 2 = ?
You can see from this example that scalar 2
is not enough information for Julia to know what you mean.
On the other hand, [0,3] * 2
pretty clearly means that you want to make that same move twice, so the answer to multiplying by scalar 2
is well defined as [0,3] * 2 = [0,6]
.