Stream: ideas

Topic: ✔ term for a function that isn't pure


view this post on Zulip Richard Feldman (Sep 19 2024 at 17:58):

so in #ideas > Purity Inference I used the term "effectful" function to describe a function that isn't pure. My reasoning was that "impure" function sounded unnecessarily judgmental; it's not like I should feel bad for writing or using a function like that, it just means I'm getting a different set of tradeoffs compared to pure functions!

view this post on Zulip Richard Feldman (Sep 19 2024 at 17:59):

but someone pointed out to me that "effectful" suggests it's doing side effects, but that's not necessarily the reason it's not pure

view this post on Zulip Richard Feldman (Sep 19 2024 at 17:59):

for example, it could be just reading from external state other than its arguments, in a way that doesn't actually change the outside world at all - so, not really an "effect" per se, but still disqualifying the function from being pure (and e.g. benefiting from compiler optimizations that are safe to do only on actually pure functions)

view this post on Zulip Richard Feldman (Sep 19 2024 at 18:00):

so maybe "effectful" is the best name for those, but I'd like to explore alternative terms and see if we can find a better one!

view this post on Zulip Richard Feldman (Sep 19 2024 at 18:00):

one that interests me is "pure function vs stateful function" - in the sense that it's either reading or writing external state

view this post on Zulip Richard Feldman (Sep 19 2024 at 18:01):

that feels in some ways more accurate than "effectful" but a thing I don't like about it is that it kinda feels like it's saying "this is a function where in my own code I've defined some state which travels with the function" rather than "this is a function which interacts with state in the outside world"

view this post on Zulip Richard Feldman (Sep 19 2024 at 18:02):

like how in some languages it's possible to make a lambda that captures a mutable object and both modifies and reads from it - that's what I think of when I hear "stateful function"

view this post on Zulip Richard Feldman (Sep 19 2024 at 18:03):

another idea is "pure functions vs procedures" where a procedure is allowed to do side effects, read from external state, etc.

view this post on Zulip Richard Feldman (Sep 19 2024 at 18:03):

a thing I don't like about that is that historically, procedures haven't been closures - they don't have a concept of captures, etc.

view this post on Zulip Richard Feldman (Sep 19 2024 at 18:04):

open to any thoughts and ideas on this! :big_smile:

view this post on Zulip Kilian Vounckx (Sep 19 2024 at 18:13):

I don't like procedure, because often it has become a name used almost interchangeably with function. I think in nim, they use func or (mostly) pure functions and proc for impure ones, but I think it will just be a distinction to learn for newcomers rather than it being intrinsic to the name. I am not a native English speaker however, so maybe it is intrinsic.
I like stateful a lot better as it implies what is meant. Maybe it doesn't cover everything an impure function can do, but both external and internal state are covered. So I/O and randomness are covered as well as things like mutating closures

view this post on Zulip Sam Mohr (Sep 19 2024 at 18:15):

As a native English speaker, "pure function vs. procedure" is not an English thing intrinsically

view this post on Zulip Johan Lövgren (Sep 19 2024 at 18:18):

One thing I like about procedure is that it is quite dry. Though there can be preconceptions, I think they are not super common. And I think it would be easy to learn “functions are pure, procedures are not”

view this post on Zulip Sam Mohr (Sep 19 2024 at 18:24):

It does feel like we're just pushing down the road if we say "we'll just tell people what procedures actually mean"

view this post on Zulip Sam Mohr (Sep 19 2024 at 18:25):

Which is why unless we find a better synonym, effectful and stateful seem like the only options so far that are directly explanatory of the behavior here

view this post on Zulip Akshay Trivedi (Sep 19 2024 at 19:10):

another idea is to reuse existing terminology - "Task".

