Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. Revealing the details of how OpenAI agents hacked Hugging Face (swarmtraces.org)
    273comments
  2. A single function Jev-like wrapper for LLMs, including vision models (allanrbo.blogspot.com)
    7comments
  3. Plan mode is dead (aymannadeem.com)
    255comments
  4. Ollaya – Ollama for open-source, Jev-style decision models (ollaya.dev)
    114comments
  5. Show HN: Jev Plays Pokémon Red (jev-pokemon.vercel.app)
    82comments
  6. What even is an OS now? (sockpuppet.org)
    266comments
  7. The Murky History of Soviet-Born Tetris (mitpress.mit.edu)
    9comments
  8. Postgres SELECT DISTINCT Does Not Scale (dbos.dev)
    20comments
  9. How I changed teaching after AI managed to do all my homework assignments (thelastsoftwareengineer.substack.com)
    17comments
  10. Jury finds Facebook liable for deceiving users in Cambridge Analytica case (cbsnews.com)
    44comments
  11. A new world airport and its baggage (computer.rip)
    1comments
  12. Gravity seems holographic. What does that mean for reality? (quantamagazine.org)
    161comments
  13. Fourier Analysis: Drawing Llamas with Circles (adekau.github.io)
    2comments
  14. Scientists build most accurate atomic clock (phys.org)
    2comments
  15. One Piece of Flock Camera Data Put This Innocent Woman in Jail for 13 Days (jezebel.com)
    65comments
  16. Show HN: Hacker Atlas - A map of what Hacker News talks about (hackeratlas.com)
    14comments
  17. Excel now supports multiple values in a single cell (techcommunity.microsoft.com)
    119comments
  18. We're gonna need a lot more mathematicians (terrytao.wordpress.com)
    91comments
  19. Two and a half years without a gallbladder (tracydurnell.com)
    22comments
  20. Lab on a Contact Lens Can Measure Stress Through Serotonin (ieee.org)
    6comments
  21. HomelabFest will be in St. Louis in September 2027 (homelabfest.org)
    11comments
  22. First Principles Thinking (sunilsadasivan.com)
    107comments
  23. I wrote a ray tracer in Brainfuck (epestr.com)
    15comments
  24. Remembering Johannes Doerfert (llvm.org)
    2comments
  25. U.S. appeals court upholds designation of Anthropic as supply chain risk (cnbc.com)
    757comments
  26. How video games inspire great UX (2019) (jenson.org)
    17comments
  27. Microsoft abandons personal AI chatbot race with Copilot reboot (bloomberg.com)
    109comments
  28. Alberta's image as world's only rat-free region shattered by discovery of rat (theguardian.com)
    1comments
  29. How we learned to stop worrying and love campus surveillance (fnl.mit.edu)
    110comments
  30. What happens when you analyze your favorite college football team like the CIA? (cultivatelabs.com)
    33comments

Deterministic Core, Non-Deterministic Shell

57 pointsby 5d agooutdata.net
17 comments
5d agoHN ↗

great work the world needs more of this!

5d agoHN ↗

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.

4d agoHN ↗

Anything you can do with ""real"" randomness can be done just as well with a seeded [CSP]RNG, including DoS prevention if you can keep the seed secret.

If you really want true RNG, you can inject a deterministic RNG at test-time and use a real one otherwise.

4d agoHN ↗

Easily circumvented: Generate a random seed in the shell and pass it to the core.

4d agoHN ↗

Great, that’s the ideal case. But in many languages and many libraries it is all but impossible to pass on a seed to everything that uses randomness, unless you control all these libraries.

That’s why as a matter of practicality I’d advocate otherwise.

5d agoHN ↗

This split is familiar from Temporal.io: workflows are deterministic while activities are idempotent.

4d agoHN ↗

I wonder if languages could and should allow enforcing both properties.

4d agoHN ↗

For frontend web development, Elm enforces a pure core (pure > deterministic).

4d agoHN ↗

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.

4d agoHN ↗

I have been trying to tell the folks at work the same thing. Ideally, using a language that goes in that direction. For frontend web development, for example, there is Elm, which is pure and functional.

4d agoHN ↗

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.

4d agoHN ↗

Correct. FCIS is about testing. Testing pure code is a lot easier than testing impure code, but most of what you want to implement can be done with pure code, and you can isolate the impure code to a shell that can be tested apart from your pure business logic.

4d agoHN ↗

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.

4d agoHN ↗

Sounds very similar to the "interpreter" or "virtual machine" pattern (can't recall the exact name).

But essentially a component receives a list of high level instructions / description of what the user wants done, and it translates that into descriptions of "lower level" commands that should be performed. And those commands then get executed separately.

Anythinf statefule / io is contained in the commands and can be tested easily with external dependencies. And the complex logic is all pure in decided what to do and how to do it based on what was asked for.

4d agoHN ↗

FCIS is basically that. You don't need an interpreter/VM, but that is an option.

4d agoHN ↗

Its interpreters all the way down. Going up the stack is finding the right Domain Specific Language to describe the self modifying sociotechincal business process computer that is capitalism

4d agoHN ↗

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:

    function add(ns) {
        let total = 0
        for (const n of ns) {
            total += n
        }
        return total
    }

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

https://ericnormand.me/podcast/what-is-an-action

https://livebook.manning.com/book/grokking-simplicity/chapte...