Programming Software

Every programmer needs these tools to help them create programs, this includes:

  • Compiler
  • Debugger
  • Interpreter
  • Linker
  • Text Editor

Compiler

A Compiler is used to transform source code of one language to another language. The target language is called Object Code and is usually in a binary form. The main use of compilers is to convert the source code into a real working executable program. Because computers do not naturally understand the higher level programming language you used, the compiler takes the source code you provide and breaks that down into the building blocks of that language which is machine code bytes (assembly language without mnemonics). For example, take this source code for example:

print "hello world!"


In assembly language that would be equivalent to:

mov ax,0900   ;Int 21 call function for print string
pop dx        ;Get address of string
int 21        ;Call OS Interrupt code 21
ret           ;Return from call


In machine language that would be:

B8 00 09 5A CD 21 C3


The machine code and assembly code are not that different:

B8 00 09   ;mov ax,0900
5A         ;pop dx
CD 21      ;int 21
C3         ;ret


The main difference between assembly and machine language is that assembly language replaces machine opcodes for mnemonics to help us memorize the instructions better. In the above example the part of the instruction: B8 is replaced by ‘mov ax’, interrupt calls are the same except in assembly ‘int’ which stands for interrupt is replaced by ‘CD’ in machine code.

Anyways, compilers are primarily given the name to programs that translate a higher level language (more abstract than machine language) to a lower level language which is usually assembly or machine code.
Now optionally, depending on your needs, there are special types of compilers. A compiler that translates a low level language to another low level language (such as assembly language to machine language) is known as an assembler. A program that does the opposite of an assembler, where bytes are converted to one step higher assembly language is known as a disassembler.

Likewise, a program that does the opposite of a compiler where machine language is converted to the original high level language source code is called a decompiler. And finally a program that converts between two high level languages (such as VB.NET to C#) is usually called a language translator/converter/rewriter.

Debugger

A debugger allows you to test and debug your program at run-time to check for unwanted output or errors. In batch, you could use cmd as it’s own debugger since cmd can return output of a command result:

@echo off
set debug=call :debug
set debug.output="%cd%\debug_bat.txt"

:main
%debug% set string=hello world!
%debug% echo %string%
%debug% echo Current Folder:
%debug% dir /b
%debug% pause
%debug% goto :eof

:debug
set debug.command=%*
echo %debug.command%>>%debug.output%
echo Output: {
%debug.command%>>%debug.output%
echo }>>%debug.output%
echo Errorlevel: %errorlevel%>>%debug.output%
goto :eof


Features of debuggers may include stepping through every single instruction at a desired rate or stopping when it reaches a certain point in a program (known as breakpoints), tracking the values of variables, or modify the state of a program while it is running. All these features enable to programmer to track bugs in their programs and observe how the program runs step by step.

Interpreter

An interpreter is similar to a type of compiler except an interpreter takes the source code and executes it directly and/or immediately. According to wikipedia, an interpreter either:

  • executes the source code directly
  • translates source code into some efficient intermediate representation (code) and immediately executes this
  • explicitly executes stored precompiled code made by a compiler which is part of the interpreter system

In fact, scripting engines like WScript or cmd.exe can be classified interpreters. Since you can make batch files which cmd.exe analyzes and executes immediately and same thing with WScript or Cscript.

+---Interpreter---+      +---Code---+
|     cmd.exe     | <--- | bat file |
+-----------------+      +----------+
         |                     ^
         |                     |
         V                     |
    +-----------+              |
    | Execution |------Output--+
    +-----------+


Here’s the psuedocode for an interpreter that I came up with:

main:
var input=GetCommandInput()
var command=ParseInput(command)
var arguments=ParseInput(arguments)
var output=Execute(command,arguments)
OutStream << output
goto :main


Linker

A linker is a program that takes all the object code generated by a compiler and links them together into a single executable. First source codes are made into object files converted by the compiler, then those object files are merged together into one executable file by the linker:

+--------+  +--------+ +--------+ 
| Source |  | Source | | Source |
|  Code  |  |  Code  | |  Code  |
+--------+  +--------+ +--------+
     |           |          |
     |           |          |
     +--------+  |  +-------+
              |  |  |
              |  |  |
              V  V  V
           +-----------+               +------> +--------+
           |  Compiler |               | +----> | Linker |
           +-----------+               | | +--> +--------+
              |  |  |                  | | |        |
              |  |  |                  | | |        |
     +--------+  |  +-------+          | | |        |
     |           |          |          | | |        |
     |           |          |          | | |        |
     V           V          V          | | |        |
+--------+   +--------+ +--------+     | | |        |
| Object |   | Object | | Object |     | | |        |
+--------+   +--------+ +--------+     | | |        |
     |           |          |          | | |        |
     |           |          +----------+ | |        |        +------------+
     |           +-----------------------+ |        +------> | Executable |
     +-------------------------------------+                 +------------+


Text Editor

The text editor is a program that allows the programmer to actually type source code for the soon to be compiled program. Text editors allows you to enter the contents of a source code file using the keyboard to enter human readable text (plain text). Text editors are easy to obtain as they are usually provided with operating systems or software development packages. One good example is the text editor that comes with windows called Notepad. The location of notepad is C:\Windows\System32. One important thing to remember is that text editors are not the same as word processors. As word processors have more advanced text editing capabilities such as formatting or adding different object formats to documents such as images or video. According to wikipedia here are the differences between text editors and word processors:

  • A plain text file is represented and edited by showing all the characters as they are present in the file. The only characters usable for ‘mark-up’ are the control characters of the used character set; in practice this is newline, tab and formfeed. The most commonly used character set is ASCII, especially recently, as plain text files are more used for programming and configuration and less frequently used for documentation than in the past.
  • Documents created by a word processor generally contain fileformat-specific “control characters” beyond what is defined in the character set. These enable functions like bold, italic, fonts, columns, tables, etc. These and other common page formatting symbols were once associated only with desktop publishing but are now commonplace in the simplest word processor.
  • Word processors can usually edit a plain text file and save in the plain text file format. However one must take care to tell the program that this is what is wanted. This is especially important in cases such as source code, HTML, and configuration and control files. Otherwise the file will contain those “special characters” unique to the word processor’s file format and will not be handled correctly by the utility the files were intended for.

For the programmer, you may want to get a source-code editor which is like a text editor except it is designed specifically for writing source code for a particular language. The features of a source code editor may include syntax highlighting, autocompletion, and indentation.

All these tools may be necessary to get, but if you wish to have a program that has all of these tools bundled into one then you could be looking for an IDE. IDE stands for Integrated Development Environment which contains the source code editor, compiler, linker, and debugger into one program. It may also include other tools.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: