Skip to main content

1.2 - What is Programming?

The Essence of Programming

At its core, programming is the process of giving instructions to a computer to perform specific tasks. Think of it as writing a detailed recipe that the computer follows step by step. Just as a recipe needs to be precise and use the correct cooking terminology, programming requires exact syntax and logical structure.

Computers: Powerful but Literal

Computers are incredibly powerful machines capable of performing billions of calculations per second, but they lack human intuition and understanding. They execute instructions exactly as given, without interpreting intent or making assumptions.

This literal nature of computers means that as programmers, we need to:

  1. Break down complex problems into simple, sequential steps
  2. Express those steps using precise language the computer understands
  3. Account for different scenarios and potential errors
  4. Organize our code in a way that's maintainable and efficient

The Role of Programming Languages

Computers ultimately understand only machine code—binary instructions (0s and 1s) that directly control the computer's processor. However, writing programs in binary would be extremely tedious and error-prone for humans.

This is where programming languages come in. They provide a layer of abstraction that allows us to write code in a more human-readable format, which is then translated into machine code.

Types of Programming Languages

Programming languages can be categorized in several ways:

  1. Low-level vs. High-level Languages

    • Low-level languages (like Assembly) are closer to machine code and provide minimal abstraction
    • High-level languages (like C#, Python, Java) are more abstracted and easier for humans to read and write
  2. Compiled vs. Interpreted Languages

    • Compiled languages (like C#, C++) are translated to machine code before execution
    • Interpreted languages (like JavaScript, Python) are translated line by line during execution
  3. General-purpose vs. Domain-specific Languages

    • General-purpose languages (like C#) can be used for a wide variety of applications
    • Domain-specific languages are designed for specific use cases (like SQL for database queries)

C# as a Programming Language

C# (pronounced "C-sharp") is a modern, high-level, compiled, general-purpose programming language developed by Microsoft. It was designed to be:

  • Object-oriented: Organizing code around "objects" that combine data and behavior
  • Type-safe: Helping prevent errors by enforcing data type rules
  • Component-oriented: Supporting reusable, modular code components
  • Modern: Incorporating features that make development more efficient and code more readable

C# strikes an excellent balance between power and ease of use, making it ideal for game development with Unity.

The Programming Process

When you're programming, you typically follow these steps:

  1. Problem Analysis: Understand what you're trying to accomplish
  2. Algorithm Design: Plan the logical steps to solve the problem
  3. Coding: Write the actual code using a programming language
  4. Testing: Check if your code works as expected
  5. Debugging: Find and fix errors in your code
  6. Optimization: Improve your code's performance and efficiency
  7. Maintenance: Update your code as needed over time

As you progress through this course, you'll practice all these steps while building increasingly complex programs.

Programming in Game Development

In game development, programming brings all the elements together to create an interactive experience:

  • It defines how game objects behave and interact
  • It controls game physics and movement
  • It manages game state, scoring, and progression
  • It handles user input and provides feedback
  • It creates artificial intelligence for non-player characters
Game Development Perspective

Imagine you're creating a simple platformer game. You might use programming to:

  • Make the player character jump when the space key is pressed
  • Detect collisions between the player and platforms
  • Add gravity so the player falls when not on a platform
  • Count and display the score when collecting items
  • Trigger a "game over" when the player falls off the screen

All of these behaviors require precise instructions written in code.

Thinking Like a Programmer

Learning to program is as much about developing a way of thinking as it is about learning syntax. Computational thinking involves:

  1. Breaking down problems into smaller, manageable parts
  2. Recognizing patterns and similarities to problems you've solved before
  3. Abstracting details to focus on the essential elements
  4. Creating algorithms (step-by-step procedures) to solve problems
  5. Thinking logically about cause and effect

As you work through this course, you'll develop these thinking skills alongside your technical knowledge of C#.

Ready to Start Coding?

Now that you understand what programming is at a fundamental level, you're ready to dive into the specifics of C# and the .NET ecosystem. In the next section, we'll explore the environment in which C# programs run and how it relates to Unity development.

Remember, programming is a skill that improves with practice. Don't worry if concepts seem challenging at first—persistence is key to mastery!