My 2 cents: the word "function" is derived from mathematics, in which it means a mapping from inputs to return values (although in imperative programming languages, it doesn't have this meaning). However, words like "procedure" and "task" make it clear to me that it's a sequence of things being done, differentiating themselves from "functions". Especially in a functional programming language, I think the terms "function" and "procedure" are sufficiently distinct, because people should already have the preconception that functions are pure

view this post on Zulip Akshay Trivedi (Sep 19 2024 at 19:10):

(I don't have a preference between "procedure" and "task")

view this post on Zulip Johan Lövgren (Sep 19 2024 at 19:14):

That’s exactly what I was thinking Akshay :)

view this post on Zulip Johan Lövgren (Sep 19 2024 at 19:15):

Though I slightly prefer procedure, as I think task has more preconceptions regarding asynchrony

view this post on Zulip Luke Boswell (Sep 19 2024 at 19:16):

I thought it was called effectful because it was ran by an effect interpreter. :thinking:

view this post on Zulip Sam Mohr (Sep 19 2024 at 19:16):

I've been trying to imply "might perform side effects" when I say effectful

view this post on Zulip Johan Lövgren (Sep 19 2024 at 19:19):

Perhaps slightly more contrived: function vs interaction

view this post on Zulip Luke Boswell (Sep 19 2024 at 19:20):

I feel like a Latin expert would have the solution to this word problem.

Like we want to convey a thing that can be effectful but may not. It has the ability to do things.

view this post on Zulip Sam Mohr (Sep 19 2024 at 19:21):

A terse term for "not deterministic/referentially transparent" would suffice

view this post on Zulip Luke Boswell (Sep 19 2024 at 19:26):

Richard Feldman said:

for example, it could be just reading from external state other than its arguments, in a way that doesn't actually change the outside world at all - so, not really an "effect" per se, but still disqualifying the function from being pure (and e.g. benefiting from compiler optimizations that are safe to do only on actually pure functions)

Schrödinger's cat may disagree. :sweat_smile:

I think it's fine to say that reading from external state is an Effect.

view this post on Zulip Niclas Ahden (Sep 19 2024 at 20:45):

I think there's value in the terms being opposites (regardless of what the actual terms are). I like that I can teach one concept and then the other one is almost free. "Pure means that it's a lookup table of values: give it X and it'll give you Y, always, regardless of the time or your database, and it won't change anything anywhere either." then explaining impure is just "It's not pure. There's no guarantee that the function returns the same value given X, and it may change stuff like your database." and that's easy for someone to grasp. They learn one (whichever clicks with them) and can recall the other as the opposite. That's neat!

view this post on Zulip Luke Boswell (Sep 19 2024 at 20:49):

From Claude

"Pure vs. Contextual" has the advantage of being relatively neutral while still conveying the key distinction: pure functions operate in isolation, while contextual functions interact with or depend on their environment in some way. This pairing avoids the potential misunderstandings of "effectful" or "stateful" while still being descriptive and forming a clear opposition.

If you prefer to stick closer to established terminology, using "Pure vs. Impure" but consistently explaining that impurity is not a negative quality, just a different set of tradeoffs (as Richard initially suggested), could help reshape the perception of the term over time.

view this post on Zulip Luke Boswell (Sep 19 2024 at 20:51):

ChatGPT

  1. Pure vs. Contextual:

  2. Pure vs. Stateful:

  3. Pure vs. Impure (with Reframing):

  4. Pure vs. Effect-Possible:

  5. Pure vs. Interacting:

  6. Pure vs. Externalized:

view this post on Zulip Niclas Ahden (Sep 19 2024 at 20:55):

"Isolated" is also a clear way to describe a pure function. Don't know the opposite of "isolated" though. Contextual? Cramped? Surrounded by loved ones?

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:02):

Chat Gippity seems to be getting at "interacts with the outside world" the most

view this post on Zulip Romain Lepert (Sep 19 2024 at 21:02):

unconventional but kinda self explanatory: pure functions vs leaking functions

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:05):

As much as it may be irrational, I agree with Richard that we want to avoid negative names, and pretty much anything that's the opposite of "pure" will get that drawback. So leaking, impure, non-deterministic, etc. I think are gonna be a hard sell

view this post on Zulip Brendan Hansknecht (Sep 19 2024 at 21:11):

Obviously pure vs useful cause useful functions are the only ones that actually do anything.... :lol:

Though more seriously, I think interactive, active, effectful, io, or something along those lines is what we want to do for.

view this post on Zulip Brendan Hansknecht (Sep 19 2024 at 21:12):

Pure vs io functions

pure vs interactive functions

...

Both of those sound decent to me

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:12):

Active I haven't seen yet... There's value in a word that's sufficiently generic

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:12):

Interactive also looks good to me

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:13):

IO feels good mainly for historical reasons, not for beginners

view this post on Zulip Isaac Van Doren (Sep 19 2024 at 21:13):

I don't think we should go with stateful. I can almost guarantee that if I wrote down a function that just made a GET request and asked my coworkers if it was stateful, they would all say no.

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:13):

Totally agree

view this post on Zulip Brendan Hansknecht (Sep 19 2024 at 21:13):

We also could go with pure vs platform functions

Cause platform function fundamentally call to the platform which is the only part of a roc executable that can do io or any other effects

view this post on Zulip Isaac Van Doren (Sep 19 2024 at 21:14):

I don't think the terms being opposites is very important. If I say that "an impure function is one that cannot be a lookup table", that doesn't really tell me much about what an impure function can do. It might just be the case that it could read from external state but not write to it, for example.

view this post on Zulip Romain Lepert (Sep 19 2024 at 21:14):

:heart: pure vs io functions
simple and to the point

view this post on Zulip Isaac Van Doren (Sep 19 2024 at 21:15):

I'm not a fan of platform function because you can still have pure functions that are defined by a platform

view this post on Zulip Isaac Van Doren (Sep 19 2024 at 21:15):

My favorites right now are io and active

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:16):

