# Computed Property vs Getter

**URL:** <https://discuss.emberjs.com/t/computed-property-vs-getter/16391>\
**Category:** General\
**Created:** [April 2, 2019, 9:48am UTC](https://discuss.emberjs.com/t/computed-property-vs-getter/16391 "2019-04-02T09:48:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Caltor](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/caltor/32/18265_2.png) [@Caltor](https://discuss.emberjs.com/u/Caltor)\
**Post date:** [April 2, 2019, 9:48am UTC](https://discuss.emberjs.com/t/computed-property-vs-getter/16391/1 "2019-04-02T09:48:22Z")

</div>

With the advent of ES6 we can now use getters as in:

```
export class col {
    constructor(left, width = 140) {
        this.left = left;
        this.width = width;
    }

    get middle() {
        return this.left + this.width/2;
    }
}

```

Previously I would have used a computed property in the example above to obtain the `middle` value. Is there any advantage to either approach? The `get` seems ideal to me as I don’t have to `import` anything and remember to identify the key fields I will be watching. Just wondered if there are any disadvantages to this (performance?) compared to traditional Ember computed properties or any gotchas of which I need to be aware.

---

<div class="post-metadata">

**Author:** ![NullVoxPopuli](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/nullvoxpopuli/32/18691_2.png) [@NullVoxPopuli](https://discuss.emberjs.com/u/NullVoxPopuli)\
**Post date:** [April 2, 2019, 9:51am UTC](https://discuss.emberjs.com/t/computed-property-vs-getter/16391/2 "2019-04-02T09:51:31Z")

</div>

I’m using native getters in [https://emberclear.io](https://emberclear.io), but I’m also using tracked properties and auto-tracking.

I ‘think’ it’d be faster, because you to longer have a cache layer from computed. And with small properties, I that is preferred.

---

<div class="post-metadata">

**Author:** ![Caltor](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/caltor/32/18265_2.png) [@Caltor](https://discuss.emberjs.com/u/Caltor)\
**Post date:** [April 2, 2019, 10:04am UTC](https://discuss.emberjs.com/t/computed-property-vs-getter/16391/3 "2019-04-02T10:04:25Z")

</div>

> [@NullVoxPopuli](#):
>
> I ‘think’ it’d be faster, because you to longer have a cache layer from computed. And with small properties, I that is preferred.

Sorry, just to clarify - you think getters would be faster than computed? I’m guessing if there is a property that is accessed a lot or involves heavy computation then the caching of a computed property would probably win though.

---

<div class="post-metadata">

**Author:** ![NullVoxPopuli](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/nullvoxpopuli/32/18691_2.png) [@NullVoxPopuli](https://discuss.emberjs.com/u/NullVoxPopuli)\
**Post date:** [April 2, 2019, 10:20am UTC](https://discuss.emberjs.com/t/computed-property-vs-getter/16391/4 "2019-04-02T10:20:52Z")

</div>

> [@Caltor](#):
>
> you think getters would be faster than computed?

Yeah. However, I don’t know how well this works pre-octane. My only concern pre-octane is if a change in the getter value will result in a template update.

> [@Caltor](#):
>
> I’m guessing if there is a property that is accessed a lot or involves heavy computation then the caching of a computed property would probably win though.

Potentially. But in octane, you don’t need to worry about it, thanks to tracked and auto tracking, you can just use getters. 🙂

---

<div class="post-metadata">

**Author:** ![Caltor](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/caltor/32/18265_2.png) [@Caltor](https://discuss.emberjs.com/u/Caltor)\
**Post date:** [April 2, 2019, 10:55am UTC](https://discuss.emberjs.com/t/computed-property-vs-getter/16391/5 "2019-04-02T10:55:46Z")

</div>

> [@NullVoxPopuli](#):
>
> Potentially. But in octane, you don’t need to worry about it, thanks to tracked and auto tracking, you can just use getters. 🙂

Thanks. Octane isn’t out yet is it? I’m on 3.4 LTS at the moment.

---

<div class="post-metadata">

**Author:** ![NullVoxPopuli](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/nullvoxpopuli/32/18691_2.png) [@NullVoxPopuli](https://discuss.emberjs.com/u/NullVoxPopuli)\
**Post date:** [April 2, 2019, 11:22am UTC](https://discuss.emberjs.com/t/computed-property-vs-getter/16391/6 "2019-04-02T11:22:10Z")

</div>

> [@Caltor](#):
>
> Thanks. Octane isn’t out yet is it?

Correct, all pieces of it will hopefully be in non-canary on the next releases and then hopefully the release after will be the octane release 🙂
