Day One Learnings: A Beginner's Guide to Programming Languages, Computer Interaction, and Core Concepts

Python programming simplified

·

11 min read

Introduction

Let me ask you a question: Have you ever wondered how computers understand the commands we give them?

Well, here’s the answer: Programming languages are the key. They serve as a bridge between human logic and machine execution.

Why Do We Need a Programming Language?

Computers, in their raw form, cannot understand human speech, thoughts, or complex logic directly. They are powerful machines, but they need to be told what to do in a way they can interpret. This is where programming languages come in.

A programming language translates human instructions into machine-readable code, which the computer can then execute. By using these languages, we can give precise and structured commands to the computer. This allows us to do things like:

  • Develop software

  • Build websites

  • Analyze data

  • Create all kinds of applications

Without programming languages, the modern technologies and services we rely on daily smartphones, social media platforms, online shopping, and much more wouldn’t exist.

Example: Making a Cup of Lemon Salad

Imagine you want to use a programming language to guide a computer in making a cup of lemon salad. In the same way you would write out a recipe for a human to follow, you could break it down into specific instructions for a computer to "execute" in steps. Here’s how a simple "recipe" might look:

Step 1: Gather Ingredients

  • 1 lemon

  • 1 tablespoon of olive oil

  • 1 tablespoon of honey

  • A pinch of salt

  • A pinch of pepper

  • Fresh herbs (optional)

Step 2: Prepare the Lemon

  • Cut the lemon in half.

  • Squeeze the juice into a bowl.

Step 3: Add Seasoning

  • Add the olive oil, honey, salt, and pepper to the bowl.

Step 4: Mix and Serve

  • Stir the ingredients together until well combined.

  • Garnish with fresh herbs if desired.

  • Serve in a cup!

In simple terms programming languages are the bridge between human logic and machine execution. Computers, in their raw form, are incapable of understanding human speech, thoughts, or even complex logic directly. Programming languages translate human instructions into machine-readable code that can be executed by a computer. They allow us to give precise and structured commands to computers, enabling us to develop software, build websites, analyze data, and create a wide range of applications. Without programming languages, we wouldn’t have the modern technologies and services that we use daily.


Understanding Programming Languages and Computer Interaction

How will computers interact with Human Beings?

Computers interact with humans through input devices (like keyboards, touchscreens, or voice recognition systems) and output devices (like monitors, printers, or speakers). Programming languages define how these devices function by enabling the creation of software that understands and processes human inputs, then provides an output. A simple example is a calculator application: when a user enters numbers and operations, the software (written in a programming language) processes the inputs and shows the result on the screen.

Why do we have so many programming languages?

There are hundreds of programming languages out there. Ever wonder why? Every programming language essentially does the same thing, so why are there so many? Let me break it down!

Consider an example: Netflix is developed using multiple programming languages!

Different languages are chosen based on specific use cases and optimizations, ensuring the best performance in each area.

  • For front-end applications: JavaScript is ideal.

  • For enterprise-level applications like banking: Java is a solid choice.

  • For simple web apps: PHP works well.

  • For automation, AI, and machine learning: Python is preferred.

  • For embedded devices and low-level hardware programming: C and C++ are commonly used.

Each of these programming languages is optimized for a specific use case, ensuring they perform efficiently in the tasks they're designed for. Over time, new languages are created to address emerging needs and problems, and existing ones evolve to improve usability, performance, and maintainability.

One single app is developed using multiple programming languages. We have a separate term for this: it's called 'Polyglot'.

What is the Polyglot Concept?

The Polyglot concept refers to the ability of a developer to be fluent in multiple programming languages. This is a valuable skill as it allows developers to choose the right tool for the job, whether it's for backend development, frontend programming, data analysis, or artificial intelligence. Being a polyglot opens up career opportunities and allows one to work on a variety of projects across different industries.


Learning the Basics of Programming

How to Teach a Computer Programming Languages?

Computers don't learn programming languages the way humans do. Instead, we use tools like compilers and interpreters to translate human-readable code into machine code that computers can understand. A compiler translates the entire program into machine code before execution, while an interpreter translates and executes code line-by-line. Programming languages are also built around algorithms and data structures, which allow computers to perform tasks efficiently.

What is an Interpreter?

An interpreter is a program that reads and executes code one line at a time. Unlike a compiler, which converts the whole program into machine code before running, an interpreter translates code line by line and executes it directly. This is useful in scripting languages like Python and JavaScript, where immediate feedback is important for developers to test their code as they write it.

How to Learn Anything in a Story Way? What Are Its Benefits?

Learning complex concepts through stories makes them more relatable and memorable. Instead of dry theory, storytelling connects abstract ideas to real-world scenarios. For example, explaining functions in programming as "a chef following a recipe" helps learners understand how functions take inputs, perform tasks, and return results. This method makes difficult topics easier to digest and keeps learners engaged by presenting information in a narrative context.


Common Concepts and Functions

Every problem has a unique way of being solved. This unique solution is nothing but a function, feature, or functionality. In the world of computers, everything happens because of a function. Everything a human asks a computer to do is processed in the form of a function or operation.

What is a Function?

A function in programming is a block of code that performs a specific task. Functions are essential because they allow developers to break down large problems into smaller, manageable pieces. Instead of repeating code, we can call a function multiple times. Functions can take parameters (inputs), perform a task (logic), and return a result (output). Functions promote code reusability and help keep code organized.

What is a Syntax Error?

