We can make all the gates using nand or nor gates. My teacher told us that nand gates are cheap too, then why do we need other gates at all?
They logically exist, you can not un-invent them. Even if no one ever made one, they would still exist in your mind.
If is easier to say “open door if I want to go through door or you want to go through door” than to say “open door if I don't want to go through door nand you don't want to go through door”
An alternate question — Why do we build devices with just one gate? i.e.
We do this because it makes the electronics simpler, if all the devices are the some, as we only have to implement one type of gate. This is about simplicity of the device, not of the logic (as this could be a bit more complex). This logical complexity could push the size up, but the symmetry of all gates being the same pushes the size down. Also a lot of the logical complexity can cancel out.
A similar question — Why do we have multiply in maths. When we can do everything with addition?
- Why do we have addition when we can just use increment: 3+4 = 3+1+1+1+1
- Why do we have multiplication when we can use addition: 3×4 = 3+3+3+3
- Why do we have exponentiation when we can use multiplication 3⁴ = 3×3×3×3
If you were to continue to look inside the computer, then you will see that it is,some what, like this:
- transistors →
nor→ all logic gates
- logic gates → addition
- logic gates → flip flops
- flip flops → shift registers → multiply by 2
- multiply by 2 & addition → multiplication
Why do we have steel, when you can just have iron, carbon, cobalt … ?
Representing the logic is just cheaper on a physical chip. AND / OR gates take more components to build. Using a few NAND gates does the same job, in a smaller, cheaper footprint electronically.