Well, we can't tell, right? If it's a platform function, you have no idea if it's pure. The only way to know from the Roc side is if it's entirely written in Roc/Roc std lib

view this post on Zulip Richard Feldman (Sep 19 2024 at 21:16):

Brendan Hansknecht said:

We also could go with pure vs platform functions

Cause platform function fundamentally call to the platform which is the only part of a roc executable that can do io or any other effects

true, but you can define your own in applications which call the ones you got from the platform, so then you end up with "ok now write a new platform function in your application..." :sweat_smile:

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:16):

I think active is nice because it's short haha

view this post on Zulip Isaac Van Doren (Sep 19 2024 at 21:16):

I think IO gets at the idea that the function might read from external state

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:17):

But it could do any number of things, I think IO is too specific

view this post on Zulip Isaac Van Doren (Sep 19 2024 at 21:17):

Well, we can't tell, right? If it's a platform function, you have no idea if it's pure. The only way to know from the Roc side is if it's entirely written in Roc/Roc std lib

It might not actually be pure, but it is still pure in the -> vs => sense

view this post on Zulip Isaac Van Doren (Sep 19 2024 at 21:17):

But it could do any number of things, I think IO is too specific

Yeah it is definitely an expansion of the concept of IO

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:18):

I blame Haskell for this issue

view this post on Zulip Isaac Van Doren (Sep 19 2024 at 21:18):

An advantage of IO is that it I suspect it would be easier to guess what in IO function is than an active function from the outside.

view this post on Zulip Brendan Hansknecht (Sep 19 2024 at 21:18):

I think IO is a general enough term and is easy to grasp

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:19):

So, we have "pure functions" and "IO functions"?

view this post on Zulip Brendan Hansknecht (Sep 19 2024 at 21:19):

I get that many may think specific at first, but it is overall a pretty general concept

view this post on Zulip Luke Boswell (Sep 19 2024 at 21:19):

When I see I/O I think input and output and don't associate that with non-pure at all.

view this post on Zulip Brendan Hansknecht (Sep 19 2024 at 21:19):

By definition input and output have to be impure

view this post on Zulip Brendan Hansknecht (Sep 19 2024 at 21:19):

So I think that is fine

view this post on Zulip Luke Boswell (Sep 19 2024 at 21:20):

I guess it depends on where you draw the boundary and if you're looking into the system or out of it.

view this post on Zulip Brendan Hansknecht (Sep 19 2024 at 21:20):

Anyway I would rate the roughly:

  1. IO
  2. Effectful
  3. Interactive
  4. Active

view this post on Zulip Brendan Hansknecht (Sep 19 2024 at 21:20):

Luke Boswell said:

Lol, I guess it depends on where you draw the boundary and if you're looking into the system or out of it.

The nice part is that we get to write the definition and people only have to learn it once

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:20):

This is unironically a great opportunity for some ranked choice voting system

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:21):

Just a poll might not do it

view this post on Zulip Brendan Hansknecht (Sep 19 2024 at 21:21):

Star voting!!!

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:21):

I'll take the internet points, then

view this post on Zulip Luke Boswell (Sep 19 2024 at 21:21):

It's election season in the US... I think we should make it mandatory and use a preferential system

view this post on Zulip Luke Boswell (Sep 19 2024 at 21:22):

But that's my exotic Australian opinion on the topic of voting systems

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:25):

Assuming we call -> functions pure functions, what should we call => functions? In alphabetical order:

  1. Active
  2. Contextual
  3. Effectful
  4. Impure
  5. Interactive
  6. IO
  7. Procedure
  8. Stateful
  9. Task

React to whichever versions you'd be okay with

view this post on Zulip Romain Lepert (Sep 19 2024 at 21:25):

Luke Boswell said:

I guess it depends on where you draw the boundary and if you're looking into the system or out of it.

Isn't I/O generally associated with external read/writes like filesystem, db, API, etc. ? Which would be out of the system.

view this post on Zulip Brendan Hansknecht (Sep 19 2024 at 21:25):

Before we make a poll, should at least wait for any other ideas

view this post on Zulip Luke Boswell (Sep 19 2024 at 21:25):

In all seriousness, I still really like effectful.

One of the main reasons is that draws out the whole idea of Effects and purity into the normal conversation. So people will be talking and thinking about these concepts when they are using roc.

I also like that it's as simple as, these are run using an "effect interpreter" which is a machine in the platform that can do things in the real world.

view this post on Zulip Richard Feldman (Sep 19 2024 at 21:29):

yeah also on a meta-level I'm not a fan of polls as a way to advance design discussions because I'd rather focus on getting all the perspectives out there and understanding their tradeoffs

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:29):

Good point

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:30):

I'll try to avoid them in general. It seemed appropriate here because we were just throwing out opinions without a sense of movement towards agreement

view this post on Zulip Luke Boswell (Sep 19 2024 at 21:30):

The great thing about having a BDFN is we dont need agreement :smiley:

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:31):

