CS 21

Reference Material

This page is for reference material that you may find helpful. This page is not exhaustive and it never will be. There may also be things that are out of date. You can help by letting me know of resources that you find helpful (or not) sharing such information with the class.

Doing Research/Going to Graduate School

If you're interested in doing either or both of these things, there is useful information at http://conquer.cra.org/. Also check out my advice on getting started in research.

Run things on your phone!

Honestly, I don't know about iPhones. Please share useful information here.

For Android phones, I have been using Termux since my first smart phone (a Google G1!). Alas, you can't get it from the Google Play Store any more, so you have to go to F-Droid. I always have Erlang, C, C++, and Python installed.

If you find an iPhone or Google Play Store terminal application that works well, please share!

Erlang Resources

erlang.org and erlang-solutions.com are very good resources. The former has lots of excellent documentation, though it can be hard to find things. I normally use Google and then follow links to erlang.org. Again, when you find it, the documentation there is really good! The latter has downloads, offers support, conference information, and even Erlang and Elixir job postings!

For the assignments, you can run Erlang on our department servers. I have also had it installed on the Tufts Supercomputer Center.

However, you will find it helpful to have it installed on your own computer. You should test everything on the department servers just to be sure, of course, but, if your intallation is within a version of the servers, you should be in good shape. Still, check!

For projects, you can install it on phones, Raspberry Pi's, etc. There are boards that are designed to run Erlang and Elixir from Grisp. Remember, Erlang can be installed and run on network switches, industrial controllers, and on and on — it can be made to fit in a small device!

It can be a little befuddling if you want to build an Erlang system that supports ordinary Unix command-line interactions. It's not that bad. Erlang, the Unix way shows a general way to build a kind of "anything server" that shell scripts can interact with. I have done some similar things, too. If you want to do something more scalable, I recommend using dynamic node names in scripts, though there is a function call or two you will have to make to establish connectivity to existing Erlang nodes. Ask me if you want to do this — I'm happy to share some examples.

To install Erlang:

http://www.erlang.org has tutorials and an extensive language manual. There are also lots of videos, including Erlang: The Movie. There is an Erlang YouTube channel — most of the videos are targeted at advanced users, but you may find useful information there.

For an old interactive tutorial, visit http://www.tryerlang.org/.

Learn you Some Erlang for Great Good! is a good introduction. There is the web site and the book. Both are a bit out of date, but the web site is more out of date. However, the basics of Erlang have not changed.

The Erlang Factory web site has lots of information about Erlang/Elixir conferences. There is a conference every 6 months, alternating between Europe and the US. They are very good about having all the talks up on YouTube.

Liam Strand wrote a primer on rebar3, that he thinks could be helpful.

Alex Lenail found this, which he thinks is useful.

An Erlang binaries cheat sheet. Binaries in Erlang rock! If you've done manipulations of binary data in C or C++, you will be blown away by Erlang's facilities for such things. You can do pattern matching on a network packet for whatever protocol on the byte or even bit level! Of course, there are a lot of options that can make it a little confusing, and here is a cheat sheet. I don't find it super clear, but some of the examples are useful.

Editor/IDE support for Erlang

Erlang is reasonaly well supported by a variety of tools. I use Emacs, but vim, VS Code, Eclipse, Sublime, IntelliJ, and others have good support, too. They all do syntax highlighting, and you may also get some code completion and templates, too. See Erlang community page for some links.

For VS Code, open up the extensions and search for Erlang. I haven't really used this for much, but I have the Erlang, Erlang/OTP, and VSCode Erlang workbench installed. If you find something that works, please share!

I mostly use Emacs, which has some options. They all do syntax highlighting and supply OTP skeletons (code templates). Some do auto-compltion. Some let you run an Erlang shell inside Emacs with M-x run-erlang.

Caleb Helbling recommends using the IntelliJ IDE with the Erlang plugin. I haven't used it, but Caleb has done tons of Erlang programming, so he would know.

There is lots of good Erlang example code out there. The book Erlang and OTP in Action has many examples, and all its code is available from github. Clone https://github.com/erlware/Erlang-and-OTP-in-Action-Source.git

Chapter 3, for example, contains an example program that creates an RPC server using sockets: it takes Erlang function calls and runs them for you. There's a gen_server, and then individual RPC requests go over a socket.

You may refer to relevant sections of the text for the pursposes of your projects. I'm making that available here only to you. The book text is not to be redistributed, and you'll have to log in using your student account to see it.

You may also want to consult the official OTP Design Principles document as well as the information available at Nine Nines.

For learning about Erlang applications and releases, in addition to the above resources, you may checkout How I Start by the author of Learn You Some Erlang.

A great video about code factoring. It's in Erlang, but really, it's great advice for programming in any language!

