4.
2
                                                                               Chapter 4
                                                                                    Abstract
          Similar to how people use different languages to communicate, programmers use various
                              programming languages to communicate instructions to a computer.
NAME :
                                                              Musfiq ul Hamid Showmik
                                                                                    01797806089
CLASS :
  4.2 Types of Programming Language, Translators, and Integrated Development
                            Environments (IDEs)
1) Introduction to Programming Languages and Communication
   a) Similar to how people use different languages to communicate, programmers use various programming
      languages to communicate instructions to a computer.
   b) Computers understand only machine code (the computer's native language), so programs written by
      programmers must be translated into machine code to be executed.
2) Purpose of Computer Programs
   a) Programs provide instructions, directing the computer on what tasks to perform, how to perform them,
      and when to execute them.
   b) This versatility allows a single computer to handle multiple tasks, like streaming videos, generating
      reports, predicting weather, and more.
3) Machine Code
   a) Computers only understand their native language, machine code.
   b) Programs must be translated into machine code to be executed.
4) Purpose of Programs
   a) Programs instruct a computer on what, how, and when to perform tasks.
   b) Examples: streaming videos, creating reports, forecasting weather.
5) Definition of a Computer Program
   a) A program is a list of instructions for a specific task.
   b) It follows the linear instructions.
6) High-Level vs. Low-Level Languages
   a) High-Level Languages: Easier for humas, widely used by programmers.
   b) Low-Level Languages: Closer to machine code, used for hardware-focused tasks.
                   4.2.1 High-Level Languages and Low-Level Languages
 High-Level Languages
   •   Purpose: Allow programmers to focus on problem-solving without needing detailed hardware
       knowledge.
   •   Portability: High-level languages are often portable across different computer systems.
   •   Benefits:
           ✓ Readability: Easier to read and understand since they are closer to English.
           ✓ Efficiency: Faster to write and debug during development.
1|Page Musfiqul Hamid Showmik
            ✓ Maintenance: Easier to update and maintain once deployed.
            ✓ Example:
            ✓ Code Snippet: Sum : FirstNumber + SecondNumber clear and concise.
            ✓ Languages: C++, Delphi, Java, Pascal, Python, Visual Basic, etc.
   •   Application: Techniques learned in one high-level language often apply to others, making skills
       transferable.
 Low-Level Languages
   → Purpose: Designed for specific hardware, directly addressing a computer’s architecture.
   → Types:
            ✓ Machine Code: Binary instructions directly understood by computers (e.g., hexadecimal or
              binary).
            ✓ Assembly Language: A human-readable version that still needs translation into machine code.
   → Example:
            ✓ Machine code snippet to add two numbers:
                                             1 12 0001 00010010
                                             4 13 0100 00010011
                                             0 1A 0000 00011010
   → Suitability: Used for tasks needing close control over hardware.
 Comparison of High-Level and Low-Level Languages
Language Type Advantages                                      Disadvantages
                 - Portable, hardware-independent              - Can be larger in size
High-Level       - Easier and faster to read, write, and debug - May execute more slowly
                 - Easier to maintain                          - Limited access to special hardware features
                 - Can use hardware-specific features
                                                              - Time-consuming to write and debug
Low-Level        - Memory-efficient
                                                              - Harder to understand and maintain
                 - Optimized for speed
                                      4.2.2 Assembly Languages
Overview of Assembly Language Usage
   •   Assembly languages are used by fewer programmers but are essential for tasks requiring:
            ✓ Access to Special Hardware: Enables direct interaction with specific hardware features.
            ✓ Machine-Dependent Instructions: Utilizes instructions specific to the computer's architecture.
2|Page Musfiqul Hamid Showmik
          ✓ Efficient Memory Usage: Produces code that takes up minimal primary memory.
          ✓ High-Speed Execution: Allows writing code that performs tasks quickly.
Example of Assembly Code
   •   The following is a sample assembly code to add two numbers:
                                                LDA First
                                              ADD Second
                                                STO Sum
          o   LDA (Load): Loads the value of First into the accumulator.
          o   ADD: Adds the value of Second to the accumulator’s current value.
          o   STO (Store): Stores the accumulator’s result in Sum.
Translation into Machine Code
   •   Assembler: Assembly language code must be translated into machine code using an assembler for it to
       run on a computer.
                                          4.2.3 Translators