But yes, polls can push people with unpopular positions away from discussions where their opinions help us all get somewhere better

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:31):

See @Brendan Hansknecht 's existence

view this post on Zulip Richard Feldman (Sep 19 2024 at 21:31):

well consensus is still important haha

view this post on Zulip Richard Feldman (Sep 19 2024 at 21:31):

although not always fully achievable, to be fair

view this post on Zulip Luke Boswell (Sep 19 2024 at 21:31):

We can be all care and no responsibility... if it turns out to be the wrong choice we can all blame Richard :sweat_smile: (no pressure or anything)

view this post on Zulip Sam Mohr (Sep 19 2024 at 21:32):

All of the pressure, actually

view this post on Zulip Richard Feldman (Sep 19 2024 at 21:32):

I knew what I was signing up for!

view this post on Zulip Richard Feldman (Sep 19 2024 at 22:11):

:thinking: maybe we could explain "effectful" as "causing an outside effect and/or being influenced by outside effects"

view this post on Zulip Brendan Hansknecht (Sep 19 2024 at 22:43):

Outside is a bit strange cause it could be something like stored which is still app internal state.

Also, I would note the most important part which is the result may vary on every single call

view this post on Zulip Brendan Hansknecht (Sep 19 2024 at 22:44):

But I feel confident we can come up with a very clear definition

view this post on Zulip Sam Mohr (Sep 19 2024 at 22:48):

I think it's not "more important" enough over "the outside world changes" to be the "most important"

view this post on Zulip Sam Mohr (Sep 19 2024 at 22:48):

But it's quite important

view this post on Zulip Richard Feldman (Sep 19 2024 at 23:16):

oh I meant outside as in outside the function

view this post on Zulip Richard Feldman (Sep 19 2024 at 23:16):

so like not its arguments or return value

view this post on Zulip Brendan Hansknecht (Sep 20 2024 at 00:34):

Oh, that was not how I read that. Outside I thought was a vague description of io

view this post on Zulip Brendan Hansknecht (Sep 20 2024 at 00:35):

Like outside the program

view this post on Zulip Agus Zubiaga (Sep 20 2024 at 13:54):

It might be different for native speaker, but at least to me, "procedure" always sounded like a series of instructions that may affect the world. As opposed to a "function", which we learn from math to be more of a mapping from input to output.

view this post on Zulip Agus Zubiaga (Sep 20 2024 at 13:57):

I think it's the one I like the most of the options discussed here, but I'm also ok with "effectful".

view this post on Zulip Anton (Sep 20 2024 at 17:31):

My reasoning was that "impure" function sounded unnecessarily judgmental

I like "not pure"

view this post on Zulip Sam Mohr (Sep 20 2024 at 17:32):

Or non-pure if it needs to be a one-word adjective

view this post on Zulip Brendan Hansknecht (Sep 20 2024 at 17:32):

Agus Zubiaga said:

It might be different for native speaker, but at least to me, "procedure" always sounded like a series of instructions that may affect the world. As opposed to a "function", which we learn from math to be more of a mapping from input to output.

For me I think the issue with procedure is that it just feels like only output is importat. When arguably input from the world is the more important part in terms of guarantees.

view this post on Zulip Dan G Knutson (Sep 21 2024 at 03:11):

I remember a clojure person using the terms "calculations" (pure) vs "actions" (impure). To me, it has the benefit that reading from outside the program sounds more like an action, but then 'calculation' requires some "but not just math" explanation.

view this post on Zulip Sam Mohr (Sep 21 2024 at 05:31):

Functions and actions are a good approach, it doesn't require qualifying the function type

view this post on Zulip Johannes Maas (Sep 21 2024 at 06:31):

I think the term pure might also not be helpful, because it just says "this is what a function is actually supposed to be, mathematically" and then you need to find an adjective that says "this is not an actual mathematical function".

So since this is about dependencies being explicitly listed in the arguments versus implicitly used in the body, here might be some other word pairs that I don't think I've read in this thread:

Another option:

I hope there are some new ideas for you in there. :wink:

view this post on Zulip Anton (Sep 21 2024 at 08:05):

I like "closed vs open", feels very intuitive.

view this post on Zulip Syntax (Sep 21 2024 at 15:54):

Hello, new here. I would like to add in 'Strict vs Compliant' functions as an alternative.

view this post on Zulip Anton (Sep 21 2024 at 16:28):

Welcome @Syntax :)

view this post on Zulip Der Schutz (Sep 21 2024 at 16:48):

Why wouldn't a non-deterministic function also be an effectful function? In Koka, the "pure" function would mean a function with 0 effects, whereas a non-deterministic function would have 1 effect called 'ndet'.

view this post on Zulip Isaac Van Doren (Sep 21 2024 at 17:27):

Yeah I personally am very content with calling impure functions effectful

