Programming and Scripting
Programming refers to writing programs, which are step-by-step instructions for the computer to perform an action.
Source code or programming language is high-level language that humans can understand.
- Computers do not understand the more human-readable high-level languages
- Computers only execute programs written in binary
Machine code or machine language is another name for binary.
For our code to be executed, we need to translate it into machine language.
Two main translation solutions:
- interpreters
- compilers
Both compilers and interpreters are used to translate programs into machine code.
Compiler
A compiler translates source code into machine language.
- checks source code for errors before translating
- if errors found, compiler specifies the errors
- Errors must be resolved before compiler can successfully recompile source code
Example
- C
- C++
- C#
- Java
Interpreter
Interpreters translate and execute source code into machine language one line at a time.
- if error found, the process is terminated at the statement containing the error and displays an error message
- error must be resolved before the interpreter continues to the next line
Example
- Perl
- Python
- PHP
- JavaScript
- Ruby
One significant advantage of an interpreter is that you can run a single line of code and see its output, whereas, in the case of a compiler, you need first to compile the whole code and then run it after all errors are fixed.
Choosing Programming Languages
A programming language should be chosen based on its capabilities to match the requirements.
- Cobol was designed for business tasks like accounting.
- Fortran was designed for scientific analysis.
- TCL is used for rapid prototyping and the creation of GUIs.
Algorithms
Algorithm is a step-by-step formula outlining how to execute a task.
In IT, an algorithm is a set of well-organized, computer-implemented instructions that often result in a computation or the solution to a problem.