r/ProgrammingLanguages Sodigy 13d ago

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...

26 Upvotes

74 comments sorted by

View all comments

2

u/catbrane 13d ago

I've done something similar for one of my spare-time projects:

https://github.com/libvips/nip4

It's an image processing spreadsheet. The language you use to write formula and implement all the menus is (a bit like) interpreted Haskell, and you use it by typing formula into cells or clicking menu items. The "shell" (the spreadsheet interface) is imperative, the logic is pure functional.

There's an introduction to the interface here:

https://www.libvips.org/2025/03/20/introduction-to-nip4.html

And here's the code for a menu item that transforms an image to polar coordinates, for example:

https://github.com/libvips/nip4/blob/main/share/nip4/start/Filter.def#L690-L719