view this post on Zulip Richard Feldman (Sep 21 2024 at 19:08):

I think the bar should be higher for terms that aren't used this way anywhere else

view this post on Zulip Richard Feldman (Sep 21 2024 at 19:09):

years ago, before "pure function" was mainstream in the JavaScript community, I tried to make "stateless function" happen in the hopes that it would be more intuitive for people to understand

view this post on Zulip Richard Feldman (Sep 21 2024 at 19:09):

it absolutely did not take, even a little bit :sweat_smile:

view this post on Zulip Richard Feldman (Sep 21 2024 at 19:10):

but eventually "pure function" became mainstream in that community

view this post on Zulip Richard Feldman (Sep 21 2024 at 19:10):

so I think "pure function" as one of the two terms is a very strong frontrunner, and the bar would be high for any choice other than that

view this post on Zulip Richard Feldman (Sep 21 2024 at 19:11):

but I don't think there is a mainstream term for the opposite

view this post on Zulip Richard Feldman (Sep 21 2024 at 19:11):

like I don't hear people talking about "impure functions" all the time for example

view this post on Zulip Niclas Ahden (Sep 21 2024 at 20:18):

It could be called a "free function" in the sense that a pure function is restricted in what it can do, while a free function can do whatever it wants. That way both terms have a word with positive connotations. No strong feelings about this, just spitballing.

view this post on Zulip Niclas Ahden (Sep 21 2024 at 20:25):

Richard Feldman said:

like I don't hear people talking about "impure functions" all the time for example

ditto. I do hear people talking about "effectful" functions sometimes though, but they don't necessarily mean an impure function. They usually mean a function that "does something" like database calls, API calls etc. Perhaps that's close enough.

view this post on Zulip Sam Mohr (Sep 21 2024 at 20:38):

Free is a good term because it captures that the function isn't guaranteed to have effects, it's just free to do them

view this post on Zulip Jasper Woudenberg (Sep 21 2024 at 21:17):

I like 'active function' that was mentioned before. Bit vague, but I think evoking the right intuition.

Alternative on 'free function': 'unconstrained function'.

"functions without borders"

view this post on Zulip Ayaz Hafiz (Sep 21 2024 at 22:24):

I think either impure or effectful is fine. The nice thing about impure is that it very clearly defines that it's not pure. I don't feel that either pure or impure have a value judgement to them. I'm not sure why someone would think there is a value judgement

view this post on Zulip Sky Rose (Sep 22 2024 at 00:14):

The problem with "impure" is that to someone who knows English but not functional programming, "impure" means unclean or subpar. It makes it sound like impure functions are something to be avoided, like if you write them you're not a good enough programmer to write good pure functions.
It's possible to teach that it doesn't have that judgement in this context, but the word choice wouldn't help.

view this post on Zulip Sky Rose (Sep 22 2024 at 00:25):

I like "effectful". It's a little weird to say that something like Time.now has an effect when nothing in the outside world changes, but I think that's easy enough to teach: From the language's perspective, a function that reads from the outside world needs the same care as one that causes an effect (because of caching, fragile tests, platform support, etc), so it makes sense to group them together and treat them all as if they're "effectful (programming term)", whether or not it actually has an "effect (English word)".

view this post on Zulip Brendan Hansknecht (Sep 22 2024 at 21:31):

We also could slightly modify effectful or add an extra word for clarification.

For example:

Maybe some minor change from effectful could be the most clear.

view this post on Zulip Luke Boswell (Sep 22 2024 at 22:15):

effectable :laughing:

view this post on Zulip Richard Feldman (Sep 22 2024 at 22:30):

effectalicious :yum:

view this post on Zulip Johannes Maas (Sep 25 2024 at 15:16):

I've just stumbled onto the term "operation" in the book Domain-Driven Design (chapter 10, section "Side-Effect-Free Functions").

It's not really used as the opposite of pure functions, but while reading I had to think of this discussion.

If we don't want to switch the noun, maybe it could be an operating function?

view this post on Zulip Eli Dowling (Sep 29 2024 at 06:30):

I'd like to suggest "non-pure".
I don't think it really has negative connections like impure. But also it avoids the "Getting time isn't really effecting things " issue.

Plus for people coming from other functional languages it's immediately obvious.

view this post on Zulip Mert Torun (Sep 29 2024 at 10:09):

Though my favorite is "contextual"
(or maybe "contextful") so far, one other suggestion could be "integrated", as it technically has to work within a certain setup/environment.

However, "impure" (or "non-pure") has the advantage that you don't have to learn the connection between two terms.

view this post on Zulip Hannes (Sep 29 2024 at 14:44):

Mildly off topic, but this made me think of a common question in the Julia forums which is "How can I write a macro to do this?" with the answer often being "you don't need to use a macro, this could be a function". Maybe if macros were called something more scary like "complex functions" it would be more obvious to beginners that they should prefer writing functions if possible :thinking:

