LMU ☀️ CMSI 3801
LANGUAGES AND AUTOMATA I
HOMEWORK #4 Due: 2025-11-07

Learning Objectives

With this assignment you will demonstrate:

Readings and Videos

Please:

Instructions

Work in teams of 1 to 4 students.

Do all work in the GitHub repository you created in the previous assignment.

Remember: There must be only one official repository per group.

Repository

Add files according to the folder structure below. You will be implementing the assigned functions and classes from scratch. The test files have been written for you; follow the links to obtain them.

.
├── code/
│   ├── java/
│   │   ├── Exercises.java
│   │   └── ExercisesTest.java
│   ├── kotlin/
│   │   ├── Exercises.kt
│   │   └── ExercisesTest.kt
│   ├── swift/
│   │   ├── exercises.swift
│   │   └── main.swift

Code

Implement—for Java, Kotlin, and Swift—modules with the following functions and types.

Strive to use the most idiomatic constructs of each language in your solutions.

Generative AI is permitted for this assignment; however, there is no guarantee that it will produce code that meets all of the requirements. Do not try to prompt your way to working solutions. Make sure to thoroughly review and test any code produced by AI tools.

To use the supplied unit tests, make sure you’ve created the test-data folder and its associated files as described in the instructions for Homework 2. Run the tests in their corresponding code folders, with the following commands:

Exercises

In the file exercises/hw4.md, provide solutions to the following problems. You will need to do research, as not all of these topics were covered in class. For exercises that ask you for prose answers, please be comprehensive and demonstrate a broad understanding. But avoid long-winded, silly gen-ai answers. Expect deductions for verbatim copies of AI slop. Be precise and concise.

  1. In Java, which keywords (if any) are used to indicate a class may have (a) no instances, (b) only a fixed number of instances, (c) no subclasses, (d) only a fixed number of subclasses.
  2. Very briefly, list the four main differences between a Swift class and a Swift struct.
  3. Does Swift have null references? If so, show an example. If not, how exactly did they prevent this billion dollar mistake?
  4. Assuming Dog is a subclass of Animal, should you be able to assign an expression of List<Dog> to a variable type constrained as List<Animal> in its declaration? Answer not in terms of what some languages do, but what makes the most sense in terms of type safety.
  5. Why is Swift’s Void type weirdly named? What is their “excuse” for using that term for what is essentially a unit type?
  6. What is the type of a supplier in Swift?
  7. Why did Yegor Bugayenko think Alan Kay was wrong about being wrong about using the term “object” when he coined the term “object-oriented programming”?
  8. What is the difference between class-based and prototype-based OOP?
  9. List all the things that a Java record automatically generates.
  10. Java does not (yet?) have companion objects like Kotlin. What do Java programmers have to use instead?

Please use professional and well-structured Markdown formatting for your answers. Take pride in your work. Show you care.

Submission

To submit your work, choose one and only one team member to submit to BrightSpace (1) the names of all team members, (2) the URL of your private repository, and (3) an affidavit for each team member stating that they have done the assigned book readings and reviewed the aforementioned course notes pages.

Teamwork

Remember that, when working in teams, all team members should participate in generating solutions and are responsible for understanding all submitted answers. Ideally, each team member should produce individual answers for all exercises, and the team should combine them to produce the ultimate submissions.

Grading

You will be graded both on the correctness of your solutions, adherence to each language’s conventions, the following of the assignment instructions, and the cleanliness of the repository. Feedback will be in the form of deductions for such things as:

This list is not exhaustive, but should help in getting you used to paying attention to your submissions and taking pride in your work. Note that most code editors have plugins that will auto-format your code and even look for suspicious coding practices. You are strongly encouraged to use them.

Your homework submission will be the state of your repository on your main branch, at 18:00 in the America/Los Angeles time zone on the due date.