I have been using the platform for a few months and now generally prefer creating Functions instead of Actions for e.g. Get local time(), ConfirmUserAuthenticated() etc.

I would like the perspective of senior developers as to whether they are basically the same thing except for edge cases or is there a tangible difference between the two and when might one be more appropriate than the other.

Hi,

The reason to use a Function is to enable the action to be used in expressions.
When doing so, a single output is mandatory. 

There is no other reason to create functions. Besides, in many situations, when the action will not be used in expressions, it is useful to be able to return more than one value, and not having to use a structure, for example.

So, if there is no need to an action to be used in expressions, there is no need to it to be a function.

Cheers.

Solution

Hello Raphael.

Well, Functions are Actions.

When you call an Action, you see it and account for it in performance. Functions are equally heavy but stay hidden.

The way I see it, the use of functions should be limited to setting an expression. But... when you need to reuse a value, if you called an Action, you just use its output again. If it is a function, you may call it twice because you forgot about it, consuming twice the resources.

In a metaphor, there is an animal somewhere in the house eating your food. Would you rather it to be a dog, that barks and goes to you and eats from your hand, or hidden mice that help themselves from your stock and multiply out of your control?

I would set all the Actions that can be Functions with Function=Yes, and use a small cache when applicable, but still call them as Actions whenever I can. If the developers are junior, give them only Actions so they think/ask before using.

Solution

Hello Raphael,

Just to make it clear for you, a function is an action :)

They are basically the same thing, there are no performance advantages when using one or another. The main difference between them is that a function can be used inside expressions directly on the screen, while an action can't. But you can still use an function as a regular action in your flows, because the function is still an action.


Hope that this helps.


Kind regards,

Rui Barradas

Great answers thank you for all your perspectives. It us hard to choose a correct answer as they all contain useful info. But I will choose one to respect community rules. Thank you all.