G.E.S J.H.S Programming

Introduction To Programming

Programming is telling a computer what to do.

A programmer writes lines of code to tell the computer what to do

The elements of a computer system fall into two major categories: hardware and software

The hardware component refers to the physical components of a computer such as the central processing unit (CPU), memory, and input/out devices.

The software refers to the programs and instructions that tell the hardware what to do.

A progammer therefore writes lines of code to tell the hardware what to do.

A programmer therefore communicates with the computer through lines of codes.

The only language the computer understands is machine language which is binary, made up of 1s and 0s

Programming was initially very difficult as programmers had to write long binary numbers to communicate with the computer.

Programmers now can write with more human-readable syntax instead of the machine language.

This is made possible by a compiler which translates the human-readable syntax into a machine language for the computer to understand.

Programmers now use an Integrated Development Environment (IDE) which is a software which has the editor, the compiler/interpreter and debugger all integrated in the software.

Editor is a software tool where programmers write their code.

Compiler is a program that translates code written in a high-level programming language into machine language.

Debugging is the process of identifying and fixing errors in the code.

Interpreter is a program that executes code directly without compiling it first.

Examples of IDE include:

Top General Purpose & Most Popular IDEs

  1. Visual Studio (Microsoft): Primarily for .NET and C++.
  2. Visual Studio Code (VS Code): A popular, lightweight, extensible code editor often used as an IDE.
  3. IntelliJ IDEA (JetBrains): Top choice for Java and Kotlin.
  4. Eclipse: Widely used, open-source IDE, especially for Java.
  5. Cursor: An AI-powered IDE that has grown in popularity.
  6. PyCharm: Dedicated IDE for Python and Data Science.
  7. Android Studio: Official IDE for Android development.
  8. Xcode: Official IDE for macOS and iOS development.

Since the computer only understands binary numbers, you must know about binary, decimal and hexadecimal numbers as a programmer

Binary Numbers

Binary number is a number with only two possible values for each digit: 0 and 1.

It is important to understand binary numbers because they are the basis of all digital data, since computers can only store data in binary form, using bits and bytes.

For a example, the character A or 65 could be stored in the computer as 01000001

The term decimal comes from the Latin 'decem', meaning 'ten', because this number system (our normal everyday numbers) is based on ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9, to represent values.

Likewise, the term binary comes from the Latin 'bi', meaning 'two', because this number system uses only two digits: 0 and 1, to represent values.

Decimal To Binary

To convert decimal to binary, follow the steps below:

  1. Divide by 2: Divide the decimal number by 2
  2. Record Remainder: Note the remainder, which will be either 0 or 1
  3. Use Quotient: Use the integer quotient from this division as the new number for the next step
  4. Repeat: Continue steps 1 - 3 until the quotient is 0
  5. Reverse Order: Write the remainders in reverse order (from the last/bottom remainder to the first/top remainder)

Applying the above steps to convert the 65 which is an integer 65 or character 'A' stored in the computer as binary.

Number Remainder
65
32 1
16 0
8 0
4 0
2 0
1 0
0 1

Listing from the bottom, 6510 = 10000012. But since a byte contains 8 bits, 0 is placed infront of the 7 bits making 01000001

Note: a bit is one digit and 8 bits make a byte.

Binary to Decimal

  1. Write down the binary number: Identify the bits
  2. Assign powers of 2: Starting from the rightmost digit, assign increasing powers of 2 (20,21,22,..) to each bit
  3. Multiply: Multiply each bit (0 or 1) by the corresponding power of 2
  4. Sum the results: Add all the products together to get the decimal equivalent

Let's follow the steps to convert 10112 to decimal:

10112 = 1 x 23 + 0 x 22 + 1 x 21 + 1 x 20

Any number raised to the power 0 is 1

20 = 1

21 = 2

22 = 2 x 2 = 4

23 = 2 x 2 x 2 = 8

10112 = 1 x 8 + 0 x 4 + 1 x 2 + 1 x 1

10112 = 8 + 0 + 2 + 1

10112 = 1110

Hexadecimal

The term hexadecimal comes from the Latin 'hex', meaning 'six', and 'decimal', meaning 'ten', because this number system has sixteen possible digits.

Hexadecimal numbers from 1 to 16 decimal numbers are 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

Hexadecimal To Decimal

When converting from hexadecimal to decimal, we multiply the digits by powers of 16 (instead of powers of 10).

To convert hexadecimal to decimal, follow the steps below:

  1. Assign Positions: Start from the rightmost digit (position 0), moving left, assigning increasing power positions (160, 161, 162, ...)
  2. Convert Hex Digits: Convert letter digits to decimal: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.
  3. Multiply: Multiply each decimal digit by its corresponding 16position value.
  4. Sum: Add all the resulting products together to get the final decimal number

Let's apply the steps to convert 23E16 to decimal.

E = 14

23E16 = 2 x 162 + 3 x 161 + 14 x 160

23E16 = 2 x 256 + 3 x 16 + 14 x 1

23E16 = 512 + 48 + 14

23E16 = 57410

Decimal To Hexadecimal

To convert from decimal to hexadecimal, follow the steps below:

  1. Divibe by 16: Divide the decimal number by 16
  2. Record Remainder: Note the remainder. If the remainder is 10 - 15, covert to the corresponding letter, 10 = A, 11, = B, 12 = C, 13 = D, 14 = E, 15 = F
  3. Divide Quotient: Take the integer quotient from the previous step and divide it by 16.
  4. Repeat: Repeat steps 2 and 3 until the quotient becomes 0
  5. Reverse Order: Write the remainders in reverse order (from the last remainder to the first) to get the hexadecimal result

