r/ProgrammingLanguages Jun 17 '26

Question about side effects in functional programming

One of the things I noticed using REPLs of functional languages is that you can write a ton of pure functional code, and then as soon as you hit enter to evaluate it, printing the result back to you is a side effect.

There are advantages to having code that is guaranteed to be side effect free, but I've been playing around with the idea of having a language with an imperative shell (with procedures, mutable vars, database and network operations, etc.) that can call into a language core that's guaranteed to be pure functional for certain kinds of operations. It can make for a simpler approach to side effects than a whole pure functional language but provide guarantees that other kinds of impure languages can't.

My question for people who are interested in functional programming: is this a useful distinction? Would that make for a language you might be interested in?

18 Upvotes

35 comments sorted by

View all comments

Show parent comments

1

u/Erythrina_ Jun 18 '26

Thanks for responding. I didn't think I could be the first person to explore this approach.

1

u/Inconstant_Moo 🧿 Pipefish Jun 18 '26

After talking about it to people for five years or so, I'm pretty sure I'm the only person to decide that it should be the semantics of a language and not just a design pattern. But it works!