r/ProgrammingLanguages • u/baehyunsol Sodigy • Jul 29 '26
Purely functional language with impure script language?
I'm working on a purely functional programming language named Sodigy. It's all about evaluating values, not "executing commands one by one".
It's nice when writing libraries, but it's not easy to write a main function. The main function is supposed to execute commands, but the Sodigy's syntax is not friendly to write a list of commands.
So what I'm trying to do is, 1) Sodigy remains purely functional and 2) add a bash-like script language. The script language can call Sodigy functions. Instead of writing a main function in Sodigy, you write sodigy-script and execute the script.
Has anyone tried similar approach? I'm not sure whether it's a good idea or not...
View all comments
2
u/mamcx Jul 29 '26
Think more deeply: What actual difference is between the 2?
Look at your AST:
(probably like:)
IF you have this, you have a expression based language. What you need to make it "imperative"?
Then your syntax to make the illusion.
Why I pointing this so obvious? Because "imperative" IS NOT IMPURITY.
"impurity" and "mutation, side-effects, etc" are else that arise when you plug into a environment where you have not FULL control, then NOW, you need to account for it.
(if you were doing forth from scratch in assembler you see that)
You can add "pure functional" into a "impure stateful" world, is only matter of how BIG your fiction is, like:
A SUPER IMPURE FUNCTIONAL PURE PROGRAM
So, the ONLY question is:
Do you wanna to surface the reality of "impurity" or not? Because you can just make all IO and HTTP "pure" (example: https://witheve.com). (I mean, how much be can be pedantic here, but I see a lang like this and think that is the feel, ok?)
To recap:
You can do 100% "functional" language that totally can do IO and terminal things with zero imperative functionality.
Impurity/purity is not derived by functionality or imperatively but by environment
HOW you communicate both things is a big deal, but you can go any directions, others has done the same!