# Best Practice: Script or Expression

**URL:** <https://forum.inductiveautomation.com/t/best-practice-script-or-expression/91764>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [June 12, 2024, 5:09pm UTC](https://forum.inductiveautomation.com/t/best-practice-script-or-expression/91764 "2024-06-12T17:09:21Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 12, 2024, 5:29pm UTC](https://forum.inductiveautomation.com/t/best-practice-script-or-expression/91764/3 "2024-06-12T17:29:19Z")

</div>

> [@Steven\_Cheron](#):
>
> I don't know which onw is faster

Expressions are faster, always.

> [@Steven\_Cheron](#):
>
> I use script when I need conditions, loop or advanced function that expression don't give.

If you can use the [Automation Professionals Integration Toolkit](https://forum.inductiveautomation.com/t/automation-professionals-integration-toolkit-module/74934) many of those limitations are also eliminated (e.g. iteration)

Generally, avoid transforms if possible, and default to pure expressions.

You can not do multithreading in expressions. There are certain applications which the expression language is not capable of, in those cases you will need to use scripts.

> [@Matthew\_Kuss](#):
>
> The most current example is I'm trying to set a button visibility based on the user role. I've bounded the role to the visibility property but then need to transform it to a Boolean value using an if statement. Does it matter what type of transformation I use for this?

This is a perfect example of when you don't even need a transform at all.

Just use a pure expression binding.

```python
hasRole('role')

```

For more perspective performance infomation see this thread:

> [@Building for Performance](https://forum.inductiveautomation.com/t/building-for-performance/71082/3):
>
> In this example, #3 is the most performant, though it could be argued that the performance gain in this instance would be negligible. Anytime you add an additional processing step you add latency. In general for the best performance I follow these guidelines: If you can achieve what you want with a binding, use a binding. Always use the binding type that is the most direct. (e.g. if all you need is a binding to a property use a property binding, not an expression binding.) Given the choice b…

---

_[View the full topic](https://forum.inductiveautomation.com/t/best-practice-script-or-expression/91764)._
