Compilation, Interpretation, Virtualisation etc. How Computer Programming Works - Part 4

Compilation, Interpretation, Virtualisation etc. How Computer Programming Works - Part 4

How Computer Programs Run

ยท

3 min read

Read Part 3

As you may imagine, most programs do much more complicated things than simply adding two numbers. So let's say we were writing a program with a potentially large codebase, may approach 10,000 lines or more, to test our code, we would have to go through the series of steps we have been discussing since the beginning of part 2. Yes, those will have to happen on every change to our codebase even if it is as little as renaming a variable. If the toolchain does not keep track of what changed and what didn't, it simply compiles, links and builds the program all over again.

In the past this used to be a problem, but not anymore, as smarter toolchains that address this this problem now exist.

The actual problem however is that of portability. This means that the program written for one platform would have to be modified (heavily if large) to have it work on another platform. In many cases, the work has to be redone n times, where n is the number of platforms the program is expected to be run on.

But you said something about cross-platform in the previous parts right?

Yes. We had already established that assembly languages aren't cross-platform because a piece a code written for one platform will have to be rewritten in another assembly language's syntax (how instruction are structured). That is, if you wanted a certain assembly code to run on another platform, you would have to learn the platform's specific syntax, therefore, no portability for you Sally. Compiled high-level languages also suffer from this setback.

What's the difference?

A program is cross-platform if it runs the same way regardless of the platform. That is, the program has executables (built by programmers) that can run on their respective platforms. In many cases, this would mean there were separate files you would have to download to get the program to run on your preferred platform but you still got the SAME features.

A program is platform-independent if the same executable or what is executed can run on any platform that supports it.

The degree of portability is determined by how much code has to be rewritten to have the same functionality on other platforms. So, portability is a programming language thing while cross-platform-ness is a program thing.

I have a question, what do you mean by platforms?

I will do you one better: why do you ask so many questions? ๐Ÿ˜ 

Anyway, a platform can either be software or hardware. Remember I mentioned in one of previous parts that the hardware's architecture has to be accounted for and so does the software in this case, the operating system. So if someone asks about "the platform" without specifying which of the two categories what they are most likely expecting you to say is something like - "Windows 10 on x86".

So let's think about it. How can we have a program run on other platforms without rewriting the code. And this is where I leave you in suspense till the next part. See ya!

ย