You are on page 1of 18

Graphics Computer

Chapter 1.
Computer Programming Language
A computer programming language is a formal language comprising a set of
instructions that produce various kinds of output. It is used to communicate instructions
to a computer in order to perform specific tasks, such as data manipulation, algorithm
implementation, and application development. Programming languages provide a
structured way to express algorithms and logic, enabling programmers to create
software, scripts, or applications for a wide range of purposes. These languages
typically consist of syntax rules, keywords, data types, control structures, and libraries
that programmers use to write code and interact with computer systems effectively.
Programming languages enable humans to communicate with computers in a way that
they can understand and execute.

Here are some key components and characteristics of programming languages:

1. Syntax: Programming languages have a specific syntax, which is a set of rules


that defines the structure and organization of code. Syntax includes elements
like keywords, punctuation, and formatting conventions.
2. Semantics: Semantics refers to the meaning behind the code written in a
programming language. It defines how the instructions written in the language
are interpreted and executed by the computer.
3. Data Types: Programming languages support different types of data, such as
integers, floating-point numbers, characters, strings, and more. Each data type
has specific operations and memory requirements associated with it.
4. Variables and Constants: Variables are used to store and manipulate data
within a program. Constants, on the other hand, are values that do not change
during program execution.
5. Control Structures: Programming languages provide various control structures,
such as loops, conditionals, and branching statements, to control the flow of
execution within a program.
6. Functions and Procedures: Functions and procedures allow programmers to
organize code into reusable modules, making it easier to manage and maintain
large programs.
7. Libraries and Frameworks: Many programming languages come with built-in
libraries and frameworks that provide pre-written code for common tasks, such
as mathematical operations, file input/output, and networking.

Disusun Oleh : Kadri Yusuf [1]


Graphics Computer

8. Compilers and Interpreters: Programming languages are implemented through


either compilers or interpreters. Compilers translate source code into machine
code that can be executed directly by the computer, while interpreters execute
code line-by-line at runtime.
9. Paradigms: Programming languages can be classified into different paradigms
based on their approach to solving problems. Common paradigms include
procedural, object-oriented, functional, and declarative programming.
10. Portability and Compatibility: Some programming languages are platform-
independent, meaning that the same code can run on different operating
systems and hardware architectures. Others are specific to certain platforms or
environments.

Learning a programming language offers numerous benefits and reasons why it's
worth the investment of time and effort. Here are some key reasons why learning a
programming language is valuable:

1. Problem-Solving Skills: Programming teaches you how to break down complex


problems into smaller, manageable tasks, fostering critical thinking and
problem-solving abilities.
2. Career Opportunities: Proficiency in programming opens up a wide range of
career opportunities in fields such as software development, data science, web
development, cybersecurity, artificial intelligence, and more.
3. Creativity and Innovation: Programming empowers you to create new software
solutions, applications, and technologies, allowing you to express your
creativity and innovate in various domains.
4. Automation and Efficiency: Programming enables automation of repetitive
tasks, increasing efficiency and productivity in various domains such as business
processes, data analysis, and system administration.
5. Understanding Technology: Learning programming provides insights into how
technology works at a fundamental level, empowering you to understand and
utilize various digital tools and systems more effectively.
6. Versatility: Programming languages are versatile tools that can be applied
across different industries and domains, allowing you to pursue diverse career
paths and adapt to changing technological landscapes.
7. Collaboration and Communication: Programming often involves working in
teams and collaborating with others to develop software projects, improving
your communication and teamwork skills.

Disusun Oleh : Kadri Yusuf [2]


Graphics Computer

8. Analytical Thinking: Programming encourages analytical thinking and attention


to detail, as small errors in code can have significant consequences, fostering
precision and thoroughness in problem-solving.
9. Continuous Learning: Technology is constantly evolving, and learning
programming languages equips you with a mindset for continuous learning and
adaptation to new tools, languages, and frameworks throughout your career.
10. Personal Growth: Mastering a programming language can be a fulfilling
personal accomplishment, boosting your confidence and providing a sense of
achievement as you build increasingly complex and impactful projects.

