lesson1-Introduction to computer programming
Introduction to Computer Programming
Computer programs are defined as sequences of instructions written in a Computer Programming Language to perform specified tasks. Key terms in this definition include:
Sequence of instructions: Similar to providing directions to a location, programming involves outlining steps to reach a specific computation.
Computer Programming Language: Just as people may communicate in various human languages, computers require specific programming languages to understand instructions.
For example, providing direction to KFC in English can be viewed as writing a human program, while a simple Python program such as print("Hello, World!") communicates directly with a computer to perform a task.
Understanding Computer Programs
Definition: A computer program is often called software, which can range from a few to millions of lines of instructions.
Source Code: Instructions in a computer program are also termed source code, and the act of creating programs is known as programming or coding.
Importance: Without programs, a computer remains inactive; thus, software serves to enable the functionality of computers, akin to how various languages facilitate human communication.
Programming Languages
There are many programming languages available, including:
Java
C
C++
Python
PHP
Perl
Ruby
Applications of Computer Programs
Computer programs are omnipresent in diverse fields:
Examples of Software: Applications like MS Word, Excel, and browsers such as Chrome are examples of programs at work.
Media Production: Computer software is instrumental in creating visual effects and graphics in films.
Medical Applications: Programs assist in conducting medical imaging techniques such as ultrasounds and X-rays.
Communication: Software is used for various communication methods via mobile applications.
The Role of a Computer Programmer
A person who writes computer programs is defined as a Computer Programmer, categorized based on their proficiency in specific programming languages (e.g., C Programmer, Python Programmer).
Understanding Algorithms
An algorithm is described as a step-by-step method to solve a problem—essentially a blueprint that programmers follow before coding.
Example of an Algorithm to Find the Largest Number:
Obtain a list of numbers.
Assume the first number is the largest.
Compare with the next number, updating if necessary.
Continue until reaching the end of the list, then output the largest number.
Types of Programming Languages
Programming languages are categorized into:
Low Level Languages
Machine Language (1GL): Consists of binary code directly understandable by the processor, offering fast execution but being difficult for programmers.
Assembly Language (2GL): Uses mnemonics as representations of operations, making it easier than machine language, though it remains hardware dependent.
High Level Languages: Closer to human languages, categorized into:
Procedural-Oriented Language (3GL): Focuses on the procedures required for computations.
Problem-Oriented Language (4GL): Allows users to state desired outputs without detailing processes, enhancing ease of programming.
Natural Language (5GL): A developing classification that allows programming with statements resembling natural language.
Programming Paradigms
Programming paradigms dictate styles and methodologies in program structure and execution. Key paradigms include:
Imperative: Commands that directly alter the program state.
Declarative: Focuses on what the program should accomplish.
Procedural: Combines the principles of imperative programming with structured procedures.
Functional: Treats computation as the evaluation of mathematical functions without changing state.
Object-Oriented: Encapsulates data and methods within objects that interact via message passing.
Notable Features of Paradigms:
Imperative: Focuses closely on machine operations; can be complex to debug.
Logical: Uses logical assertions and queries to solve problems with minimal programming steps.
Functional: Emphasizes functions, avoiding side effects and enhancing parallel processing capabilities.
Object-Oriented: Prioritizes code reuse and encapsulation, reducing dependency on specific implementations.
Understanding these various paradigms and types of programming languages helps equip a programmer with the tools necessary for effective coding across diverse applications.