# Polymorphic Type Instance Memory Overhead

**URL:** https://discourse.julialang.org/t/polymorphic-type-instance-memory-overhead/14211
**Category:** General Usage
**Created:** [August 28, 2018, 8:32pm UTC](https://discourse.julialang.org/t/polymorphic-type-instance-memory-overhead/14211 "2018-08-28T20:32:44Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [August 29, 2018, 9:22am UTC](https://discourse.julialang.org/t/polymorphic-type-instance-memory-overhead/14211/4 "2018-08-29T09:22:11Z")

</div>

> [@nordlow](#):
>
> Is union types or composition of inheritance the way to express traditional object hierarchies in Julia?

I don’t know what a “traditional object hierarchy” is. Julia has single-ancestor subtypes, where the leafs are concrete and the rest is abstract types. These are mostly used for governing dispatch. Composition is recommended for what some OO languages solve with inheritance. See

> [@Composition and inheritance: the Julian way](https://discourse.julialang.org/t/composition-and-inheritance-the-julian-way/11231):
>
> I am a relatively newbie and I am wondering what is the most appropriate Julian way to reuse the code. I don’t want to trigger discussions on topics already discussed a million times. This post simply aims to lay down a clear list of rules to be followed to write good Julia code, and pose a couple of questions. Let’s start with an example: I have a type Person mutable struct Person \<: AbstractPerson name::String age::Int end and a lot (hundreds) of methods dealing with it. Now I wa…

> [@Workaround for traditional inheritance features in object-oriented languages](https://discourse.julialang.org/t/workaround-for-traditional-inheritance-features-in-object-oriented-languages/1195/):
>
> I am using the Julia type system seriously for the first time and have just learned that it doesn’t support inheritance from non-abstract types nor multiple inheritance. This statement applies to Julia v0.5. Could you please explain how one can workaround these limitations, specifically: How you develop code with inheritance from abstract types only? Does it cover all possible use cases? Is there any workaround for the lack of multiple inheritance?

> [@OOP in Julia, inherit from parametric composite type](https://discourse.julialang.org/t/oop-in-julia-inherit-from-parametric-composite-type/1841):
>
> Hey, so this might be a rather vague question but anyway here it is. I am really having a hard time getting to grasp with OOP in Julia. I am developing a package for specific clinical trial designs and these designs can essentially be represented as a tuple of vectors. Trying to be thorough I implement them as parametric composite types. E.g. the base design could be type DesignA{T1, T2} v1::Vector{T1} v2::Vector{T2} end Now another design could be just like DesignA but with additional pa…

and similar topics.

Also, I would not worry about representation in memory etc, other than what is described in the

[https://docs.julialang.org/en/stable/manual/performance-tips/](https://docs.julialang.org/en/stable/manual/performance-tips/)

---

_[View the full topic](https://discourse.julialang.org/t/polymorphic-type-instance-memory-overhead/14211)._
