Computer Science: Programming with a Purpose (Coursera)

Offered by Princeton University,
Computer Science: Programming with a Purpose (Coursera)

The basis for education in the last millennium was “reading, writing, and arithmetic;” now it is reading, writing, and computing. Learning to program is an essential part of the education of every student, not just in the sciences and engineering, but in the arts, social sciences, and humanities, as well. Beyond direct applications, it is the first step in understanding the nature of computer science’s undeniable impact on the modern world.

Class Deals by MOOC List - Click here and see Coursera's Active Discounts, Deals, and Promo Codes.

This course covers the first half of our book Computer Science: An Interdisciplinary Approach (the second half is covered in our Coursera course Computer Science: Algorithms, Theory, and Machines). Our intent is to teach programming to those who need or want to learn it, in a scientific context.
We begin by introducing basic programming elements such as variables, conditionals, loops, arrays, and I/O. Next, we turn to functions, introducing key concepts such as recursion, modular programming, and code reuse. Then, we present a modern introduction to object-oriented programming.
We use the Java programming language and teach basic skills for computational problem solving that are applicable in many modern computing environments. Proficiency in Java is a goal, but we focus on fundamental concepts in programming, not Java per se.
All the features of this course are available for free. It does not offer a certificate upon completion.

Syllabus

WEEK 1
Basic programming concepts
Why program? This lecture addresses that basic question. Then it describes the anatomy of your first program and the process of developing a program in Java using either virtual terminals or a program development environment, with some historical context. Most of the lecture is devoted to a thorough coverage of Java's built-in data types, with example programs for each.

WEEK 2
Conditionals and loops
The if, while, and for statements are Java's fundamental control structures. This lecture is built around short programs that use these constructs to address important computational tasks. Examples include sorting, computing the square root, factoring, and simulating a random process. The lecture concludes with a detailed example illustrating the process of debugging a program.

WEEK 3
Arrays
Computing with a large sequence of values of the same type is extremely common. This lecture describes Java's built-in array data structure that supports such applications, with several examples, including shuffling a deck of cards, the coupon collector test for randomness, and random walks in a grid.

WEEK 4
Input and output
To interact with our programs, we need mechanisms for taking information from the outside world and for presenting information to the outside world. This lecture describes several such mechanisms: for text, drawings, and animation. Detailed examples covered include fractal drawings that model natural phenomena and an animation of a ball bouncing around in the display window.

WEEK 5
Functions and libraries
Modular programming is the art and science of breaking a program into pieces that can be individually developed. This lecture introduces functions (Java methods), a fundamental mechanism that enables modular programming. Motivating examples include functions for the classic Gaussian distribution and an application that creates digital music.

WEEK 6
Recursion
A recursive function is one that calls itself. This lecture introduces the concept by treating in detail the ruler function and (related) classic examples, including the Towers of Hanoi puzzle, the H-tree, and simple models of the real world based on recursion. We show a common pitfall in the use of recursion, and a simple way to avoid it, which introduces a different (related) programming paradigm known as dynamic programming.

WEEK 7
Performance
When you develop a program, you need to be aware of its resource requirements. In this lecture, we describe a scientific approach to understanding performance, where we develop mathematical models describing the running time our programs and then run empirical tests to validate them. Eventually we come to a simple and effective approach that you can use to predict the running time of your own programs that involve significant amounts of computation.

WEEK 8
Abstract data types
In Java, you can create your own data types and use them in your programs. In this and the next lecture, we show how this ability allows us to view our programs as abstract representations of real-world concepts. First we show the mechanics of writing client programs that use data types. Our examples involve abstractions such as color, images, and genes. This style of programming is known as object-oriented programming because our programs manipulate objects, which hold data type values.

WEEK 9
Creating data types
Creating your own data types is the central activity in modern Java programming. This lecture covers the mechanics (instance variables, constructors, instance methods, and test clients) and then develops several examples, culminating in a program that uses a quintessential mathematical abstraction (complex numbers) to create visual representations of the famous Mandelbrot set.

WEEK 10
Programming languages
We conclude the course with an overview of important issues surrounding programming languages. To convince you that your knowledge of Java will enable you to learn other programming languages, we show implementations of a typical program in C, C++, Python, and Matlab. We describe important differences among these languages and address fundamental issues, such as garbage collection, type checking, object oriented programming, and functional programming with some brief historical context.

Go to Class
MOOC List is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Related Courses

