The code in this repository is part of the Programming Languages and Paradigms (PLP) Seminar at the University of Zurich.
In the Tutorial session, we will implement a simple web crawler that fetches the titles of a list of websites both synchronously and concurrently using goroutines.
- Download and install Go from the official website: https://golang.org/dl/
- Follow the installation instructions for your operating system.
- Verify the installation by opening a terminal and running:
You should see the installed Go version.
go version
- Clone this repository to your local machine:
git clone https://github.com/vichcruz/programming-languages-tutorial.git
- Navigate to the project directory:
cd programming-languages-tutorial
- Open a terminal and navigate to the project directory.
- The exercise code is located in the
version-0folder. You can run it using:cd version-0 go run .
- We will progressively work on versions 1 to 4 during the tutorial.
- The complete solution code is located in the
version-5folder. Please don't look at it yet. If you want to see the expected output of the crawler, you can run it using:cd version-5 go run .
main.go: The main entry point of the application.Fetcher.go: Contains the function to fetch the title of a webpage.ConcurrentCrawler.go: Implements the concurrent web crawler using goroutines.go.mod: Go module file specifying dependencies.
version-0: Basic synchronous web crawler.version-1: Introduces goroutines for concurrent crawling, but without proper synchronization or result collection.version-2: Adds a channel to receive titles from concurrent goroutines, but has a bug in the receiving loop.version-3: Fixes the channel receiving logic and adds timing measurements to compare concurrent vs synchronous performance.version-5: Complete solution with proper concurrent crawler usingsync.WaitGroupfor goroutine synchronization and buffered channel for result collection.