Purpose of Translators
   •   Translation: Programs written by humans in high-level or assembly languages must be
       translated into machine code (binary) for a computer to execute.
   •   Types of Translators: There are three main types—compilers, interpreters, and assemblers—
       each serving a unique role in translation.
Types of Translators
   1. Compilers
         o Function: Translates an entire high-level program into machine code in one go,
             producing an executable file.
         o Reusability: Once compiled, the machine code can be run multiple times without
             recompilation.
         o Error Handling: Generates an error report if issues are found.
         o Example:
                 ▪ High-level statement: Sum : FirstNumber + SecondNumber
                 ▪ Machine code: 0001 00010010, 0100 00010011, 0000 00011010
   2. Interpreters
         o Function: Translates and executes high-level language statements one at a time.
         o Reusability: Requires interpretation each time the program is run.
         o Error Handling: Stops execution and provides an error message if an error is detected.
         o Use Case: Often used during program development for real-time testing and debugging.
   3. Assemblers
         o Function: Translates assembly language into machine code.
3|Page Musfiqul Hamid Showmik
           o     Reusability: Once assembled, the machine code can be executed multiple times without
                 re-assembly.
           o     Example:
                     ▪ Assembly code: LDA First, ADD Second, STO Sum
                     ▪ Machine code: 0001 00010010, 0100 00010011, 0000 00011010
                                   Translation Programs Summary
                                  ExecutableInstruction        Runtime
Translator         Function                                                                  Common Use
                                     File   Conversion      Requirements
            Translates an               One high-level
                           Produces an                                                     Used for
            entire high-                statement may      Can run
                           executable                                                      distributing
Compiler level language                 translate into     independently of
                           machine code                                                    programs for
            program into                multiple machine the compiler.
                           file.                                                           general use.
            machine code.               code instructions.
            Executes a
                                        Each statement
            high-level     Does not
                                        may need multiple Requires the                     Commonly used
            language       produce an
Interpreter                             machine code       interpreter to run              during program
            program one    executable
                                        instructions to    each time.                      development.
            statement at a file.
                                        execute.
            time.
                                        Typically, one
            Translates     Produces an assembly                                            Used to distribute
                                                           Can run
            assembly       executable   instruction                                        programs with
Assembler                                                  independently of
            language into machine code corresponds to one                                  hardware-specific
                                                           the assembler.
            machine code. file.         machine code                                       instructions.
                                        instruction.
           4.2.4 Advantages and Disadvantages of Compilers and Interpreters
Translator Advantages                                    Disadvantages
            - Easier and faster to debug and test
            programs during development.                 - Programs cannot be run without the interpreter.
Interpreter
            - Easier to edit programs during             - Programs may take longer to execute.
            development.
               - Compiled programs can be stored and     -Each change requires recompiling, making the
               ready for repeated use.                   debugging process slower and less efficient
               - Compiled programs can run without the   compared to interpreters.
Compiler
               compiler.                                 -Adjustments and tests take more time, as the
               - Uses less memory during execution.      entire program must be recompiled to check
               - Executes programs faster.               each change.
4|Page Musfiqul Hamid Showmik
                      4.2.5 Integrated Development Environment (IDE)
An Integrated Development Environment (IDE) is a software suite that assists programmers in writing and
developing code. IDEs may support a single programming language or multiple languages, with popular
examples including PyCharm (Python), Visual Studio (Visual Basic), and BlueJ (Java).
Key Features of IDEs:
   1. Code Editors:
           o   Allows writing and editing of code within the IDE, streamlining the development process by
               eliminating the need for separate text editors.
   2. Translators:
           o   Provides built-in compilers and/or interpreters to execute programs, typically using an
               interpreter during development and a compiler for the final version.
   3. Runtime Environment with a Debugger:
           o   Includes a debugger for running the program line by line, enabling programmers to set
               breakpoints and inspect variables to identify logic errors.
   4. Error Diagnostics and Auto-Correction:
           o   Performs dynamic error checking while coding, alerting programmers to potential errors and
               suggesting corrections as they type.
   5. Auto-Completion:
           o   Offers context-sensitive suggestions for variable names and reserved keywords, enhancing
               coding speed and accuracy.
   6. Auto-Documenter and Pretty Printing:
           o   Automatically generates documentation for code and formats it for readability with color coding
               and organized layout.
These features collectively enhance the efficiency and effectiveness of the programming and development
process, making it easier for programmers to write, test, and debug their code.
5|Page Musfiqul Hamid Showmik