Logic for Programmers
Posted by _doctor_love 4 days ago
Comments
Comment by rmunn 4 days ago
Looking through the sample chapter, I'm reminded of my experience with symbolic logic class. It looks like it'll be much the same thing, but flipped on its head: instead of knowing programming and using that knowledge to make symbolic logic easier, this looks like it'll be about knowing symbolic logic and using that knowledge to make programming easier. Seems pretty useful; I'll give the sample chapters a more in-depth read soon.
Comment by leonidasrup 4 days ago
"In programming language theory and proof theory, the Curry–Howard correspondence is a direct relationship between computer programs and mathematical proofs. It is also known as the Curry–Howard isomorphism or equivalence, or the proofs-as-programs and propositions- or formulae-as-types interpretation."
https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspon...
Comment by layer8 4 days ago
That’s why you can have a productive programmer who is nevertheless unable to construct valid proofs.
(I’m very much in favor that programming should involve proofs as much as possible, but that’s something to strive for, not a matter of fact.)
Comment by lioeters 4 days ago
Comment by deterministic 3 days ago
Another example is CompCert (a proven correct C compiler used by Airbus and others for real production software).
Comment by WillAdams 4 days ago
He was one of only two folks I've ever met outside of TeX User Group conferences who had read _The Art of Computer Programming_ (and had a well-thumbed set of Vols. 1--3 on a shelf next to his desk) and had written (and sold commercially) an operating system and full application suite, and when asked, always had a (wonderfully documented) bit of code to apply to any problem.
Comment by random3 4 days ago
Given the volume of text philosophy wrangles, I’m not surprised TAOCP was casual =))
Comment by js8 4 days ago
I really like this: https://disi.unitn.it/~bernardi/RSISE11/Papers/curry-howard....
I think every programmer should understand the consequences of CHI to the discipline, which are profound. It means that there is no need for classical logic as a separate metalanguage, the properties of programs could also be expressed in the programming language of your choice. Furthermore, it shows that "running the program" and "reasoning about the program" are ultimately the same processes, which raises some good philosophical questions about testing for example. But also about how can we approach the program design, maybe we can just "calculate it" from the constraints. It also opens us to things such as supercompilation.
I think the discipline needs to move towards formal understanding how different programming languages and logics express similar ideas, because it's a really powerful tool of mutual understanding.
(Also, I personally find the typed LC notation, especially with type checking and inference, easier than the classical logic notation. It might be the reason why logic is considered too complicated.)
Comment by LudwigNagasena 4 days ago
What ambition? The book is an applied introduction for people who aren’t even familiar with what ∃ means. It’s 200 pages, which is at best comparable to a semester-long course.
Comment by js8 4 days ago
It kinda reminds me of the debate whether functional programming is suitable for beginners, despite being simpler than imperative, while imperative is more familiar.
I am opposed to familiarity argument (I think classical predicate logic and existential quantifier are being taught in early high school, maybe sooner, so they are more familiar than lambda calculus).
Based on my own programming and math experience, I wish I learnt about functional programming, LC, dependent types and CHI much sooner. I don't think it has to be complicated, I know some attempts (although a bit incomplete) to show this to beginners - To Mock a Mockingbird, Haskell Programming from First Principles.
Comment by LudwigNagasena 3 days ago
"Functional programming" in applied programming usually just means using less mutable state and using stuff like `map` and `reduce` to make semantics of code more predictable and move the burden of optimizing actual implicit mess it creates to compiler/interpreter.
Comment by cubefox 4 days ago
Comment by js8 4 days ago
"constructive proofs are allegedly code. They are not"
I disagree, what CHI shows is that specific language you choose matters only a little (as long as you stick to TC and have some means of compositionality).
I want programmers get to the point where they think of programming in a single unified language, of which different programming languages (and logics) are just expressions of (sometimes a bit more restrictive). I think it would enable metaprogramming (and formal methods) on an unprecedented scale.
Comment by epolanski 4 days ago
I'm not following your point, is the criticism that a book on logic is only focusing on logic?
Comment by js8 4 days ago
Comment by epolanski 4 days ago
Reading some comments in this thread is borderline depressing: half of the people complaining this isn't more abstracted and generalized mathematics and the other half complaining there's too much computer science and is not about coding only.
Which means that this book is exactly perfect for programmers interested in learning about computer science. Might be a niche, but it is a real audience.
Comment by cubefox 4 days ago
Comment by mirrorlake 4 days ago
Also, Hillel (author) has a blog that's absolutely worth checking out as well as some great conference talks which are on YouTube, he's on the short list of speakers who I automatically watch any of their talks.
Comment by Merkur 4 days ago
It seems to favor the compact and efficient kind of code that is brittle in the hand of a mildly competent junior dev, or a heavy multitasking senior.
I like smart code, in fun projects, but on the job I prefer fast to read and to reason code. Don’t try to be fancy.
So I guess that’s a book to challenge my assumptions. I like that. Thx.
Comment by jpollock 4 days ago
https://github.com/dwmkerr/hacker-laws#kernighans-law
"Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?"
Comment by dwattttt 4 days ago
I know it's explaining the joke, but you've blown past "clever" if you've reached the point where you can't debug it.
Comment by jpollock 4 days ago
Otherwise, you're the only one who can fix your code, and becomes a whole bus factor thing.
Comment by Jach 4 days ago
Comment by rswail 4 days ago
Comment by Merkur 4 days ago
Comment by rswail 3 days ago
We don't have the same level of "proven solutions" and constraints and mathematical rigor that engineering has, nor do we have the legal/liability requirements of "Professional Engineers".
I hope that I qualify as the equivalent of an artisan, like a carpenter that makes furniture, that has elements of both art and craft. Even as I've moved up (and down) the hierarchy of programmer/senior/"architect"/manager.
Programmers fit the "craftsperson/journeyperson/apprentice" model much better than engineering practice.
Comment by mjaniczek 4 days ago
Comment by cubefox 4 days ago
Comment by richardbarosky 4 days ago
Comment by gitowiec 4 days ago
Comment by Jach 4 days ago
Comment by jibal 4 days ago
Comment by rtrigoso 2 days ago
Comment by kriro 4 days ago
Alternatively hop straight into Prolog (Art of Prolog, Craft of Prolog).
Comment by fmajid 4 days ago
Comment by xelxebar 4 days ago
Proofs of incompleteness theorems, the halting problem, Rice's theorem etc. all share a diagonalization structure. The keyword here is Lawvere's fixed-point theorem[0], but it's a bit of abstract nonsense, so here's a good accessible video on the topic[1].
I'm not sure the incompleteness theorems themselves are immediately and directly applicable to software development, but I find that having several examples of diagonaization proofs bouncing around in my head makes the Lawvere structure apparent. Since proofs are just programs, the pattern is surprisingly pervasive. Futamura projections are one incarnation, which is essentially how many interpreters end up providing "compilation" of programs into standalone binaries.
[0]:https://en.wikipedia.org/wiki/Lawvere%27s_fixed-point_theore...
Comment by cubefox 4 days ago
Those are not aimed at programmers, so very different and not a replacement. Just look at the free sample on the website. Besides, incompleteness theorems are probably irrelevant for programmers.
Comment by alfiedotwtf 4 days ago
I guess I’m more mature now, so I’ll have yet another attempt… but I don’t like my chances!
Comment by nxdmum 3 days ago
Comment by foobarbecue 4 days ago
If I do "buy now," I get a strange text-only "out of stock" page.
If I add to cart and try to check out, I'm redirected to the "switch account" page, where only my currently logged-in account is listed.
I buy things on amazon ask the time and have never seen this before.
EDIT: whatever that was, it's fixed now. I was able to purchase the print book.
Comment by chris_wot 4 days ago
Comment by theusus 4 days ago
Comment by harperlee 4 days ago
This marks the completion of a project that took five years of work, six bookwriting professionals, fourteen domain experts, and fifteen public alphas.
This has been, without a doubt, the biggest and most exhausting project I've ever done. The examples in the discarded drafts alone could make a second book. The cursed knowledge I've gained on LaTeX and typography could fill a third (or at least a couple of entertaining blog posts). Self-publishing was simultaneously the worst and best decision I made.
Now excuse me I am going to sleep for a month.Comment by Obscurity4340 4 days ago
Comment by sqemo 4 days ago
Comment by fenestella 4 days ago
Comment by z0ltan 4 days ago
Comment by z0ltan 4 days ago
Comment by altmanaltman 4 days ago
Comment by Terretta 4 days ago
Is it something like .htcsjs, .hsj, or .HSJ on Windows? Or just .html?
More seriously, seems anything that can render .html handles the other two inline, so calling it HTML even with css and js in it seems fine?
Comment by altmanaltman 4 days ago