Disusun Oleh : Kadri Yusuf [3]


Graphics Computer

Essay Question in chapter 1

1. What is a programming language?


Answer: A programming language is a formalized set of instructions that can be
used to communicate with a computer and create software programs.
2. What is the purpose of a programming language?
Answer: The purpose of a programming language is to enable humans to write
instructions (code) that computers can understand and execute to perform specific
tasks.
3. What are the two main categories of programming languages based on their
execution methods?
Answer: The two main categories are compiled languages and interpreted
languages.
4. What is a compiled language?
Answer: A compiled language is a programming language where the source code
is translated into machine code (binary code) by a compiler before execution.
5. What is an interpreted language?
Answer: An interpreted language is a programming language where the source
code is executed line by line by an interpreter at runtime.
6. What is the difference between a compiler and an interpreter?
Answer: A compiler translates the entire source code into machine code before
execution, while an interpreter executes the source code line by line at runtime.
7. Name an example of a compiled programming language.
Answer: C, C++, and Java are examples of compiled programming languages.
8. Name an example of an interpreted programming language.
Answer: Python, JavaScript, and Ruby are examples of interpreted programming
languages.
9. What is a programming paradigm?
Answer: A programming paradigm is a fundamental style or approach to
programming that dictates how a programmer structures and organizes code to
solve problems.
10. What is a variable in programming?
Answer: A variable is a symbolic name that represents a value stored in the
computer's memory. It can hold different values during the execution of a
program.

Disusun Oleh : Kadri Yusuf [4]


Graphics Computer

Chapter 2.
History of Programming Language
Programming languages are formal languages used to communicate
instructions to a computer. They provide a structured and systematic way to write
code that can be executed by a computer to perform specific tasks or solve problems.
Programming languages allow programmers to express algorithms, logic, and data
manipulation in a human-readable format, which is then translated into machine-
readable instructions by a compiler or interpreter.
In essence, programming languages serve as a bridge between human
thought and machine execution, enabling programmers to write software that
instructs computers on how to perform various operations, from simple arithmetic
calculations to complex data analysis and system control. These languages vary in
syntax, semantics, and features, catering to different programming paradigms, such
as imperative, declarative, functional, and object-oriented programming. Some
common programming languages include Python, Java, C++, JavaScript, and Ruby,
among many others.
The history of programming languages is a rich and complex subject that
spans several decades and involves numerous contributors, innovations, and
developments. Here, will be provided a comprehensive overview of the history of
programming languages, divided into key stages and highlighting significant
languages and advancements along the way.
1. Pre-20th Century
The concept of programming languages can be traced back to the 19th century,
with the development of mechanical calculating machines such as Charles
Babbage's Analytical Engine.
Ada Lovelace, often considered the world's first programmer, wrote algorithms
for Babbage's Analytical Engine in the mid-19th century.
2. 1940 - Early 1950
The first electronic computers were developed during and after World War II,
leading to the need for programming languages to operate these machines
efficiently.
In the 1940, assembly languages, such as Assembly for the ENIAC, were
developed to provide a more human-readable representation of machine code.
The short-lived Plankalkül, developed by Konrad Zuse in the late 1940, is
considered one of the earliest high-level programming languages.
3. 1950 - 1960

Disusun Oleh : Kadri Yusuf [5]


Graphics Computer

This period saw the emergence of several influential programming languages:


a. FORTRAN (1957): Developed by IBM, FORTRAN (Formula Translation) was
the first high-level programming language, designed for scientific and
engineering applications.
b. LISP (1958): Created by John McCarthy, LISP (LISt Processing) was one of
the earliest functional programming languages, known for its use in
artificial intelligence research.
c. COBOL (1959): COBOL (COmmon Business-Oriented Language) was
developed for business data processing and became widely used in
commercial applications.
d. ALGOL (1958-1960): ALGOL (ALGOrithmic Language) was a significant
early high-level language that influenced the design of subsequent
languages.
4. 1970s - 1980
This era saw the development of several influential languages and paradigms:
a. C (1972): Created by Dennis Ritchie at Bell Labs, C became one of the most
widely used programming languages, known for its efficiency and versatility.
b. Pascal (1970): Designed by Niklaus Wirth, Pascal was developed for teaching
programming and became popular in academic settings.
c. Smalltalk (1972): Developed at Xerox PARC, Smalltalk was an object-oriented
programming language that influenced the design of subsequent languages
like Java.
d. Prolog (1972): Prolog (PROgramming in LOGic) was developed for artificial
intelligence and symbolic computing applications, based on logic
programming principles.
5. 1990 – 2000
This period saw the rise of several influential languages and technologies:
a. Java (1995): Created by James Gosling at Sun Microsystems, Java became
widely used for building cross-platform applications and web services.
b. Python (1991): Developed by Guido van Rossum, Python gained popularity
for its simplicity and readability, becoming one of the most widely used
programming languages.
c. JavaScript (1995): Initially developed by Brendan Eich at Netscape,
JavaScript became the primary language for client-side web development.
d. C++ (1985): An extension of C, C++ introduced object-oriented
programming features and became widely used in system and application
development.
e. PHP (1995): Developed by Rasmus Lerdorf, PHP became a popular server-
side scripting language for web development.

Disusun Oleh : Kadri Yusuf [6]


Graphics Computer

6. 21st Century
The 21st century has seen the continued evolution of programming languages
and the emergence of new trends and paradigms:
a. Swift (2014): Developed by Apple for iOS and macOS app development,
Swift replaced Objective-C as the primary language for Apple platform
development.
b. Rust (2010): Developed by Mozilla, Rust gained attention for its emphasis
on safety and performance, particularly in system programming contexts.
c. Go (2009): Developed by Google, Go became popular for its simplicity and
efficiency, particularly in concurrent programming.
d. Kotlin (2011): Developed by JetBrains, Kotlin gained traction as a modern
language for Android app development, eventually becoming an official
language for Android development alongside Java.

Disusun Oleh : Kadri Yusuf [7]


Graphics Computer

1. Who is often considered the world's first programmer?


A) Charles Babbage
B) Ada Lovelace
C) Konrad Zuse
D) Alan Turing
Answer: B) Ada Lovelace
2. Which of the following was one of the earliest high-level programming languages?
A) Assembly language
B) COBOL
C) Plankalkül
D) LISP
Answer: C) Plankalkül
3. Which programming language was developed for scientific and engineering
applications?
A) LISP
B) COBOL
C) FORTRAN
D) ALGOL
Answer: C) FORTRAN
4. Who developed the programming language LISP?
A) John McCarthy
B) Dennis Ritchie
C) Niklaus Wirth
D) Guido van Rossum
Answer: A) John McCarthy
5. What was the primary purpose of the COBOL programming language?
A) Business data processing
B) Scientific computing
C) Artificial intelligence
D) Game development
Answer: A) Business data processing
6. Which programming language influenced the design of subsequent languages like
Java?
A) Pascal
B) Smalltalk
C) Prolog
D) C++
Answer: B) Smalltalk

Disusun Oleh : Kadri Yusuf [8]


Graphics Computer

7. Who is credited with the creation of the C programming language?


A) Dennis Ritchie
B) James Gosling
C) Niklaus Wirth
D) Brendan Eich
Answer: A) Dennis Ritchie
8. Which language became popular for its simplicity and readability, often described
as "executable pseudocode"?
A) Python
B) Java
C) C++
D) JavaScript
Answer: A) Python
9. What programming language is widely used for client-side web development?
A) Python
B) Java
C) JavaScript
D) PHP
Answer: C) JavaScript
10. Which programming language is primarily used for server-side scripting in web
development?
A) Python
B) Java
C) JavaScript
D) PHP
Answer: D) PHP
11. What programming language was developed by Apple for iOS and macOS app
development?
A) Swift
B) Kotlin
C) Rust
D) Go
Answer: A) Swift
12. Which language gained attention for its emphasis on safety and performance in
system programming contexts?
A) Swift
B) Kotlin
C) Rust
D) Go

Disusun Oleh : Kadri Yusuf [9]


Graphics Computer

Answer: C) Rust
13. What programming language became popular for its simplicity and efficiency,
particularly in concurrent programming?
A) Swift
B) Kotlin
C) Rust
D) Go
Answer: D) Go
14. Who developed the programming language Kotlin?
A) Google
B) JetBrains
C) Mozilla
D) Apple
Answer: B) JetBrains
15. Which of the following is an official language for Android development alongside
Java?
A) Swift
B) Kotlin
C) Rust
D) Go
Answer: B) Kotlin
16. Which language gained traction as a modern language for Android app
development?
A) Swift
B) Kotlin
C) Rust
D) Go
Answer: B) Kotlin
17. What was the primary purpose of the Plankalkül programming language?
A) Scientific computing
B) Business data processing
C) Teaching programming
D) Artificial intelligence
Answer: C) Teaching programming
18. What was the primary purpose of the ALGOL programming language?
A) Scientific computing
B) Business data processing
C) Artificial intelligence
D) Teaching programming

Disusun Oleh : Kadri Yusuf [10]


Graphics Computer

Answer: D) Teaching programming


19. What programming language is often described as a "system programming
language"?
A) Java
B) C++
C) Python
D) JavaScript
Answer: B) C++
20. Which programming language was developed for symbolic computing and
artificial intelligence applications?
A) Prolog
B) LISP
C) COBOL
D) Smalltalk
Answer: A) Prolog

Disusun Oleh : Kadri Yusuf [11]


Graphics Computer

Chapter 3.
Syntax and Semantic
3.1 Syntax
Syntax in programming languages refers to the set of rules that define the
combinations of symbols, keywords, and characters that form valid statements and
expressions within the language. It governs how programs are written and
structured, ensuring that the code is understandable and interpretable by both
humans and computers. Syntax encompasses elements such as variable declarations,
control structures, data types, and function definitions.
Here are some key aspects of syntax in programming languages
a. Keywords: These are reserved words that have special meanings in the
language and cannot be used as identifiers (e.g., variable names). Examples
include `if`, `else`, `for`, `while`, `int`, `float`, etc.
b. Identifiers: These are names given to various program elements such as
variables, functions, classes, etc. Identifiers must adhere to certain rules
regarding character usage, such as starting with a letter or underscore, and
can contain letters, digits, and underscores. Examples:
- Variable names: int age, double salary, String name.
- Function names: void calculateSalary(), int add(int a, int b).
- Class names: class MyClass, interface MyInterface.
- Object names: MyClass obj, MyInterface obj.
c. Operators: These symbols represent operations to be performed on operands,
such as arithmetic operators (`+`, `-`, `*`, `/`), comparison operators (`==`,
`!=`, `<`, `>`), logical operators (`&&`, `||`, `!`), etc.
d. Punctuation: Punctuation symbols like parentheses `()`, braces `{}`, brackets
`[]`, commas `,`, semicolons `;`, and periods `.` are used to define the
structure of code, such as grouping expressions, delineating blocks of code,
separating elements, and terminating statements.
e. Comments: In programming languages, a comment is a piece of text that is
ignored by the compiler or interpreter and is intended solely for human
readers. Comments are used to annotate code, providing explanations,
clarifications, or notes about the purpose, functionality, or behavior of the code.
They are essential for improving code readability, understanding, and
maintenance. Comments are typically indicated by special symbols or
keywords specified by the programming language, and they can appear inline

Disusun Oleh : Kadri Yusuf [12]


Graphics Computer