view this post on Zulip Johan Lövgren (Sep 29 2024 at 15:40):

Eli Dowling said:

I'd like to suggest "non-pure".
I don't think it really has negative connections like impure. But also it avoids the "Getting time isn't really effecting things " issue.

Plus for people coming from other functional languages it's immediately obvious.

Huh. I like this actually. Being pure is like a property. Functions can fulfill the constraints and be pure, or they are not pure. So -> and => both refer to functions, but -> signify functions that are pure and => signifies a regular function, that is not pure.

view this post on Zulip Brendan Hansknecht (Sep 29 2024 at 17:04):

a regular function, that is not pure

I'm not a fan of that connotation. In a language like roc, pure functions really should be the default. So pure functions should be considered the regular functions. Or at least some sort of even split.

I'm overall not a fan of not pure/non-pure. It really doesn't tell you the why. It just leaves things blank.


Though my favorite is "contextual"

I think "context" is too overloaded of a term in software. Everything has a context that is runs in. A web request (and lots of other code) often has an explicit context variable that is passed in. All of that is totally unrelated to effects.

view this post on Zulip Johan Lövgren (Sep 29 2024 at 18:03):

That is fair.

view this post on Zulip Johan Lövgren (Sep 29 2024 at 18:05):

It seems very difficult to find a great word that is not overloaded (like “contextual”), or not too inert (like “procedure”)

view this post on Zulip Brendan Hansknecht (Sep 29 2024 at 18:10):

Yeah, probably. Likely we'll just have to pick something that fits well enough at some point. That or leave it at the status quo of effectful.

view this post on Zulip Kasper Møller Andersen (Sep 30 2024 at 07:44):

In terms of negative connotations of being "pure" versus "impure", maybe there are other terms with less connotations attached? Like "fixed" versus "unfixed", "restricted" versus "unrestricted", "hard" versus "soft", and so on.

view this post on Zulip Anton (Sep 30 2024 at 09:16):

I like "restricted" versus "unrestricted"

view this post on Zulip Eli Dowling (Sep 30 2024 at 23:17):

I would probably prefer constrained/ unconstrained, slight difference, I think constraint is a nicer word than restriction. But I actually quite like the suggestion.

Another path I really like is" deterministic"/"nondeterministic". I think that's very descriptive about what the actual issue is with impure functions.

view this post on Zulip Eli Dowling (Sep 30 2024 at 23:23):

Like if I saw that as a new user Id think "well I'd like most of my functions to be deterministic, that would make my program easier to reason about"

None of the other suggestions, even put/impure quite reach that

view this post on Zulip Brendan Hansknecht (Sep 30 2024 at 23:27):

I really like is" deterministic"/"nondeterministic". I think that's very descriptive about what the actual issue is with impure functions.

Oh wow, yeah, that does sound really good.

view this post on Zulip Sam Mohr (Sep 30 2024 at 23:45):

I think it's very descriptive, it's just not very catchy. If "effectful" was less clunky, then we'd probably not be having this discussion. I think something simple is important to aim for

view this post on Zulip Tod Gillespie (Oct 01 2024 at 04:29):

“Wild” might signal unpredictability and external influence without being negative or clunky. Balances well phonetically against “pure”, and you have the option of “tame”

view this post on Zulip Isaac Van Doren (Oct 01 2024 at 14:23):

I think deterministic/non-deterministic should be avoided because lots of impure functions are still deterministic.

view this post on Zulip Kasper Møller Andersen (Oct 01 2024 at 14:58):

Maybe functions being “open” and “closed” communicates it well enough? It’s succinct, and it’s pretty similar to impure/pure and unrestricted/restricted, without any negative connotations in my mind at least.

view this post on Zulip Richard Feldman (Oct 01 2024 at 15:20):

just to reiterate:

Richard Feldman said:

so I think "pure function" as one of the two terms is a very strong frontrunner, and the bar would be high for any choice other than that

I'm not saying it's impossible, but so far I don't think anything other than "pure function" has come remotely close to this bar :big_smile:

view this post on Zulip Richard Feldman (Oct 01 2024 at 15:21):

maybe a useful heuristic might be: if in the tutorial we're going to end up saying "______ functions are pure functions, we just call them something else" then a natural beginner question will be "why don't you just call them pure functions like everyone else does?"

view this post on Zulip Richard Feldman (Oct 01 2024 at 15:25):

(and to reiterate the point at the beginning of the thread, if there were already a term everyone used for "function that isn't pure" then we'd just use that and there wouldn't need to be a discussion!)

view this post on Zulip Richard Feldman (Oct 01 2024 at 15:26):

maybe another way to say what I'm thinking here: I notice we have a lot of suggestions of paired terms, where one part of the pair is not "pure function" - and I don't think that's what we're going to want here

view this post on Zulip Kasper Møller Andersen (Oct 01 2024 at 15:40):

