Theoretical Foundation II: Modular- Programming, Code-Translation, and Encapsulation (Part 2)

3.2 Code-translator versus programming-language

This section explains the difference between code-translator and programming-language. This section is written to assist the readers in understanding the scope of this dissertation. Producing a good code-translator is very expensive; it requires large amount of fund. On the other hand, creating a programming-language may be economically feasible for individual researcher or student; as can be seen from Table 1.4 (in sec 1.6) and the fourth row of Table 3.2.


Programming-language Code-translator
Does not translate source-code, does not translate intermediate-code Translates source-code, translates intermediate-code
Specification of syntax and semantic Is not a specification
Mostly free (most specification syntax and semantics are freely downloadable) Mostly are not free. License fee is usually hundreds of US dollars.
Few individuals can create industrial-strength programming-language Few individuals cannot create industrial-strength code-translator
Does not determine the size of runnable-code and/or intermediate code Determines the size of runnable-code and/or intermediate-code.

Table 3.2 Comparison between programming-language and code-translator


A programming-language – especially for the source-code – dictates neither the size of intermediate-code or runnable-code nor the relative superiority of run-time. In all programming-languages consulted in writing this dissertation not one dictates the superiority of intermediate-code, runnable-code, or run-time speed. The superiority in those terms are the attribute of code-translator. As a proof, consider fig 3.12 and 3.13 that translate the C source-code as follows.


#include <stdio.h>

void main()


  printf ("Hello world\n");


Code 3.1 A source-code in one programming-language (C)


Figure 3.12 shows that the GNU C linker produce 9 KB runnable-code while fig 3.13 shows that Microsoft C linker produce 28 KB runnable-code (the topmost file). The difference cannot be attributed to the programming-language because the code-translator accepts the source-code in the same programming-language. The difference can (and must) be attributed to the code-translator.



Figure 3.12 Runnable-code size produced by GNU C



Figure 3.13 Runnable-code size produced by Microsoft Visual C


Having understood the differences between programming-language and code-translator, the next section will begin to define the term module. Its definition is the key to better understand code-translation. Module is also the key to understanding encapsulation and modular programming.


3.3 Module: Unit of translation

Sec 3.1 uses phrases like source-code file, intermediate-code file. The precise term, however, is unit of translation – C++ standard [59] used the term translation unit. A unit of translation is not necessarily a file. Code 3.2 and 3.3 show an example written in C++.


void operator1 (); // Module01.h, first file

Code 3.2 A very simple module written in C++


#include "Module01.h"  // Module01.cpp, second file

#include <stdio.h>

void operator1 ()


  printf ("Hello worlding\n");


void main ()




Code 3.3 Another module, using the module in Code 3.2


In that example, there are two source-code files, but there is only one unit of translation. The next example comes from Oracle PL/SQL. This source-code can be stored in one file, two files, or no separate file at all (if stored in database).



  PROCEDURE operator1;



Code 3.4 One part of a module, written in Oracle PL/SQL



  PROCEDURE operator1 AS


    DBMS_output.put_line ('Hello worlding');




Code 3.5 Another part of a module, written in Oracle PL/SQL


The source-code represented by both Code 3.4 and Code 3.5 represent one unit of translation, not two. Furthermore, the code-translation approach for Code 3.4 and Code 3.5 differs with the approach for Code 3.2 and 3.3. Thus, the concept of unit of translation is independent toward translation approach.

While the concept of unit of translation is good, the phrase denoting the concept is long enough. A shorter, yet equally accurate term is needed. That term is Module. We define Module as:


Module: unit of translation.                                                                           (3.1)


The word Module needs to be used for two reasons as follows:

  1. Shorter than ‘unit of translation’
  2. Ease explaining the concept of ‘Modular Programming’.


The second reason will be clarified in sec 3.6. With module as unit of translation we can say:

  1. Module is unit of Interpretation
  2. Module is unit of Compilation
  3. Module is unit of Linking
  4. Module is unit of Disassembling
  5. Module is unit of CompileLinking
  6. Module is unit of LinkRunning


Subsec 3.1.3 has exhaustively listed the translation approaches. With module stated as the unit of translation, we can refine the wordings for code-translation approaches. They are redefined using the word Module as follows:

  • Compile: translate source-code module to materialized intermediate-code module.
  • Interpret: translate source-code modules to unmaterialiazed runnable-code module.
  • Link: translate intermediate-code modules to materialized runnable-code program.
  • CompileLink: translate source-code modules to materialized runnable-code program.
  • LinkRun: translate intermediate-code modules to unmaterialized runnable-code program.
  • Disassemble: translate from
    • Materialized runnable-code program to materialized source-code module
    • Materialized intermediate-code modules to materialized source-code module
  • Translate:
    • translate source-code module to source-code module.
    • translate intermediate-code module to intermediate-code module.
    • translate runnable-code program to runnable-code program.


Note that some paragraphs use the word ‘program’. The relationship between module and program is clarified in sec 3.7.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s