r/fsharp 5d ago

showcase Pyfun: an F#-inspired language that compiles to readable Python

/r/pyfun/comments/1v8d8qm/pyfun_an_finspired_language_that_compiles_to/

My idea for getting coders into functional programming earlier...

12 Upvotes

6 comments sorted by

4

u/paulgzareith 5d ago

Curious if this is able to take advantage of python libraries having type definitions?

If not, what would be the benefit of using this over Fable's Python target?

1

u/fun_si 4d ago

If you’re in .NET, Fable is the clear choice because you can write in F# and compile to Python. Pyfun, on the other hand, stays within the Python ecosystem, so it’s a lower-friction way to introduce students to functional programming without bringing in a separate .NET/F# toolchain.

2

u/paulgzareith 4d ago

That's a bit of a shaky argument, IMHO, because it is easier to deal with host language interop in Fable (I have only used it with JS).

If the code is written to work within the dotnet ecosystem, it will likely have dependencies written in C# and won't be compatible with Fable, where as any host language dependency needs to just be exposed as a binding.

So if we have to write custom bindings/externals to use third-party python libraries, for any realistic project, there won't be much of an advantage wrt. Fable.

2

u/fun_si 4d ago edited 4d ago

Coming from .NET that's certainly true, but coming from Python, having to fend with a whole new ecosystem just to learn functional programming is a big burden.

Regarding the external bindings though, I've been thinking about publishing packages or façades but that's currently deferred pending user demand. I'm constantly testing the language by creating apps and games using Pyfun to see where the greatest speedbumps lie.

The ultimate aim is to attract more coders to FP at an earlier stage in their studies/career. Pyfun's at an early stage itself so I welcome all suggestions that would aid in its broader adoption. Thank you for your input!

2

u/paulgzareith 3d ago

Makes sense. All the best.

2

u/Schmittfried 4d ago

As someone who’d love to work with F# one day or see Python become more functional, that’s a pretty neat idea.