Julia function arguments follow a convention sometimes called “pass-by-sharing”, which means that values are not copied when they are passed to functions.
I know that in this case the variable points is not copied when passed to scatter.
Now consider having a 2×500 Array of points, i.e., 500 points in a 2D space. For this case, the scatter plot requires you to pass both x and y series separately. We usually do this by writing
scatter(points[1, :], points[2, :])
In this case points[1, :] and points[2, :] are copies of each row of points that are created before being passed to the function. A way to prevent this is
scatter(view(points, 1, :), view(points, 2, :))
but it is a bit verbose, is there a way to achieve the same behavior without calling view?
Did you benchmark this?
I doubt that the copying would take any noticeable amount of time with a 2x500 array, compared the plotting (and I suspect if the array is actually large enough for this to matter, you want a 2d histogram rather than a scatter plot).
I used 500 for the sake of example, but yes in practice it might not be relevant. I asked out of curiosity and still managed to learn one or two things from the answers.
It is very likely that plotting time will also scale at least linearly or worse (when a render has to figure out overlap in case of overplotting) with the number of points.
The key to efficient Julia code is to be aware of various performance pitfalls and optimization techniques, then benchmark and profile, and apply them where needed.