In the following two code snippets, is there a deeper difference other than MyMatrix being more descriptive, i.e. the type tells me the type of the elements and that it stores those elements as a vector? Is the first version more Julian? If so, why? Are there performance differences? The struct definition of Version 2 seems a little cleaner?!
Version 2 is not concrete. v is of abstract type at the moment of creation and (in principle) it will be much slower than the first one; You can always fix this by fixing the actual concrete type, i.e. declaring v::Vector{T}, but that makes the approach less flexible (you can’t use it with e.g. sparse vectors, before the’re converted to dense ones)
julia> using BenchmarkTools
julia> n = 10000000
julia> A = @btime MyMatrix(rand(n))
julia> B = @btime MyNewMatrix(rand(n))
20.005 ms (3 allocations: 76.29 MiB)
19.737 ms (3 allocations: 76.29 MiB)
See Performance Tips · The Julia Language and the following section. The short answer is that you should declare the type in such as way that the type system knows exactly what it’s going to get from A.v.