# Julia type displaying change between versions

**URL:** <https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029>\
**Category:** New to Julia\
**Created:** [July 30, 2022, 2:35pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029 "2022-07-30T14:35:04Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [July 31, 2022, 9:19pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/21 "2022-07-31T21:19:28Z")

</div>

> [@Schneeschaufel](#):
>
> Also this is pretty confusing:
> 
> ```julia
> **julia>** Array[[5,6],[9,78]]
> 
> 2-element Vector{Array}:
> 
> [5, 6]
> 
> [9, 78]
> 
> ```
> 
> It shouldn’t rather be expressed as:
> 
> ```julia
> **julia>** Vector[[5,6],[9,78]]
> 
> ```

I don’t really follow what you are saying here, if you simply do

```julia
julia> [[2, 3], [4, 5]]
2-element Vector{Vector{Int64}}:
 [2, 3]
 [4, 5]

```

you get a vector of vectors if that is what you want, but if you specify that the elements should be of type Array (what you do when you say `Array[...]`) you get a vector of arrays. Not sure if that was the problem?

---

<div class="post-metadata">

**Author:** ![Schneeschaufel](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@Schneeschaufel](https://discourse.julialang.org/u/Schneeschaufel)\
**Post date:** [July 31, 2022, 9:19pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/22 "2022-07-31T21:19:31Z")

</div>

If this is so then it does not make sense:

```julia
**julia>** Array[[5,6],[9,78]]

2-element Vector{Array}:

```

It should rather print:

```julia
**julia>** Array[[5,6],[9,78]]

2×2 Matrix{Int64}:

```

---

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [July 31, 2022, 9:21pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/23 "2022-07-31T21:21:57Z")

</div>

But what if I do

```julia
julia> Array[[5,6],[7,8,9]]
2-element Vector{Array}:
 [5, 6]
 [7, 8, 9]

```

would you want this to be a matrix?

---

<div class="post-metadata">

**Author:** ![Schneeschaufel](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@Schneeschaufel](https://discourse.julialang.org/u/Schneeschaufel)\
**Post date:** [July 31, 2022, 9:23pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/24 "2022-07-31T21:23:20Z")

</div>

I already see it coming (like with NumPy): even using NumPy for more than 10 years I cannot use a NumPy function without looking it up. Everything is so counter intuitive.

---

<div class="post-metadata">

**Author:** ![Schneeschaufel](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@Schneeschaufel](https://discourse.julialang.org/u/Schneeschaufel)\
**Post date:** [July 31, 2022, 9:26pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/25 "2022-07-31T21:26:59Z")

</div>

I cannot change the Julia syntax. I will stop arguing here.

But replying to your questions: the problem stems from the fact that:

```julia
Julia> Array[[5,6],[7,8,9]]

```

just seems wrong and it should be:

```julia
Julia> Vector[[5,6], [7,8,9]]

```

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [July 31, 2022, 9:31pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/26 "2022-07-31T21:31:17Z")

</div>

> [@Schneeschaufel](#):
>
> If this is so then it does not make sense:

Why? `T[]` with `T` being a type is syntax for creating a vector that can hold any valid `T`. If `T` is `Array` it will be able to hold any `Array`, if `T` is `Vector` it will be able to hold any `Vector`.

By explicitly specifying the element type you’re overriding the automatically inferred type, making it less specific.

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [July 31, 2022, 9:32pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/27 "2022-07-31T21:32:36Z")

</div>

> [@Schneeschaufel](#):
>
> just seems wrong and it should be:

You’ll still be able to do `push!(my_vec, ["foo"])`, which I don’t think you want?

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [July 31, 2022, 9:33pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/28 "2022-07-31T21:33:15Z")

</div>

> [@Schneeschaufel](#):
>
> ```julia
> Julia> Array[[5,6],[7,8,9]]
> 
> ```
> 
> just seems wrong and it should be:
> 
> ```julia
> Julia> Vector[[5,6], [7,8,9]]
> 
> ```

They are not the same. If you want `Vector[[5,6], [7,8,9]]`, then write that, and you will get it.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [July 31, 2022, 9:36pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/29 "2022-07-31T21:36:46Z")

</div>

> [@kevbonham](#):
>
> I gather this distinction is important to the linear algebra folks, but I find it a bit awkward. then again, it rarely comes up in practice

The distinction is important, and comes up _everywhere_ in practical coding (and definitely not mainly in linear algebra). Matlab’s failure to distinguish these two is a terrible mistake, that _constantly_ creates problems for Matlab users.

Here is my rant about Matlab’s lack of matrix-vector distinction: [Trouble Understanding Slicing - #7 by DNF](https://discourse.julialang.org/t/trouble-understanding-slicing/36821/7)

---

<div class="post-metadata">

**Author:** ![Schneeschaufel](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@Schneeschaufel](https://discourse.julialang.org/u/Schneeschaufel)\
**Post date:** [July 31, 2022, 9:46pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/30 "2022-07-31T21:46:27Z")

</div>

IDL data language also does not make a distinction between vectors and arrays as far as I know.

IDL is less used in physics and engineering but was (less so these days) a big player in astrophysics and Earth satellite image processing.

NumPy also has no vectors. And if I convert a list of numbers to a NumPy array I have no idea if NumPy thinks it has to deal with a vector from that moment onwards. It is actually pain.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [July 31, 2022, 9:51pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/31 "2022-07-31T21:51:11Z")

</div>

> [@Schneeschaufel](#):
>
> So Julia is not backwards compatible.

Julia follows _semantic versioning_, which means that minor version updates are backwards compatible. Code that worked on v1.0 must work on 1.8, etc. If a new version is introduced that breaks backwards compatibility, then the _major_ version must be updated. In other words, Julia is backwards compatible until v2.0, whenever that might be.

“Backwards compatibility” does not mean “nothing changes”. If it did, then what would be the point of new development? Just make a final version, and stop developing. If you dislike changes, pick a version you like, and never update.

> [@Schneeschaufel](#):
>
> All the tutorials on the net are broken now.

Tutorials based on versions before the first stable release, v1.0, _may_ be broken, but tutorials based on newer versions should not be. If they are, there’s a problem with the tutorial itself.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [July 31, 2022, 9:54pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/32 "2022-07-31T21:54:31Z")

</div>

> [@Schneeschaufel](#):
>
> IDL data language also does not make a distinction between vectors and arrays as far as I know.

I presume you mean it doesn’t distinguish vector and matrix. Vectors are a type of array, as is matrix, but they are different. I don’t know IDL, but I linked to a post where I explain why this is bad.

> [@Schneeschaufel](#):
>
> NumPy also has no vectors.

Yes, fortunately, it _does_ have actual vectors.

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [July 31, 2022, 9:55pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/33 "2022-07-31T21:55:11Z")

</div>

> [@DNF](#):
>
> and comes up _everywhere_ in practical coding

I should have said “rarely comes up in practice _for me_”. I don’t claim to be typical in my uses, my point was that there’s clearly a (well thought out) reason for the way things are done, and after a bit of initial confusion on my part, it rarely causes me problems. And when it does, I just put a `vec()` on it and it works out fine 😂.

---

<div class="post-metadata">

**Author:** ![Schneeschaufel](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@Schneeschaufel](https://discourse.julialang.org/u/Schneeschaufel)\
**Post date:** [July 31, 2022, 9:56pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/34 "2022-07-31T21:56:56Z")

</div>

Never came across or heard of vectors in NumPy (I am using Python \> 3.8 and a NumPy compatible version in Conda).

What would those vectors be in NumPy?

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [July 31, 2022, 9:58pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/35 "2022-07-31T21:58:52Z")

</div>

> [@kevbonham](#):
>
> I should have said “rarely comes up in practice _for me_”.

Maybe you don’t use Matlab 😉 Julia takes care of the distinction for you, so you basically rarely have to think about it. In Matlab, you must _always_ be aware of this, and constantly check explicitly whether you are working with rows or columns.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [July 31, 2022, 10:05pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/36 "2022-07-31T22:05:58Z")

</div>

> [@Schneeschaufel](#):
>
> What would those vectors be in NumPy?

It’s the regular 1D arrays [Array creation — NumPy v1.26 Manual](https://numpy.org/doc/stable/user/basics.creation.html)

```julia
a1D = np.array([1, 2, 3, 4]) 

```

Perhaps you mean they are not _called_ “vector”? But the point is that you never have to wonder whether to represent a vector as a row or a column. Just always use a flat 1d array.

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [July 31, 2022, 10:08pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/37 "2022-07-31T22:08:25Z")

</div>

> [@DNF](#):
>
> Maybe you don’t use Matlab 😉

🎯

I don’t use much of anything other than Julia these days, though I used to do more python/R. But in python I rarely had need of something more performant then a list, and in R it was basically just “read in the CSV and plot it.”

---

<div class="post-metadata">

**Author:** ![tomerarnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomerarnon/32/3170_2.png) [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)\
**Post date:** [July 31, 2022, 10:23pm UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/38 "2022-07-31T22:23:22Z")

</div>

> [@Schneeschaufel](#):
>
> ```julia
> **julia>** Array[[5,6],[9,78]]
> 
> 2-element Vector{Array}:
> 
> ```
> 
> It should rather print:
> 
> ```julia
> **julia>** Array[[5,6],[9,78]]
> 
> 2×2 Matrix{Int64}:
> 
> ```

Both are correct syntactically, but they do different things. A `Vector` is a “flat” collection of items. An `Array` is a collection of items with “rectangular” shape (of arbitrary dimensionality). A `Vector` is a kind of `Array`; a `Matrix` is also a kind of `Array`; a 3-dimensional array is also an `Array`; etc. There is a type hierarchy in julia, and you can use it to confirm that, e.g., Vector is a subtype of Array (written `Vector <: Array`). Furthermore, a matrix is not the same as a vector-of-vectors (see my reply to an earlier comment of yours below).

`T[a, b, c]` creates a `Vector{T}` (a vector that holds things of type `T`) with elements a, b, and c. `[a, b, c]` creates a vector where `T` is inferred from the elements to be the most specific it can be. If a different `T` is provided, then the vector is initialized to hold that T instead. See:

```julia
julia> [1,2]
2-element Vector{Int64}:
 1
 2

julia> Number[1,2]
2-element Vector{Number}:
 1
 2

```

Therefore, this behavior follows naturally:

```julia
julia> [[1,2], [3,4,5]]
2-element Vector{Vector{Int64}}:
 [1, 2]
 [3, 4, 5]

julia> Array[[1,2], [3,4,5]]
2-element Vector{Array}:
 [1, 2]
 [3, 4, 5]

```

> [@Schneeschaufel](#):
>
> Because an array normally is thought of as a vector of vectors and each element again can represent a vectors.

This is incorrect. In all languages that have a multi-dimentional array type, such an array must be “rectangular”. That is, all rows must have the same number of elements; likewise for columns. You cannot have a row of 3 followed by a row of 4. In order to store something like that, you must use an array-of-arrays, which is not the same thing. Since they are not the same thing, and they have vastly different uses, guarantees, and performance trade-offs, it make sense for a language to be able to represent both types, and many languages have done so long before julia.

---

<div class="post-metadata">

**Author:** ![Schneeschaufel](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@Schneeschaufel](https://discourse.julialang.org/u/Schneeschaufel)\
**Post date:** [August 1, 2022, 6:40am UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/39 "2022-08-01T06:40:27Z")

</div>

I know and this was my point. An array consists of vectors of vectors etc.

Yes the vectors have to return the same length.

In NumPy I often have something like this (treating the list as kind of a poor mans vector):

```julia
erg=[]
for i in range(5):
   erg.append(xxxx)

np.array(erg)

```

where xxxx is a NumPy array of the same length and type. And erg now is a 2D array.

In Scheme there are no arrays. I used vectors of vectors to create my own array library up to a certain dimension.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [August 1, 2022, 6:52am UTC](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029/40 "2022-08-01T06:52:56Z")

</div>

> [@Schneeschaufel](#):
>
> I know and this was my point. An array consists of vectors of vectors etc.

No, an array does not have to be nested. It can contain any type of data, including plain numbers. So `[1,2,3]` is an array, too, as is a matrix, `[1 2 3; 4 5 6]`, etc.

The point of `Array` is that it is very general, and be either flat or nested, be of any dimension, (0, 1, 2, 3, …, N, …), and contain any type of elements you want.

```julia
julia> [1,2,3] isa Array
true

julia> [1 2 3; 4 5 6] isa Array
true

julia> [[1,2], [3 4; 5 6], 8, "Hello"] isa Array
true

```

[Previous page](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029.md?page=1)

[Next page](https://discourse.julialang.org/t/julia-type-displaying-change-between-versions/85029.md?page=3)
