r/ProgrammingLanguages • 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...

27 Upvotes

74 comments sorted by

View all comments

Show parent comment

2

u/Inconstant_Moo 🧿 Pipefish Aug 08 '26

The pure functions don't reach up: the commands pass the data down, and you structure your code like that.

If your otherwise-pure computation needed an arbitrary and unforeseeable amount of random numbers then you would have to write some sort of loop in the calling command so it could say "not finished yet, need more random", and some way to continue it, and that would be a mess.

Similarly with other stateful things. This would make it a terrible fit for e.g. a systems language (which it couldn't do anyway without a heck of a lot of work) but it makes it a good fit for data-oriented stuff where we want stateful things to be tightly bound to requests from users/clients saying "do this stateful thing".

I do have plans to do a rand library in a more functional style. There are functions which instead of working iteratively can just tell you what the nth random number is, and that would seem like a good basis for a library.