Re:Simplify Your Code: Functional Core, Imperative Shell
by js8 on Tuesday October 28, 2025 @01:45PM
(#45736188)
Well you can claim that the core is the programming language, in which we write those tax rules, but that's not a very useful distinction IMHO (for how to write programs in the language).
Re:Simplify Your Code: Functional Core, Imperative Shell
by Izkata on Tuesday October 28, 2025 @02:13PM
(#45736635)
That's only the case where a usable generic core already exists. A great example where it didn't exist is python's "requests" library: https://requests.readthedocs.io/en/latest/
The example on the homepage is the "specific shell" - simple and easy to use, and by far the most common usage, but if you scroll down the table of contents on the API page (https://requests.readthedocs.io/en/latest/api/) you'll see sections titled "Lower-Level Classes" and "Lower-Lower-Level Classes" - that's the generic core, which the upper level is implemented in terms of.
Re:Simplify Your Code: Functional Core, Imperative Shell
by Twisol on Tuesday October 28, 2025 @02:47PM
(#45737074)
I like this example :) Another good example might be Git's distinction between "porcelain" and "plumbing"; the porcelain is implemented in terms of the plumbing, and gives a nicer* interface in terms of what people generally want to do with Git, but the plumbing is what actually does all the general, low-level stuff.
* opinions vary
As someone who does this himself for taxes, you're looking only at the "specific shell" part. The generic core is the thing that does the math - spreadsheet, database, whatever. The tax rules are then imposed on top of that core.