作者宣布其著作《程序员逻辑学》(Logic for Programmers)正式发布。这本书历时五年写成,向在职开发者教授形式逻辑的基础知识及其应用,包括基于属性的测试、领域建模和逻辑编程。这本书的创作初衷是当时没有面向程序员学习这些基础知识的资源,而且阅读本书不需要任何数学背景。抢先购阅读者可在 Leanpub 上免费获取 1.0 版本。
I am delighted to announce that my book, Logic for Programmers, is now available! You can check out the release site here or go directly to buy the ebook or print versions. If you bought any of the early access versions, you can get the 1.0 for free from leanpub.
This has been a long time in the making. Formal logic is an incredibly powerful tool to understand software. Everything from “what’s a left outer join” to “why shouldn’t Square inherit from Rect” makes more sense if you know just the basics of logic. Yet there weren’t any programmer-focused resources for actually learning those basics. You were just sort of expected to crack open a math book or pick it up through osmosis.
The osmosis route doesn’t work.
继续阅读全文
为了尊重作者,这里只展示开头几段。你可以去原文阅读,或者在 HorizonReader 里读:划线做笔记、让 AI 帮忙。
AI 摘要This article, adapted from the second chapter of the book Logic for Programmers, is a crash course in formal logic for programmers. It explains predicates as Boolean-returning functions that can be concrete or abstract, uses a CanRunProgram example and truth tables to show how formal logic removes ambiguity from natural-language requirements, and introduces the implication operator (=>) along with sets for constraining predicate inputs.
AI 摘要The author, writing for April Cools, argues that the classic 'Chicago vs New York pizza' debate is meaningless because deep dish is a special-occasion food while New York-style pizza is an everyday food, making them poor points of comparison. Instead, they propose comparing New York pizza to the Chicago-style hot dog as role-equivalent iconic local foods, ultimately conceding that NYP wins for ease of home preparation while praising the Chicago dog as a superior hot dog. The piece closes as a celebration of other Chicago specialties like Italian beef, the jibarito, and flaming saganaki.
AI 摘要The author shares a collection of discarded Z3 example scripts (written with Python bindings) produced while working on their book 'Logic for Programmers', explaining that Z3 is an SMT solver that finds values satisfying mathematical and programming constraints. The examples range from solving equation systems and math puzzles about equal sums and products, to optimizing annual bank deposits, reverse engineering a pseudorandom number generator's parameters, proving theorems by checking for counterexamples, and maximizing stock trade profit. Along the way, the article demonstrates Z3 features like the Optimize solver, the theory of arrays, and constraint checking with additional temporary constraints.
AI 摘要The article traces the earliest history of algebraic data types back to John McCarthy's 1961 paper 'A Basis for a Mathematical Theory of Computation,' which introduced Cartesian products and 'direct unions' along with their algebraic properties like isomorphism and distributivity. The author then follows how these ideas spread through Tony Hoare's work on data structuring in imperative languages, where 'discriminated union' was coined, and through Rod Burstall's structural induction work that influenced functional programming. Finally, the author disputes the common claim that Landin's ISWIM was the first language with algebraic data types, arguing it was merely a proposal and likely never actually defined sum types.
AI 摘要Written as part of the 'April Cools' tradition, this article recommends video games that are accessible to non-gamers, using criteria such as running on ordinary hardware, requiring no prior gaming knowledge, being culturally meaningful, and being games the author has personally seen non-gamers enjoy. The author details four picks—Baba is You, Stardew Valley, The Case of the Golden Idol, and Balatro—explaining each game's mechanics, appeal, and historical context within its genre. The piece aims to lower the barrier to entry into gaming, which despite being a half-trillion-dollar industry remains surprisingly niche compared to movies or music.