CSE 240 Guide

Course Overview

Welcome to Intro to Programming Languages! This isn't just about learning new syntax. It's about understanding the four major ways to 'think' like a programmer. You'll see how different language paradigms solve problems in fundamentally different ways.

Paradigm 1: Procedural (C)

The foundation. You give the computer a list of instructions. Mastering this is non-negotiable for future systems courses.

  • Pointers: The most crucial topic. You'll learn to directly manipulate memory addresses. It's powerful but dangerous!
  • Memory: Understand the Stack (for local variables, fast) and the Heap (for dynamic data, you manage it).
  • `malloc()`/`free()`: You are the memory manager. If you `malloc` (allocate) memory, you MUST `free` it, or you'll create memory leaks.
  • Structs: How you create complex data types in C.

Paradigm 2: Object-Oriented (C++)

Builds on C. Instead of just procedures, you bundle data and the functions that operate on that data into "objects."

  • Classes/Objects: The blueprint and the instance. The core of OOP.
  • Inheritance: Create new classes that reuse and extend existing ones.
  • Polymorphism: An object can take many forms. Allows for more flexible and reusable code.
  • `new`/`delete`: The C++ way of managing heap memory. Just like `malloc`/`free`, you must manage it yourself.

Paradigm 3: Functional (Scheme)

A totally different mindset. Think in terms of pure functions, like in math. State changes are avoided.

  • Recursion is King: Loops are rare. You'll solve problems by breaking them down into smaller, self-similar problems.
  • Immutability: Data doesn't change. You create new data instead of modifying old data.
  • First-Class Functions: Functions are just like any other data. You can pass them as arguments and return them from other functions.

Paradigm 4: Logic (Prolog)

The most abstract paradigm. You don't tell the computer *how* to solve a problem, you just describe the problem.

  • Facts & Rules: You define a knowledge base. (e.g., "Socrates is a man.", "All men are mortal.")
  • Queries: You ask the system questions based on its knowledge. (e.g., "Is Socrates mortal?")
  • Unification: The process Prolog uses to match patterns and find answers.

Must Remembers!

  • POINTERS IN C/C++: Practice, practice, practice. Draw diagrams. Understand what the `*` and `&` operators do. This will haunt you or help you in every future CS course.
  • MEMORY MANAGEMENT: For every `malloc` or `new`, there must be a corresponding `free` or `delete`. This is a fundamental concept in low-level programming.
  • RECURSION: Get comfortable with it in Scheme. It will make you a better problem solver in ANY language.
  • PARADIGM SHIFTING: Don't try to write C code in Scheme, or Scheme code in Prolog. Embrace the new way of thinking for each language. This is the entire point of the course.
B
A
SELECT
START
ASU