with code or as standalone blocks. Comments are not executed or processed


during runtime; they serve only as documentation for developers.
f. Data Type : a data type defines the type of data that a variable can hold or the
type of value that an expression can produce (e.g., integers, floats, strings,
booleans, arrays, etc.) and syntax for defining custom data types (e.g., structs,
classes, enums).
g. Control Structures: These are constructs that determine the flow of execution
in a program, such as conditional statements (`if`, `else`), loops (`for`,
`while`), and branching (`switch`).
h. Function Definitions: Syntax includes rules for defining functions or methods,
including the function name, parameters, return type, and the body of the
function.
i. Whitespace: whitespace refers to any sequence of characters that are used
for spacing, indentation, or formatting purposes, but are otherwise ignored by
the compiler or interpreter during the parsing or execution of code.
Whitespace characters include spaces, tabs, newline characters, and
sometimes other invisible characters like carriage returns.
j. Case Sensitivity: case sensitivity refers to the distinction made between
uppercase and lowercase letters in identifiers, keywords, and other elements
of the language syntax. A programming language is considered case sensitive
if it differentiates between uppercase and lowercase characters and treats
them as distinct entities.

3.2 Semantic
In the context of programming languages, "semantic" refers to the meaning or
interpretation of the code, as opposed to its syntax, which is concerned with its
structure and grammar. The semantics of a programming language define how
statements and expressions are executed and how they interact with each other and
the underlying system.

Here are several key aspects of semantics in programming languages:


a. Data Types and Operations: Semantics define the behavior of various data types
(such as integers, floating-point numbers, strings, and arrays) and the operations
that can be performed on them (such as arithmetic operations, string
manipulation, and array operations). For example, the semantics of adding two
integers specify that they are to be added numerically, while the semantics of
concatenating two strings specify that they are to be combined end-to-end.
b. Variables and Assignment: Semantics determine how variables are declared,
initialized, and used within a program. This includes rules for variable scope,

Disusun Oleh : Kadri Yusuf [13]


Graphics Computer

lifetime, and visibility, as well as the semantics of assignment statements, which


specify how values are assigned to variables.
c. Control Flow: Semantics define the behavior of control flow constructs such as
conditionals (if-else statements), loops (for loops, while loops), and branching
(switch statements). This includes specifying how control flow statements affect
the order of execution of statements within a program.
d. Functions and Procedures: Semantics describe how functions and procedures are
defined, called, and executed within a program. This includes specifying how
arguments are passed to functions, how return values are returned, and how local
variables are scoped within functions.
e. Memory Management: Semantics determine how memory is allocated, managed,
and deallocated within a program. This includes specifying how memory is
allocated for variables and data structures, how memory is reclaimed when it is
no longer needed, and how memory leaks and other memory-related errors are
handled.
f. Concurrency and Parallelism: For languages that support concurrency and
parallelism, semantics describe how concurrent and parallel processes or threads
interact, synchronize, and communicate with each other. This includes specifying
how shared resources are accessed and protected, how synchronization primitives
such as locks and semaphores are used, and how concurrent and parallel
programs are executed.
g. Error Handling: Semantics define how errors and exceptions are detected,
propagated, and handled within a program. This includes specifying how runtime
errors are detected and reported, how exceptions are raised and caught, and how
error-handling mechanisms such as try-catch blocks are used.

Disusun Oleh : Kadri Yusuf [14]


Graphics Computer

Multiple Choice Questions

1. What is syntax in programming languages?


