What is the idea of having a builtin function like 'axpy!'?

I am from matlab. I find that there are actually much more builtin functions in julia than in matlab. In julia, we even have a function like ‘axpy!’

It is of course handy to have such a builtin function, although it is simple to program it yourself.

What is the idea of having such small functions? Possibly matlab should have them too, as we pay more should get more.

The axpy function relates to the BLAS standard. BLAS routines are the cornerstone of numerical computing and are often backed by vendor-specific highly optimized libraries like MKL. These are typically much faster than the equivalent handwritten routine.


To extend. bit on “why to have them”, using the high level functions is usually. just fine, especially when you write the code initially.
Later, if you notice it can be done faster by using a low level function you could still optimise your code to get a bit more performance. Though for now I mainly have seen that with mul!, specially its second variant.

LinearAlgebra.axpy! is not a built-in function, you can tell because it prints “generic function” in the REPL. A built-in function, like getfield, prints “built-in function” and lacks the multiple modifiable methods of a generic function. Built-in functions all belong to the Core module, which must be present for Julia to work at all. Even the Base module with basic features, like getindex, is only imported automatically in module block modules; baremodule block modules only import Core automatically. In both Julia and MATLAB, a built-in function is implemented in a different language, often C; this does not imply that other functions must be entirely implemented in the base language, some like axpy! are not.