I know that this might seem like a stupid question, because declarative is not really an electrical term. I'm having a discussion (argument) with someone who is a functional programming fanatic, and they claimed that

Nope, they're fundamentally declarative. They built an imperative instruction set on top of a declarative model. ISA and machine code is imperative, sure. But; CPUs, GPUs, etc are all declarative.

If it wasn't for diodes, all parts could be emulated in lambda calc. Hence why it is a bicartesian closed category.

I disagree with this, because I would argue that CPUs are machines that have internal state that they mutate. In fact, computation is all about mutation (of memory, or registers, or latches).

Who is right?

  • 5
    \$\begingroup\$ In fact, you just discovered the distinctions between combinational logic and sequential logic, which are the two fundamental concepts of digital electronics. I suggest you to read a digital logic textbook, you'll find it interesting. \$\endgroup\$ – 比尔盖子 Oct 9 '19 at 22:29
  • 1
    \$\begingroup\$ “They” seem to mess up ALU and CPU. A CPU is basically an ALU plus registers plus some glue logic. It's not possible to build a CPU without at least a program counter, aside from having that function put into the memory, e.g. a punched tape on a spinning roll. \$\endgroup\$ – Janka Oct 9 '19 at 22:40
  • 7
    \$\begingroup\$ This reminds me of a story of Richard Feynmann's (from "Surely you're Joking, Mr. Feynmann"). He was hanging out with some faculty from the philosophy department, and they asked him if an electron is an essential object. He wasn't sure what an essential object was so he said "I dunno -- is a brick an essential object?" They were still arguing over that when he left. So -- is a brick declarative? \$\endgroup\$ – TimWescott Oct 9 '19 at 22:56

Aren't you both wrong? To me this sounds like arguing that if someone thinks in English then their neurons are wired in English, which is nonsensical.

If you actually want to force application of the terms then I think it is just a matter of perspective. For example, an assembly instruction (or machine code) might tell a CPU to add.

From the perspective of a higher abstraction layer (like an assembly programmer) that instruction would be imperative because it is being used to tell the CPU how to go about doing some process.

But to the computer hardware engineer actually designing the CPU, an addition instruction might be declarative because he is the one who has to design the microcircuitry that actually does the addition. The add instruction just tells the CPU to add (i.e. what to do). It doesn't determine how the CPU actually goes about the addition (i.e. how to do it). That's determined by the actual microcircuitry performing the addition.

The same logic applies as you applies as you get even deeper down into the abstraction layers for hardware into computational blocks like registers or adders, and even lower into gates, and lower again into transistors. Every "abstracted entity" is imperative to the person using it but declarative to the person designing it.

Sounds like needless classification gone amock to me.

| improve this answer | |
  • \$\begingroup\$ This indeed hints at why the question is ultimately one of opinion on what to look at. One of the key things to consider is that many if not most modern general purpose processors don't literally implement what their lowest level exposed programming model implies. They accomplish the same result of course, but they get there in a somewhat different way. \$\endgroup\$ – Chris Stratton Oct 10 '19 at 1:17

unless you map a dataflow language directly onto hardware, you'll end up with an underlying procedural hardware implementation.

There are systolic array computers, where some data moves in Y direction, and some data moves in X direction.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.