a. The output of a program
b. The meaning of code
c. The structure and grammar of code
d. The runtime behavior of code
Answer: c. The structure and grammar of code
2. Which of the following is a reserved word in many programming languages?
a. Variable
b. Identifier
c. Keyword
d. Constant
Answer: c. Keyword
3. Which punctuation symbol is commonly used to indicate the beginning and end of
a block of code in many programming languages?
a. Parentheses ()
b. Braces {}
c. Brackets []
d. Comma ,
Answer: b. Braces {}
4. What is the purpose of a semicolon in many programming languages?
a. To end a statement
b. To indicate the start of a loop
c. To declare a variable
d. To separate function arguments
Answer: a. To end a statement
5. In programming languages, what does the term "identifier" refer to?
a. A reserved word
b. A variable name or symbol
c. A data type
d. An operator
Answer: b. A variable name or symbol
6. Which section of a function declaration specifies the type of value the function
returns?
a. Parameters
b. Body
c. Return type
d. Function name

Disusun Oleh : Kadri Yusuf [15]


Graphics Computer

Answer: c. Return type


7. What do programming language operators, such as "+" and "*", represent?
a. Keywords
b. Data types
c. Operations
d. Variables
Answer: c. Operations
8. What is the purpose of comments in programming languages?
a. To execute code
b. To improve code readability and provide explanations
c. To declare variables
d. To define functions
Answer: b. To improve code readability and provide explanations
9. Which of the following is an example of a valid variable name in many
programming languages?
a. 123variable
b. $price
c. if
d. float-number
Answer: b. $price
10. What does the term "case sensitivity" refer to in programming languages?
a. The ability to handle errors gracefully
b. The order in which statements are executed
c. The distinction between uppercase and lowercase letters in identifiers
d. The efficiency of a program
Answer: c. The distinction between uppercase and lowercase letters in identifiers
11. What does semantics refer to in programming languages?
a. The structure and grammar of code
b. The meaning or interpretation of code
c. The output of a program
d. The runtime behavior of code
Answer: b. The meaning or interpretation of code
12. Which aspect of programming language semantics defines how data is
represented and manipulated?
a. Control flow
b. Data types and operations
c. Variables and assignment
d. Functions and procedures
Answer: b. Data types and operations

Disusun Oleh : Kadri Yusuf [16]


Graphics Computer

13. What does control flow semantics in a programming language describe?


a. How memory is allocated and deallocated
b. How functions and procedures are defined and called
c. The order in which statements are executed
d. How errors and exceptions are handled
Answer: c. The order in which statements are executed
14. In the context of programming languages, what does memory management
semantics encompass?
a. How variables are declared and assigned values
b. How memory is allocated, accessed, and deallocated
c. How concurrency and parallelism are achieved
d. How control flow constructs are implemented
Answer: b. How memory is allocated, accessed, and deallocated
15. Concurrency and parallelism semantics in programming languages refer to:
a. How errors and exceptions are handled
b. How memory is managed
c. How concurrent processes or threads interact and synchronize
d. How data types and operations are defined
Answer: c. How concurrent processes or threads interact and synchronize
16. What aspect of programming language semantics deals with error detection,
propagation, and handling?
a. Data types and operations
b. Control flow
c. Error handling
d. Concurrency and parallelism
Answer: c. Error handling
17. Which of the following is not determined by programming language semantics?
a. How variables are declared
b. How functions are defined
c. The syntax of the language
d. How errors are handled
Answer: c. The syntax of the language
18. What is the purpose of specifying semantics in a programming language?
a. To define the structure and grammar of the language
b. To ensure that code is readable and understandable
c. To provide guidelines for writing efficient code
d. To ensure that code behaves predictably and correctly
Answer: d. To ensure that code behaves predictably and correctly
19. Which of the following is an example of semantics in programming languages?

Disusun Oleh : Kadri Yusuf [17]


Graphics Computer

a. The use of braces {} to denote code blocks


b. The interpretation of a variable's value based on its data type
c. The use of parentheses () in function calls
d. The order of statements in a program
Answer: b. The interpretation of a variable's value based on its data type
20. What does semantic error in programming refer to?
a. An error detected by the compiler during syntax analysis
b. An error in the logic or meaning of the code
c. An error due to improper memory management
d. An error caused by incorrect use of operators
Answer: b. An error in the logic or meaning of the code

Disusun Oleh : Kadri Yusuf [18]

You might also like