What are instructions in Computer Programs?

There are many examples of the word instruction but there is no defintion of the word instruction. Here is an example of the word instruction used is in the meaning of a computer program. A computer program is a set of instructions that tell a computer what to do. I have found the meaning of instruction on the oxford dictionary in google. The meaning of instruction is detailed information about how something should be done. Another meaning I have found in the dictionary for the word instruction is the word order. Using one of the two meanings for the word instruction that I have found on the oxford English dictionary can someone tell me the defintion of instruction in computer programs?

In computer program the instructions are the code that tell the computer what to do
Every line in a computer program is one or more instructions.

Did you want something like in this wiki article?

Also keep in mind that JavaScript is a high level language, meaning that it is fairly far from the code of the computer. At the lowest level would be machine code, actually 1’s and 0’s, that tell the computer “add the two numbers at these address locations” or “move the data from this address to this other address”.

Humans can’t comfortably read these instruction so they invented Assembly. Assembly is a very low level language because it maps very closely to machine code. Assembly would look something like:

   mov	eax, 45
   xor	ebx, ebx
   int	80h

   add	eax, 16384
   mov	ebx, eax
   mov	eax, 45
   int	80h

Each of those corresponds to a machine code instruction so this is still considered a low level language. Very little code is written in assembly today, unless you need code that is as fast as possible and as efficient as possible. But processor speed and memory is much cheaper today so it isn’t needed as much as it used to be.

Next up I guess would be a language like C. It has some benefit of being a more abstract language than Assembly but is still fairly efficient. With C you still have a lot of control over things like memory allocation and can be fairly efficient.

As you work your way up to higher level languages, a lot of that control is taken away from you at the benefit of code that is easier to write. In Assembly, everything you wrote paired very well with a machine instruction, but as languages get “higher” they get more abstracted from those instructions. JavaScript looks a lot like C (it is a descendant) but is not nearly as controllable. Things like memory allocation, garbage collection, etc are handled for you, at the expense of flexibility, speed, and memory.

Which is better? It depends on what you need. For web development, you need JavaScript for the frontend because it is the only option. On the backend you have some other options too.

Don’t worry about instructions because in high level languages you never have to deal with them directly. They are low level things sent to the CPU (and will be different for different computers) and each command you give in JavaScript will actually be a few to many instructions.

Think of it this way. The instructions are like telling the soldiers, “left foot, right foot”. But you are the general, you just tell them “march from point A to point B”. The JavaScript interpreter will be your Sargent and figure out the best way to get them there.

1 Like