1
$\begingroup$

Ok, I've been told for years that during the old days, a program written on a certain machine would run only on that machine but now, programs run on multiple types of computers.

What does this really mean? I mean, does it mean that programs were written for certain instruction sets of the processor and would not run in different instruction sets? If so how did they overcome this problem?

Is it due to the standard x86, AMD64 or ARM architectures that most programs are written for these types of processors and they are abundant in the world?

Please enlighten this lost kid.

$\endgroup$
  • $\begingroup$ It's not about the program usually, but about the compiler. Anyway, I have my doubts that this is a computer science question. Community votes, please! $\endgroup$ – Raphael Jan 20 '16 at 10:59
3
$\begingroup$

The intel line of processors (8086, x86) have backwards compatible instruction sets (i.e., unless you tell an x86 otherwise, it will behave like a 8086, and the 8086 instructions (and registers, etc) are just a subset of the x86 ones. Ditto for AMD64 (i.e., x86_64), they are able to run x86 software as is. This for pragmatic compatibility reasons: buying the shiny, new machine with the latest processor, and having it run your extant software in a slow emulator is not a way to make new buyers. So the 80286 could run 8086 software (operating system and all), and so on up. You can install an 32 bit (x86) operating system on x86_64 (64 bits) too.

ARM is a completely different kettle of fish, but also compatible (to an extent) along the line.

Besides, running software on some sort of virtual machine (Java Virtual Machine, .NET, ...) has advantages as the same "binary" runs on more platforms (simplifying the logistics of getting "the right version" to the user), today's processors are so ridiculously overpowered it doesn't make much of a difference for interactive applications. Besides, the Just In Time compilation technology has become the tool of choice, even rivaling native compiled binaries for some uses.

$\endgroup$
  • 2
    $\begingroup$ Another option is binary translation. While this adds translation overhead and the result may not match the performance of a native version from the same source code, such can update old software to use newer features, take advantage of runtime information (profile-guided optimization is not commonly used in ahead-of-time compilation), and exploit microarchitecture/system-specific knowledge. $\endgroup$ – Paul A. Clayton Jan 20 '16 at 3:35
  • $\begingroup$ I'm confused as to why this answer does not matter compilers. Nobody programs assembly; the programs people actually write work on many CPUs, provided you use a fitting compiler. $\endgroup$ – Raphael Jan 20 '16 at 11:00

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.