There are so many levels in between the source code of some program and the circuits on a chip. Why do higher level languages have neither xor nor nand short-circuit operators? (about missing operators in general, not this specific one.Why is there no nand instruction in modern CPUs? (about the circuits within a CPU, not languages).My question is why not just let the dev specify "Here is a NAND operation just do that"? I assume and pray that some compiler or something is smart enough to optimize this (after all, I see NAND in some IBM instruction sets), but I haven't heard of higher-level languages having an operator that explicitly invokes it. I know each of these gates is a single processor instruction, but wouldn't that instruction be so much more efficient if it only passed through one gate rather than several? This seems silly and inefficient to me! Just look at the first line of the implementation of C = NOT ( A AND B ): it gives us the result right away! But we toss it back and forth a few times after that anyway to return to the result we started with. The problem I see is that, since each of these operators is implemented in the processor as a combination of NANDs, then expressing NAND as these compositions might have them be executed as this: C = NOT ( A AND B )Ĭ = ( ( A NAND B ) NAND ( A NAND B ) ) NAND ( ( A NAND B ) NAND ( A NAND B ) )Ĭ = ( ( A NAND A ) NAND ( A NAND A ) ) NAND ( ( B NAND B ) NAND ( B NAND B ) ) I've seen arguments saying that these languages don't contain a dedicated NAND operator since C = A NAND B can be expressed as these: C = NOT ( A AND B ) So, it just makes sense to me that it would be really efficient for a program to say "Hey, I have a NAND operation for you please pass it through only one gate and store the result in a register." However, as far as I'm aware, no such operator exists in actual compiled languages. For example, processors compose NAND gates like this to create these operators: A AND B = ( A NAND B ) NAND ( A NAND B ) since these are the languages which actually implement golfing languages.Īs far as I know, modern processors are made up of NAND gates, since any logic gate can be implemented as a combination of NAND gates. I know that some golfing languages like APL have a dedicated NAND operator, but I'm thinking about languages like C, C++, Java, Rust, Go, Swift, Kotlin, even instruction sets, etc.