r/AskComputerScience • • Mar 20 '25
**"Why Is My School Teaching Boolean Algebra for Coding?"**
Hey guys, I'm not the best at coding, but I'm not bad either. MyGitHub.
I'm currently in high school, and we have a chapter on Boolean Algebra. But I don’t really see the point of it. I looked it up online and found that it’s used in designing circuit boards—but isn’t that more of an Electrical Engineering thing?
I’ve never actually used this in my coding journey. Like, I’ve never had to use NAND. The only ones I’ve used are AND, OR, and NOT.
So… why is my school even teaching us this?
================================================================================
Update: Why this post and my replies to comments are getting down-voted, is this because i am using an AI grammar fixer
17
u/JoJoModding Mar 20 '25
The school is teaching you this so that you get a better grasp of how elementary logic works. Knowing how to think about the boolean operators is a very necessary skill not just in computer science but also in everyday programming. For example, are the following two if conditions equivalent?
if x < y and y < z:vsif not (y <= x or z <= y):If you know boolean algebra, you can immediately see that these are the same due to De Morgan's rule.
Beyond that, knowing the operators helps you express your intuitive ideas about what should happen when into formal, logical statements; this is precisely what programming is.
45
u/jeffbell Mar 20 '25
It's not not part of computer science.
9
u/RodionRaskolnikov__ Mar 20 '25
Coding is just one part of computer science as a whole. There's a lot of discrete mathematics you'll be learning. A lot of problems like compilers, language interpreters, database engines or proof based logic engines like Prolog rely on these concepts to work.
5
u/AlexTaradov Mar 20 '25
There is almost no chance you have not used NAND if you wrote any meaningful amount of code. It is not an explicit operation in programming languages, but there is a chance you wrote something like this: "if (!(started && ready)) {...}"
Boolean algebra is something you will absolutely have to know or you will be constantly lost. In fact, it is not really possible to not know it if you do professional coding.
4
u/NationalMushroom7938 Mar 20 '25
It's the fundamental of CPUs .
Even if you don't need it that much in your Javascript projects :)
For a deeper understanding check out "nand2tetris"-course on Coursera where you gonna build a CPU from scratch.
11
u/jrdubbleu Mar 20 '25
It’s used to simplify complex problems, you need those fundamentals for coding.
7
u/apnorton Mar 20 '25
Logic is pretty fundamental to computer science. At the very least, you should know about the basic operations involved. (I'm also a little surprised you've never stumbled upon XOR, since that's a pretty important operation.)
As a practical point: A lot of computer science degrees require a course in digital logic and/or computer architecture, both of which will absolutely require knowledge of Boolean logic. My degree was 100% a CS degree, but I implemented adders, counters, etc. with physical components as part of my coursework. Sure, a computer engineering major will spend more time on such things, but every person who graduates with a CS degree should be able to explain (or, at least, should have learned at some point) at a basic level how a bare-bones processor works.
3
u/Xalem Mar 20 '25
While coding or even thinking about problems, you will use your knowledge of logic, binary math, set theory, group theory, category theory, type theory on a weekly, if not daily basis.
2
u/-Nyarlabrotep- Mar 20 '25
Boolean algebra is a fundamental part of computer science. If you try to avoid learning it, it would be like trying to learn physics without understanding Newton's equations.
2
u/TheSauce___ Mar 20 '25
It's a good thing to know - probably less useful now than it was back in ye olden days, but once in a blue moon it's helpful. It's also one of the classic topics of computer science.
1
u/azhder Mar 20 '25
Every code you have written or you will write that has a check if something needs to be done or another or if it should repeat once or 1000 times or not at all depends on you knowing boolean algebra.
That means, know that boolean algebra like the back of your hand so you may be decent at programming and maybe even use it outside of it.
1
u/srsNDavis Mar 20 '25
I don't know where you're from so excuse me if there are regional differences. I'm basing my answer on the OCR A-level computer science specification, but most specs at a comparable level should not be too different.
First off, I don't think school education does a great job of differentiating between computer science (CS), computer engineering (CE) (which would include digital logic), software engineering (SWE), and information technology (IT), as well as often a modicum of HCI. They're related - some very closely - but not the same.
In school, you'd typically cover some of most. Example: Look at pp. 12-20 of the OCR spec. It spans (the labels on some of these can be debated but I'm assigning the closest one in my view):
As for Boolean algebra, not counting logical circuits, you are likely to see it used in programming the control flow logic (trivially, if statements always take a condition). Boolean algebraic manipulation is a useful trick to simplify the conditions in a number of algorithms (likely none that you'll encounter in school). More on the theoretical side, Boolean algebra is used to manipulate problem structures (e.g. in proofs of complexity results of the Boolean satisfiability problem). Also not likely school-level stuff, but Boolean operations have an interpretation in set theory (and: intersection, or: union, not: complement), which makes it useful in mathematical modelling.
In other words, I think it's a pretty fundamental topic for CS (or the related disciplines I mentioned above).
But I think the aim of teaching Boolean algebra is even more fundamental - it is a primer on logic and logical reasoning, whether or not you go on to work with formal logic (you will if you study maths and/or CS). It's one of those core skills that will be useful for reasoning rigorously.