Let's convert 450 decimal to hexadecimal

Number Remainder
450
28 2
1 C (Note: 12 is C)
0 1

Listing from the bottom to top, 45010 = 1C216 or 01C216 for 4 bits

Binary to Hexadecimal

To convert from binary to hexadecimal, follow the steps below:

  1. Group into 4 bits: Starting from the rightmost bit, group the binary digits into sets of four. If the leftmost group has fewer than four bits, pad it with leading zeros.
  2. Convert Each Group: Convert each group of 4 bits to its hexadecimal equivalent using the following mapping: 0000 = 0, 0001 = 1, 0010 = 2, 0011 = 3, 0100 = 4, 0101 = 5, 0110 = 6, 0111 = 7, 1000 = 8, 1001 = 9, 1010 = A, 1011 = B, 1100 = C, 1101 = D, 1110 = E, and 1111 = F.
  3. Concatenate Hex Digits: Combine the hexadecimal digits obtained from each group to form the final hexadecimal number.

Note: If you don't know the binary representation of a hexadecimal digit, you can convert the binary to decimal first and then to hexadecimal.

10 = A

11 = B

12 = C

13 = D

14 = E

15 = F

Let's convert 1101011012 to hexadecimal.

Grouping into 4 bits: 0001 1010 1101

0001 = 1

10102 = 1 x 23 + 0 x 22 + 1 x 21 + 0 x 20 = 8 + 0 + 2 + 0 = 10 = A

1101 = 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20 = 8 + 4 + 0 + 1 = 13 = D

1101011012 = 1AD16

Hexadecimal to Binary

To convert from hexadecimal to binary, follow the steps below:

  1. Convert Each Hex Digit: Convert each hexadecimal digit to its 4-bit binary equivalent using the following mapping: 0 = 0000, 1 = 0001, 2 = 0010, 3 = 0011, 4 = 0100, 5 = 0101, 6 = 0110, 7 = 0111, 8 = 1000, 9 = 1001, A = 1010, B = 1011, C = 1100, D = 1101, E = 1110, F = 1111.
  2. Concatenate Binary Digits: Combine the binary digits obtained from each hex digit to form the final binary number.

Let's convert 3F16 to binary.

3 to binary

Number Remainder
3
1 1
0 1

Listing from the bottom to top, 310 = 112

Adding the leading zeros to get 4 bits: 310 = 00112

F16 = 1510

15 to binary

Number Remainder
15
7 1
3 1
1 1
0 1

Listing from the bottom to top, 1510 = 11112

Therefore, F16 = 11112

3F16 = 0011 11112

3F16 = 0011 11112 = 001111112

3F16 = 001111112 = 1111112

Programming languages are tools designed for specific tasks, ranging from building interactive websites to controlling hardware.

Here is a list of common programming languages and the types of software they are used to build:

Web Development

  1. JavaScript: The "language of the web," used to build interactive front-end elements like dropdown menus and animations. With Node.js, it is also used for back-end server-side development.
  2. TypeScript: A version of JavaScript with added safety features, used for large-scale web applications where reliability is critical, such as Slack and Microsoft Teams
  3. PHP: Primarily used for server-side web development and powers content management systems like WordPress and large platforms like early Facebook
  4. Ruby: Often paired with the Ruby on Rails framework to build web applications quickly; it is the foundation for sites like Airbnb

Mobile App Development

  1. Swift: Apple's official language for building native apps across the iOS, macOS, watchOS, and tvOS ecosystems
  2. Kotlin: The modern standard for Android development, preferred by Google for its concise syntax and safety features
  3. Java: A long-standing choice for Android apps and high-performance mobile applications.
  4. Dart: Used with the Flutter framework to build cross-platform mobile apps for both iOS and Android from a single codebase

Systems & Game Development

  1. C++: Known for speed and resource control, it is used to build operating systems (like Windows internals), game engines (such as Unreal Engine), and high-performance desktop apps like Adobe Photoshop
  2. C#: The primary language for the Unity game engine, used to build 2D, 3D, and VR games, as well as Windows desktop software.
  3. Rust: A rising star focused on memory safety, used for performance-critical systems, blockchain infrastructure, and security-sensitive tools at companies like Amazon and Meta
  4. C: The foundational language for embedded systems, hardware drivers, and operating system kernels.

Data Science & Enterprise

  1. Python: The dominant language for Artificial Intelligence (AI), machine learning, and data analysis due to its massive library ecosystem (e.g., TensorFlow, Pandas).
  2. SQL: A specialized language used to manage, query, and manipulate data within relational databases
  3. Java: The "enterprise powerhouse" used for large-scale banking systems, e-commerce platforms, and server-side business software.
  4. Go (Golang): Designed by Google for scalability, it is used to build cloud infrastructure (like Docker and Kubernetes), microservices, and high-performance backend APIs.

Python is widely considered the best overall language for teaching principles because its syntax mirrors natural English. This allows beginners to focus on computational thinking (loops, conditionals, and problem-solving) rather than struggling with complex code structures

We will be using C and Python programming languages to teach the concepts of programming.

We will also use the online compilers instead of an IDE since installation of an IDE can be cumbersome.