# New blog post about Julia parametric types and constructors

**URL:** <https://discourse.julialang.org/t/new-blog-post-about-julia-parametric-types-and-constructors/120717>\
**Category:** Teaching & Outreach\
**Tags:** parametric-types, constructors\
**Created:** [September 30, 2024, 11:03am UTC](https://discourse.julialang.org/t/new-blog-post-about-julia-parametric-types-and-constructors/120717 "2024-09-30T11:03:52Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![PatrickHaecker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/patrickhaecker/32/222891_2.png) [@PatrickHaecker](https://discourse.julialang.org/u/PatrickHaecker)\
**Post date:** [October 7, 2024, 1:24pm UTC](https://discourse.julialang.org/t/new-blog-post-about-julia-parametric-types-and-constructors/120717/6 "2024-10-07T13:24:52Z")

</div>

In preparation to the second tutorial, it probably makes sense to highlight that it is not about (subtype of) abstract field types versus concrete field types for the struct (as you imply with the content at the bottom of the page).  
Rather it is about parametric (possibly subtype of abstract) type parameters versus abstract field types:

```julia
struct ParametricAbstract{T <: Real}
    x::T
    y::T
end

struct Abstract
    x::Real
    y::Real
end

```

```julia
julia> ParametricAbstract(2f0, 2f0) |> Base.summarysize
8

julia> Abstract(2f0, 2f0) |> Base.summarysize
24

```

I think the rule of thumb should be:

- It’s okay and often even encouraged to be (subtype of) abstract in the header (defining the type parameters of a struct or the arguments of a method),
- but you should be specific in the body (using a concrete type or type parameter).

The reason for this rule of thumb is (no surprise here): multiple dispatch (or after thinking a bit more about it) and specialization.

---

_[View the full topic](https://discourse.julialang.org/t/new-blog-post-about-julia-parametric-types-and-constructors/120717)._
