I think that Rivest’s question may be a good reason to rethink the initialization of structs and offer the explicit guarantee that all unassigned elements will be initialized to 0 (and not just the jl_value_t pointers). I would argue that the current behavior resulted more from a desire to avoid clearing the array twice (if the user is about to call fill, zeros, ones, +, etc.) than an intentional, casual exposure of uninitialized memory.
A random array of integers is also a security concern if an attacker can extract some other information (with some probability) about the state of the program. Julia is not hardened by design, so you can’t safely run an unknown code fragment, but you still might have an unintended memory exposure in a client-facing app. While zero’ing memory doesn’t prevent the user from simply reusing a memory buffer in a security-unaware fashion (rather than consistently allocating a new one for each use), it’s not clear to me that the performance penalty would be all that noticeable for map Array(X) to zero(X), and only providing an internal constructor for grabbing uninitialized memory (perhaps Base.Unchecked.Array(X) from #8227)
So we are talking adding possibly seconds to a program per large array allocation.
$ ./julia -q
julia> N=10^9
1000000000
julia> @time begin x=zeros(Int64,N); fill(x,0) end
elapsed time: 6.325660691 seconds (8000136616 bytes allocated, 1.71% gc time)
0-element Array{Array{Int64,1},1}
$ ./julia -q
julia> N=10^9
1000000000
julia> @time x=zeros(Int64,N)
elapsed time: 6.160623835 seconds (8000014320 bytes allocated, 0.22% gc time)
julia> @time beginx = Array(Int,N)fill!(x,1)end;elapsed time: 6.782572096 seconds (8000000128 bytes allocated)julia> @time beginx = zeros(Int,N)fill!(x,1)end;elapsed time: 14.166256835 seconds (8000000176 bytes allocated)
Using calloc could reduce this significantly since the kernel can lazily fill zero pages only when you access them.
In general, arrays cannot be assumed to be 16-byte aligned because it's always possible to create one that isn't using pointer_to_array. However, from Intel's AVX introduction:Intel® AVX has relaxed some memory alignment requirements, so now Intel AVX by default allows unaligned access; however, this access may come at a performance slowdown, so the old rule of designing your data to be memory aligned is still good practice (16-byte aligned for 128-bit access and 32-byte aligned for 256-bit access).