Join the discussion
Write your take first — we'll ask for email only when you're ready to publish.
- Hacker News
- great work the world needs more of this!
- I've been pondering something I call "slop core, artisanal shell", as a way of keeping vibecoding under control. Slop core might sound like the thing you want to avoid, but as long as it's purely-functional (or perhaps, merely deterministic) it should be robustly testable. The "artisanal shell" keeps the thing human-understandable and human-modifiable, as long as you put some thought into the API boundaries.by Retr0id
- This split is familiar from Temporal.io: workflows are deterministic while activities are idempotent.by consuming2
- If you want to avoid the word 'functional' then say pure: pure core, impure shell. Or maybe: pure core, I/O shell. Otherwise it's too long :)
Idk. I like Gary's formulation. No, I love it. One time when designing an STS with Claude I told it my FCIS design for an STS and Claude demonstrated real excitement -- it really loved the idea.
Briefly, my idea was to have the functional core isolated such that it receives a JSON description of the input request, any additional data [wait for it], and outputs either: an error, a request for more data, or a description of a token/credential to issue and with what issuer credentials. This would allow one to write all the core logic in Julia, JS, MicroJS, jq even, any language you like, and the imperative shell is what does all the rest (authentication, token validation, database lookups -- whatever you want). I swear Claude expressed real excitement over this. I've seen Claude be frustrated as well. It really does seem to have some sorts of emotions.
by cryptonector - I agree with the thrust of the article but I want to quibble with one thing: the article says “calling RNGs that aren't seeded” doesn’t count as deterministic behavior, but randomized algorithms often have simpler implementations and better asymptotics than non-randomized algorithms while having statistical guarantees (“almost surely”) on their properties. Two of my favorite examples: (1) a randomized quicksort where choosing the pivot randomly in each iteration is simpler and better than deterministic methods of choosing the pivot; (2) a randomized treap gives you a balanced binary search tree with far simpler implementation than say a red black tree. And that’s besides the more utilitarian security benefit of using randomness inside hash functions to protect against HashDoS attacks.
So I’d implore the author to delete this restriction. Even when randomized algorithms produce different outputs (the treap giving you differently shaped trees with the same sequence of inserts) these outputs have properties that can be checked statistically.
by kccqzy - I think actions vs calculations is a better framing here. It's not just about avoiding imperative code or nondeterminism. It's about being extra careful with actions because the order and number of times they run matter.
Here is an example of a calculation written imperatively. It remains easy to reason about because the actions don't leak out of the function:
On the other hand, a deterministic state machine like `a = AddMachine` is harder to reason about because it still matters how many times the action `a.transition(1)` is called. (Note it is possible to implement the state machine as calculations.)function add(ns) { let total = 0 for (const n of ns) { total += n } return total }https://ericnormand.me/podcast/what-is-an-action
https://livebook.manning.com/book/grokking-simplicity/chapte...
by Leftium - I think the main insight from "functional core, imperative shell" is more about structuring the code so as to be easy to test.
Without that structure, code tends to be difficult to test, since the impure stuff like network requests is part of the same sequence of statements as the logic you want to test. (That is: pure code is easier to test (but harder to write real programs with).. so, "arrange the code so you've got a well tested core" is a good strategy).
The nice part about the pure/functional is that you know for the same inputs, you always get the same outputs. -- I think if you want to say, "well, this stateful object is still pure (if you consider the state part of the input" then sure, I guess.
by rgoulter