Spawned Shelter has an impressive collection of curated Erlang links from the beginner to professional level.

Other Actor or CSP Languages

Erlang has a successor language, elixir that is increasing in popularity. It has a syntax inspired by the Ruby language, but it runs on the Erlang virtual machine (the BEAM) and interoperates seamlessly with Erlang (including the ability to perform function calls back and forth between languages and use the OTP). It has a hierarchical module system and modern package management, which is very nice. It also supports a Ruby on Rails type web programming framework called Phoenix.

Actor and CSP approaches to concurrency are also finding their way into mainstream languages. For example, akka brings a mostly actor-style model to the Java virtual machine, and it interoperates with the Java ecosystem. Haskell has an actor facility, now, too.

I considered using the go (golang) programming language for the course, because it's another language designed to be concurrent from the ground up. It's a CSP-based language developed by Google. You can read a little sales pitch. Here is a video that describes Erlang for Golang developers.

There is a CSP model for Java, too.

Python Resources

http://www.python.org has extensive documentation, including tutorials and an extensive language manual. Be aware that we will be using Python version 3, not version 2.7. Finally, we will be working with Allen Downey's Little Book of Semaphores, which is pre-version-3.

A couple students have recommended Google's training materials, including videos on YouTube.

For learning more about the threading package, besides consulting the Python documentation, there is a brief tutorial on the Python Module of the Week site.

Mac users: Recent OS X releases have an “application resume” feature. This results in a strange message when some applications, including Python programs, open windows. The message looks something like this:

2015-10-02 21:33:14.965 Python[7620:6826297] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/r5/h00tz_rs2lbcp_y0pv2ws5k80000gn/T/org.python.python.savedState

To stop this, type this into a terminal:

defaults write org.python.python ApplePersistenceIgnoreState NO
You can review the defaults man page if you like.

Threads

C++11 has standardized what seems like a very nice threads package. It's ultimately based on pthreads, but it appears to be much easier to use (I've only looked at examples and not tried it myself). For a good introduction to the C++ threads package, you can see https://www.classes.cs.uchicago.edu/archive/2013/spring/12300-1/labs/lab6/ (thanks to Mike Shah for finding that!). For an example tcp server in C++, you can see https://github.com/TheiaRT/libiris/blob/master/tcp_server.cpp (which was actually part of a previous project for this course!).

Software Transactional Memory

There was an ASPLOS paper (recommended by Noah Mendelsohn) that has a decent summary of prior work and a good bibliography.

NB The above link goes to the ACM Digital Library. Tufts has an institutional membership, so you can access such links without having your own DL subscription from the Tufts network (including via VPN). If you have trouble with the link, try it from on campus.

Here is the note from Noah to me in which he recommends the paper:

Mark:

I've been working my way through the latest ASPLOS proceedings and
came on this from David Cheriton's group at Stanford:

http://dl.acm.org/citation.cfm?id=2541952&CFID=524114784&CFTOKEN=11098803

I have no idea whether you actually are interested in pursuing this
stuff for the course, but if so I found this of interest for several
reasons in addition to the fact that the specific technique reported
is interesting.

* It mentions in passing that both Intel and IBM have included
 transactional memory support in recent processors.  I hadn't
 realized things had gone that far with adoption. References
 for hardware support appear to include:

 (IBM) http://dl.acm.org/citation.cfm?id=2485942
 (Intel) http://pages.cs.wisc.edu/~rajwar/papers/SC13_TSX.pdf

 Quoting from the IBM paper:

    On the twentieth anniversary of the original publication
    [ref to Herlihy paper], following ten years of intense
    activity in the research literature, hardware support for
    transactional memory (TM) has finally become a commercial
    reality, with HTM-enabled chips currently or soon-to-be
    available from many hardware vendors. In this paper we
    describe architectural support for TM added to a future
    version of the Power ISA TM.

 The Intel TSX stuff also seems to be significant commitment.

* There apparently are proposed C++ extensions to enable the
 compiler to exploit TM, and those are being proposed jointly by
 Intel, IBM and Oracle:

 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3725.pdf

* The Cheriton paper indirectly summarizes a lot of the
 interesting earlier work on TM and has an excellent biblio.

So, all of this reinforces my intuition that TM has at least a 50/50
chance of going mainstream as a concurrency model. I think it would be
really fun if you could find half a session or a whole session in
which to present the topic, at least as something to watch. We're now
seeing mainstream support in CPU chips from leading vendors and
standards track specifications proposed for languages like C++.

What do you think? In any case, I learned an lot about the state of TM
by reading the Cheriton paper and following references to what others
have done lately.

Cheers.

Noah

Sources I've consulted

Other Links

Mark A. Sheldon (msheldon@cs.tufts.edu)
Last Modified