Office hours

Kyle Dewey
kyledewey at cs dot ucsb dot edu
Miroslav (Mika) Gavrilov
mvg at cs dot ucsb dot edu
Burak Kadron
kadron at cs dot ucsb dot edu

About the course

Why should I care?

As computer scientists, we have to work with programming languages. Programming languages make the task of communicating with a machine easier. To investigate them, we need to know how to write them correctly – know their syntax, and how to understand what is written: know their semantics. Because it’s very easy to create bugs in the code we write, and more often than not painstakingly hard to find and correct them, learning about programming languages as a theoretical basis can be useful: if we could create better, more secure, robust and bug-free languages, anyone using them could probably reap the same benefits for their own various applications.

What will I learn?

This course will give you an overview of how to use, and then construct languages very similar to two real-world ones (Scala and Prolog), chosen as representatives of paradigms not commonly seen by students, as a show of diversity. You will acquire an idea of how to code in a functional environment, which is a valuable skill in the modern industry. Overall, at the end of this course, you will have a deeper understanding of programming languages, their quirks, and know the importance of undefined behaviours, inevitably making you a better programmer!

How is this course evaluated?

There are no exams. There are no in-class assignments or quizzes. Attendance is optional both for lecture and discussions. Your grade is entirely based on seven equally weighted programming assignments. We will be testing your code thoroughly. Check the course syllabus for details on how your grade will reflect this.

Discussion

First Steps

Here are some resources that may be helpful with your journey into Scala:

Using Scala effectively

To learn Scala, do three things consistently:

  • read all warning and error messages carefully: the Scala compiler is far from simple, and uses many analyses to help you determine not only what's wrong with your code, but also how to fix it. To track the errors, the compiler gives you the row and column number in which the error manifests, so good hunting!
  • try not to fight the type-system: Scala is a language with a powerful type-checker. This is generally very useful, if you use it properly. If you've never used a strongly-typed language before, just accept this at face value: the sooner you stop resisting, the better. Bring your questions to us as often as you want to, we know it can be hard.
  • think in terms of moving parts, not changing states: to learn functional programming properly, skip early optimizations. In fact, skip thinking of optimizations at all. Every time you need to change state, create new objects with a different internal state, instead.

To make sure you don't start writing Java code in Scala, we make one thing very explicitly forbidden:

  • you can't use mutable state except where told otherwise. This includes both mutable variables defined with var and mutable collections from the scala.collection.mutable package.

This will consistently test your resolve on all of the aforementioned advice. Not playing along with this one rule will hurt your grade significantly.

Figuring out which class has which methods

The fastest way to work with Scala is to use Scaladoc, the online documentation for classes that are a part of the standard library. The easiest way to get to this point is to search the web for something like "Scala ClassName docs" and look for the result that starts with something like Scala Standard Library 2.12.0 - ClassName.

The documentation can be daunting at first, but reading it regularly (all while asking lots of questions about it) makes it easier and more useful.

We will be giving out notes that go into more detail than the handouts, and may expound on different things. These can be helpful for providing a wider context to the material, and more background information. While these are ordered based on the content of the class, some of them are covered in great detail (being the topic of multiple discussions), and others are only lightly touched upon.

This list will keep growing as we go.