from Hacker News

Truth Functional Logic for Hackers

by ChilledTonic on 3/11/25, 6:30 PM with 14 comments

  • by mcguire on 3/11/25, 7:14 PM

    The important part is at the end of the article: "For those interested in building a stronger foundation in logic, the Open Logic Project provides excellent free educational resources on propositional and predicate logic, formal proof systems, and other topics such as modal logic and set theory - all targetted towards a non-mathematical audience."

    https://openlogicproject.org/

  • by tantalor on 3/11/25, 6:52 PM

    I don't get it. Isn't this what compilers are for? So I don't have to rewrite my code in an equivalent but stupider way just to get a marginal performance gain.
  • by nvader on 3/11/25, 10:53 PM

    In this blog article from 2021, I warn about making this change without appropriate care, as it has been a source of common bugs: https://danverbraganza.com/writings/de-morgans-flaw-perform-...
  • by hoppp on 3/11/25, 10:37 PM

    My first thought was to rewrite it without any or and operation. just return early from if statement.

    If user is blacklisted return access denied; If account is expired return access denied; If no conditions match return access granted;

    Wouldn't that be more effective?

  • by lucaspauker on 3/11/25, 7:45 PM

  • by cluckindan on 3/11/25, 9:15 PM

    The code blocks’ font size varies line by line on mobile. Hint: set it to be smaller than the body text size because monospace fonts tend to be a bit larger than proportional ones.