Computational Thinking for K-12 Educators: Sequences and Loops (Coursera) Coursera
University of California, San Diego

Computational Thinking for K-12 Educators: Sequences and Loops (Coursera)

How do we give instructions to a computer? Isn't programming hard? Not really! Whether it's giving someone directions to a nearby store or writing out some dance moves we frequently exhibit aspects of computational thinking in our everyday lives! This class teaches the first key concepts of programming -- sequences of instructions and basic counted repetition of instructions.

Jun 3rd 2026
5-12 Weeks
Introduction To Swift Programming (Coursera) Coursera
University of Toronto

Introduction To Swift Programming (Coursera)

Introduction to Swift Programming is the first course in a four part specialization series that will provide you with the tools and skills necessary to develop an iOS App from scratch. By the end of this first course you will be able to demonstrate intermediate application of programming in Swift, the powerful new programming language for iOS. Guided by best practices you will become proficient with syntax, object oriented principles, memory management, functional concepts and more in programming with Swift.

Jun 1st 2026
5-12 Weeks
Introduction to HTML5 (Coursera) Coursera
University of Michigan

Introduction to HTML5 (Coursera)

Thanks to a growing number of software programs, it seems as if anyone can make a webpage. But what if you actually want to understand how the page was created? There are great textbooks and online resources for learning web design, but most of those resources require some background knowledge. This course is designed to help the novice who wants to gain confidence and knowledge. We will explore the theory (what actually happens when you click on a link on a webpage?), the practical (what do I need to know to make my own page?), and the overlooked (I have a page, what do I do now?).

Jun 1st 2026
3 Weeks
Learn to Teach Java: Boolean Expressions, If Statements, and Iteration (Coursera) Coursera
University of California, San Diego

Learn to Teach Java: Boolean Expressions, If Statements, and Iteration (Coursera)

Learn to program with Boolean Expressions, If Statement, and For and While Loops in Java, and prepare to teach others using the free, online interactive CS Awesome textbook. In this course for teachers we'll guide you both in learning Java concepts and skills but also in how to effectively teach those to your students.

Jun 3rd 2026
4 Weeks
Advanced Data Structures in Java (Coursera) Coursera
University of California, San Diego

Advanced Data Structures in Java (Coursera)

How does Google Maps plan the best route for getting around town given current traffic conditions? How does an internet router forward packets of network traffic to minimize delay? How does an aid group allocate resources to its affiliated local partners? To solve such problems, we first represent the key pieces of data in a complex data structure. In this course, you’ll learn about data structures, like graphs, that are fundamental for working with structured real world data.

Jun 1st 2026
5-12 Weeks
Programming Foundations with JavaScript, HTML and CSS (Coursera) Coursera
Duke University

Programming Foundations with JavaScript, HTML and CSS (Coursera)

Learn foundational programming concepts (e.g., functions, for loops, conditional statements) and how to solve problems like a programmer. In addition, learn basic web development as you build web pages using HTML, CSS, JavaScript. By the end of the course, will create a web page where others can upload their images and apply image filters that you create.

Jun 1st 2026
4 Weeks
Data Privacy Fundamentals (Coursera) Coursera
Northeastern University

Data Privacy Fundamentals (Coursera)

This course is designed to introduce data privacy to a wide audience and help each participant see how data privacy has evolved as a compelling concern to public and private organizations as well as individuals. In this course, you will hear from legal and technical experts and practitioners who encounter data privacy issues daily.

Jun 3rd 2026
3 Weeks
Learn to code with AI (Coursera) Coursera
Scrimba

Learn to code with AI (Coursera)

Imagine waking up tomorrow as a web developer. What would you want to build? With AI tools like ChatGPT, you're already a developer, regardless of your experience, if you know how to work with them. So in this course, you'll build functional, interactive front-end projects while learning how to write effective prompts and debug and refine your code with the help of AI.

Jun 3rd 2026
2 Weeks
Interactivity with JavaScript (Coursera) Coursera
University of Michigan

Interactivity with JavaScript (Coursera)

If you want to take your website to the next level, the ability to incorporate interactivity is a must. But adding some of these types of capabilities requires a stronger programming language than HTML5 or CSS3, and JavaScript can provide just what you need. With just a basic understanding of the language, you can create a page that will react to common events such as page loads, mouse clicks & movements, and even keyboard input.

Jun 1st 2026
4 Weeks