So the objective is basically to find a synonym for “impure”, which doesn’t have negative connotations. I think calling them “open” functions is a decent term in that case. I see “open” as meaning the function has an “open door” to the outside world. It doesn’t say anything about how the function might use that access, but simply that it’s there. Though “open” still pairs better with “closed” than with “pure”, but it’s not a terrible match at least.

view this post on Zulip Sam Mohr (Oct 01 2024 at 18:01):

Richard Feldman said:

maybe another way to say what I'm thinking here: I notice we have a lot of suggestions of paired terms, where one part of the pair is not "pure function" - and I don't think that's what we're going to want here

Because of the bar placed here with "pure" being so established, I think there are two groups of solutions that could be work instead of the current null hypothesis of keeping "pure" and "effectful":

  1. We find a term that pairs well opposite of "pure", which we have plenty of examples for in this thread
  2. We use the mathematical term "function" to mean "pure function" and pair it opposite something else to mean impure function, e.g. "action", "procedure", etc.

view this post on Zulip Sam Mohr (Oct 01 2024 at 18:02):

I lean towards the second group of solutions because I think concision for these kinds of concepts is really important, but maybe that's just me.

view this post on Zulip Kasper Møller Andersen (Oct 01 2024 at 18:05):

Thinking more about the “open door” metaphor, I really like the idea that, when calling such a function, you have to add the ! to actually open the metaphorical door :big_smile:

view this post on Zulip Sam Mohr (Oct 01 2024 at 18:06):

Very Kingdom Hearts, yes

view this post on Zulip Nathan Kramer (Oct 01 2024 at 23:42):

Could we call an impure function an “effect”?
More succinct than “effectful”.

view this post on Zulip Nathan Kramer (Oct 01 2024 at 23:54):

possible downside of conflating the actual underlying effect with the function(s) that trigger it though.

view this post on Zulip Nathan Kramer (Oct 02 2024 at 03:17):

Or maybe an “activity”? I quite like the previously suggested “action” as well

view this post on Zulip Eli Dowling (Oct 02 2024 at 15:05):

Alternatively, lean into the negative connotation! Havingtainted functions sounds extremely cool :laughing:

view this post on Zulip Bryce Miller (Oct 14 2024 at 11:54):

Effectful doesn’t seem too bad to me. If a function can go from “I could do effects, but I actually just read global state,” to “now I am actually doing effects” without any change to the type signature, seems reasonable to just assume they all do effects unless we look at the definition.

view this post on Zulip Dan G Knutson (Oct 14 2024 at 14:13):

The two kinds of function are "effective" and "ineffective"

view this post on Zulip Sam Mohr (Oct 28 2024 at 19:46):

So, do we have a sense of what we want to move forward with here? There are tons of good ideas, and I don't sense that any one of them is that much stronger than another, but we do have the purity inference PR in review and it has picked "pure" and "effectful" in both the compiler code and the reported error messages.

view this post on Zulip Sam Mohr (Oct 28 2024 at 19:47):

We can always change it later, but it'll be easier to do it now while we have the set of code referencing this concept localized to a single PR

view this post on Zulip Sam Mohr (Oct 28 2024 at 19:47):

I'm personally happy with pure/effectful, but thought I'd kick this can to get the feeling from others

view this post on Zulip Brendan Hansknecht (Oct 28 2024 at 20:12):

I like pure and effectful best currently

view this post on Zulip Brendan Hansknecht (Oct 28 2024 at 20:13):

Deterministic and non-deterministic being probably the most descriptive otherwise (but a lot longer to type).

view this post on Zulip Johan Lövgren (Oct 28 2024 at 20:34):

Pure and effectful do feel like they will require the least work as they are already quite established

view this post on Zulip Sam Mohr (Oct 28 2024 at 21:13):

Okay, glad to see consensus!

view this post on Zulip jan kili (Oct 28 2024 at 22:53):

+1 to "free" and "open"

view this post on Zulip jan kili (Oct 28 2024 at 22:53):

What do y'all think about "loose"? (I only skimmed this thread just now; sorry if derailing.)

view this post on Zulip Sam Mohr (Oct 28 2024 at 23:19):

Loose makes sense to me, and so do lots of other candidates here, but for a number of reasons described above, pure/effectful is pretty well established and would be hard to overcome

view this post on Zulip Brendan Hansknecht (Oct 28 2024 at 23:22):

I think "it's a loose function" isn't really clear at all to what it could mean. Some other words feel like they have clear meaning as standalone, but "loose" feels too generic.

view this post on Zulip Eli Dowling (Oct 31 2024 at 11:20):

I would argue that loose is too loose a term to be using for this case ;)

view this post on Zulip witoldsz (Nov 01 2024 at 10:59):

What a read... I would argue the "action" (or the "action function") would be: short, descriptive, but also the word "action" (in opposite to e.g. "loose") is very common in many languages other than English.

