I have been writing higher-order functional programming in Python for the last few weekends:
- hofppy (https://github.com/equational/hofppy) will be a Python library. For the moment it is a collection of Jupyter notebooks.
- My initial goal was to have a handy FP toolkit which supports applied math with JAX's JIT. Yet I realise that in fact what I am really doing is reimplementing the generic part of a compiler for a reactive (trading) language I wrote in 2010 in F#, while including a few tricks I picked up since then, the primary one being to think of code as implementing a synchronous execution model.
- There is really very little code like this on the web, therefore why I am doing this open source.
This blog is in part written to mention the above, as already the first JAX JIT supporting monad and comonad models are "nice". Yet this blog is also to bring up the subject of the process of creating new technology.
My recipe to do something new, such as lead a team on a new subject, write software that did not exist before is the following:
- Create a "mind's eye" imaginary world of "usage" of the end result.
- Imagine how it should work.
- Start very quickly to implement features.
- Review 1, 2, and 3, as you regularly cycle through them, again, again, and again!
- Lazy software design are easier express in code.
- The most flexible design, is the code that does nothing but accumulates lazily what it could do, until finally because output is expected, it works backwards from output expectations to pull out the desired output.
- Multi-stack semantics is perfectly normal.
- For example, in the project's above monadic code, the free monads have "their" variables, "normal" Python has its variables, and these are carefully kept separate.
- Multiple flows of causality exist in the real world, stacks of various semantics is the only cheap way to capture these cleanly in software.
- For every Ying, there is a Yang.
- If there is more, there is also less; If there are variables, there are constraints, etc.
- Structure is more important than types.
- I started in functional programming without the types. Then I embraced types. And yet to understand that the sweet spot is somewhere in between. The reality is that it is much easier to use code to constrain software "just a right level" than to use types.
- Math is the most powerful structure.
- Think geometry, topology, and dualities!