A syntax error occurs when the structure of your code doesn’t follow the rules of the programming language. For instance, forgetting to close parentheses or misspelling a keyword. Syntax errors are caught by the compiler or interpreter during the development process and prevent the code from running. Debugging syntax errors is an essential skill for every programmer.

In simple terms, if a human writes a program to solve a problem and the code contains incorrect syntax or uses undefined commands, the computer won't understand it and will throw a syntax error.

What is the Print Function?

The print function is one of the most commonly used functions in programming. It is used to display output on the screen.

For example, in Python, you can print text or variables using print("Hello, World!"). This function is crucial for debugging and testing code, as it allows developers to see the results of their program.

However, to send instructions or display messages through platforms like email or WhatsApp, different types of functions are needed.


Working with RAM and Data Storage

RAM, or a memory device, is needed to retrieve and access data when required. RAM has a physical memory address, and to access data in RAM, we need the memory address.

A variable or reference variable stores the memory address of the data in RAM.

How to Access and Retrieve Data Stored in RAM?

RAM (Random Access Memory) is where data that is currently being used or processed by the computer is stored temporarily. When a program runs, it loads necessary data into RAM for faster access. The CPU can quickly retrieve data from RAM, which is much faster than accessing data from a hard drive or other storage devices. Programmers can access and retrieve data stored in RAM through variables, arrays, or data structures.

How to Store Data in RAM?

Data is stored in RAM when a program needs to use it during execution. When you create variables or arrays in a program, the computer allocates space for them in RAM. This allows the program to quickly read from and write to the memory. The more RAM a computer has, the more data it can store for active processes, improving performance.

In simple terms, we need a function, and it's nothing but the '=' sign. '=' is an assembly level programming operation.

What is the Return Function?

A return function is a mechanism in programming that allows a function to send a result back to the part of the program that called it. For example, a function that adds two numbers can return the sum to the calling code for further use. The return statement helps pass data between functions, promoting modularity and reusable code.

What is id ( ) Function?

Generally, in Python, the id() function is used to obtain the memory address in RAM. So, we can say that the memory address can be accessed with the help of the id() function.

Example: If x = 5, calling id(x) will return the memory address of the variable x. You can see an example in the image below.

How to store data in memory?

Well, the answer is quite simple: it’s done using the equal sign (=), as discussed above.

What is REPL?

REPL stands for Read-Eval-Print Loop, and it’s an interactive programming environment that allows you to enter expressions, evaluate them, and see the results immediately. It’s commonly used in Python and many other languages for quick experimentation and learning.

How REPL works:

  1. Read: The REPL reads the code or command entered by the user.

  2. Eval: It evaluates the expression to determine its meaning or result.

  3. Print: It prints the result of the evaluation.

Loop: It repeats the process, allowing the user to keep interacting with the environment.

The >>> symbol in REPL (Read-Eval-Print Loop) is the Python prompt that appears when you are using the interactive Python shell.

Meaning of >>> in REPL:

  • Prompt for input: The >>> is the prompt where you can type Python code. It indicates that the interpreter is waiting for you to enter an expression or statement.

  • Interactive mode: This prompt appears when you run Python interactively, meaning you can type commands, evaluate expressions, and immediately see the result.

In the REPL, we don’t need to use the print() function; the result will be automatically printed as soon as we enter any statement. REPL acts as a live interpreter, and as soon as we exit the session (using the exit() function from the terminal), everything will be erased.

REPL is a Command Line Interface (CLI). Instead of this, we can use an IDE.

IDE:

An Integrated Development Environment (IDE) is used to interact with programming languages through a graphical interface. Some examples include VS Code, Jupyter Notebook, and Google Colab, among others."


Myths:

  1. As soon as data is loaded into RAM, the data is available! (Correct)

  2. As soon as we close the program, the data is removed from RAM! (Exceptions)


Explanation:

  1. As soon as data is loaded into RAM, the data is available!
    This statement is generally correct. Once data is loaded into RAM (Random Access Memory), it can be accessed quickly by the program. The operating system loads the necessary data into RAM for efficient access, and the program can use it as needed.

  2. As soon as we close the program, the data is removed from RAM!
    This is mostly true, but there are exceptions. While it's generally true that when a program closes, the data it used is removed from RAM, certain data might remain in memory temporarily. For example:

    • Operating system processes: Some data may be cached by the operating system for performance optimization.

    • Memory leaks: In some cases, programs may not release memory properly, leaving data in RAM even after the program exits.

    • Swapping: If the system is low on memory, data might be swapped out to the disk (virtual memory), even if the program is closed.

    • Saved Data or Snapshots: Programs or systems that periodically save their state (e.g., snapshots or checkpoints) can store data in RAM at specific times, allowing retrieval or review of that data even after the program closes.

Let’s discuss all of this in more detail in the coming days! In the next article, let’s dive deep into how to access and read the entire RAM using various techniques. We will also discuss how companies benefit from using Python, as well as topics like module management, threading, and memory management.


Conclusion

In this article, we've covered the essential role of programming languages in helping computers understand human commands. We've also explored some key programming concepts, such as functions, syntax errors, and the importance of RAM in data storage and retrieval.

Next, we’ll dive deeper into memory management, threading, and how companies benefit from using Python. Stay tuned for more insights into the fascinating world of programming!


Don't just believe; dive deep into technology, understand who created it, and uncover the truth. Seek knowledge relentlessly, question assumptions, and empower yourself with the clarity to shape the future.

For more Such Contents follow me on Social Media

LinkedIn: https://www.linkedin.com/in/sathyanarayan-k/