view this post on Zulip Sam Mohr (Nov 01 2024 at 11:03):

I don't really want to open this can of worms again, buuuut I think that's one of the only pair of candidates that still would be worth considering: "functions" and "actions" are both very simple terms that are fun and mostly self-explanatory

view this post on Zulip Sam Mohr (Nov 01 2024 at 11:04):

And also they're one word each, which is a huge plus in my mind

view this post on Zulip Sam Mohr (Nov 01 2024 at 11:04):

But... I don't know how high the bar is to replace "pure" and "effectful", though I expect it's pretty high

view this post on Zulip Fritz Psiorz (Nov 01 2024 at 18:15):

Niclas Ahden schrieb:

It could be called a "free function" in the sense that a pure function is restricted in what it can do, while a free function can do whatever it wants. That way both terms have a word with positive connotations. No strong feelings about this, just spitballing.

"Free" could also be interpreted the opposite way pure: It's free from side effects, you can freely call it without having to worry about any side effects, it's not "attached" to the outside world through side effects.

view this post on Zulip Brendan Hansknecht (Nov 01 2024 at 19:44):

I think action is ok for a short explainable term. Though there are a lot of non-active simple input reading and caching style functions that would be effectful.

view this post on Zulip Brendan Hansknecht (Nov 01 2024 at 19:45):

But action vs function/calculation are pretty reasonable.

view this post on Zulip Eli Dowling (Nov 02 2024 at 02:10):

I don't mind action, but pairing it with function feels bad to me. Given every other language I know of would call both of those things functions, I feel you need a different word. Calculation isn't bad though.

Still, at this point, I think pure and effectful is fine.
I particularly like efffectful because with the purity inference changes, roc is doing effect tracking. Which is a fairly standardized term. A user can search "effectful function" or "effects" and immediately read about the underlying concepts.

I think picking standardized names for things helps us lean on existing learning resources which can aid learning and deeper understanding.

Eg: If I come from ocaml and I see roc has effectful functions I immediately understand that.

view this post on Zulip Brendan Hansknecht (Nov 02 2024 at 02:26):

Yeah

view this post on Zulip Brendan Hansknecht (Nov 02 2024 at 02:27):

I don't think anything beats out the ubiquity of pure. And effectful is not as ubiquitous, but it is semi-common

view this post on Zulip jan kili (Nov 02 2024 at 02:27):

Actions and calculations reminds me positively of my Redux/Vue/Vuex days in 2015-16 ~ actions to change state, calculated values that update smoothly.

view this post on Zulip jan kili (Nov 02 2024 at 02:29):

Perhaps presenting it like this would be friendly:
"There are two kinds of functions - calculations and actions. Calculations are pure functions... Actions are effectful functions..." so then both names act as single-word aliases for those standard-ish concepts.

view this post on Zulip jan kili (Nov 02 2024 at 02:34):

It would likely spend some weirdness budget, but it's usually good to give short nicknames to top-priority concepts, and this would call attention to it being an code-impacting distinction instead of just an attribute/remark.

view this post on Zulip jan kili (Nov 02 2024 at 02:42):

Tangential: Assuming the word "effectful" will be used at least somewhere in Roc's docs: As Task seemingly moves behind the scenes, would it make sense to rename it as Effect to match? Or is that name used for something behind Task already? Sorry if this is already well explained and I just need to re-read docs.

view this post on Zulip Brendan Hansknecht (Nov 02 2024 at 03:14):

Task is fully going away

view this post on Zulip Brendan Hansknecht (Nov 02 2024 at 03:14):

The equivalent will be effectful functions that return results

view this post on Zulip Brendan Hansknecht (Nov 02 2024 at 03:16):

There is still the hosted module, but we will just say that it is for platforms to define their effects (or o guess actions if we use that terminology)

view this post on Zulip Derin Eryilmaz (Nov 02 2024 at 20:34):

"Dependent function" maybe (?) because they depend on something else (usually outside of roc) to work
You can also say dependent as in "what does this function return? it depends..."
Whereas independent functions are pure functions, ones that can run on their own.

view this post on Zulip Tanner Nielsen (Nov 03 2024 at 16:30):

In the spirit of spending our collective brain energy on bigger issues, I'd vote to resolve this topic to discourage further bike shedding. The terms "pure" and "effectful" seem to have stuck.

view this post on Zulip Dan G Knutson (Nov 03 2024 at 16:54):

Having brought up the 'action' thing, I agree. I think the bar for not saying 'pure/effectful' as the default is real high. It's more beginner-friendly to allow people to compare with concepts they'll find in other places than to have the best terminology in a vacuum. There's still a place for other terms in 2nd or 3rd party docs & explainers, but the default terms in the main docs should be searchable.

view this post on Zulip Notification Bot (Nov 03 2024 at 19:19):

Luke Boswell has marked this topic as resolved.


Last updated: Jun 16 2026 at 16:19 UTC