Doing Research/Going to Graduate School
If you're interested in doing either or both of these things, there is useful information athttp://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:
- On a Mac, use homebrew (as
I do for managing most software on my Mac):
brew update; brew install erlang
- On a Linux machine with Ubuntu-style package management:
sudo apt-get update; sudo apt-get install erlang
- For Windows and for other binary installations, see the Erlang Solutions download page
- For Termux:
pkg 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
.
- There is an Erlang Language Server, which I tried on my previous Mac. It was usable but a little glitchy in 2022, but I will likely try it again on my new Mac.
- Erlang distributions usually ship with Emacs Lisp code for an
Erlang Mode. This is available on our department servers by
just putting the following in your
~/.emacs
:(autoload 'erlang-mode "erlang" "Major mode for editing Erlang programs." t) (setq auto-mode-alist (append '(("\\.erl" . erlang-mode) ; Erlang source ("\\.hrl" . erlang-mode) ; Erlang header ("\\.yaws" . erlang-mode) ; Yaws web server ("\\.xrl" . erlang-mode)) ; Erlang lex file auto-mode-alist))
- If you install Erlang, then you have to find the
installation Erlang root directory. Once you have that, you
can do this (which I put onto my PixelBook):
;; Erlang support ;; First save location of the Erlang installation ;; You may need to search around for it ;; This worked on the on my Chromebook (setq erlang-root (convert-standard-filename "/usr/lib/erlang")) ;; Tell emacs where to find the Emacs support files ;; relative to the erlang installation ;; Alas, you will have to change this if the tools version changes (add-to-list 'load-path (concat erlang-root (convert-standard-filename "/lib/tools-3.2/emacs"))) ;; Tell Emacs where to find Erlang executables ;; relative to the erlang installation (add-to-list 'exec-path (concat erlang-root (convert-standard-filename "/bin"))) (require 'erlang-start) ;; Start up Erlang support! ;; Loads Erlang mode automatically ;; You'll get Erlang mode when you edit .erl or .hrl files (autoload 'erlang-mode "erlang" "Major mode for editing Erlang programs." t)
Restart Emacs, and you're ready to go!
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.
- Joe Armstrong, Concurrency Oriented Programming in Erlang, 2003.
- Steve Vinoski, Rediscovering Distributed Systems, IEEE Computer, March/April 2014, pp. 3–6.
- Phil Trinder, Comparing C++ and Erlang for Motorola Telecoms Software, Heriot-Watt University, 2006.
- The Erlang Runtime System, AKA The BEAM Book describes the nitty gritty details of how the BEAM virtual machine works.
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 NOYou 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 onpthreads
, 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 finally 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
- Max Hailperin. Operating Systems and Middleware. Thomson. 2007.
- Shameem Akhter and Jason Roberts. Multi-Core Programming: Increasing Performance through Software Multi-threading. Intel Press. 2006.
- Franklyn Turbak, David K. Gifford, with Mark A. Sheldon. Design Concepts in Programming Languages. MIT Press. 2008. Unpublished chapter on concurrency (was supposed to be on the web supplement, but it doesn't seem to be there).
- Kenneth C. Louden. Programming Languages: Principles and Practice, 2nd edition. Thomson. 2003.
- Fred Hébert. Learn You Some Erlang for Great Good! A Beginner's Guide. no starch press. 2013. The web site is good, too.
- Joe Armstrong. Programming Erlang (2nd edition). The Pragmatic Bookshelf. 2013. A great book by one of the language's inventors.
- Bruce A. Tate. Seven Languages in Seven Weeks: A Pragmatic Guide to Learning Programming Languages. The Pragmatic Bookshelf. 2010. Has a chapter on Erlang. Also has a chapter on Prolog, and discusses concurrency issues in some other languages, including Scala.
- Robert Love. Linux Kernel Development: A thorough guide to the
design and implementation of hte Linux kernel, 3rd
edition. Addison Wesley. 2010.
This is one of the most wonderful books every! It's nominally about the Linux kernel, but much of the text serves as a fantastic introduction to operating systems, better then most OS textbooks, with real examples from the Linux kernel. I've referred to it many times for at least 3 different courses!
- Doug Lea's Home Page. Does concurrent programming in Java.
- David Bunde's inclusion of thread programming into an introductory course.
Other Links
- Writing Quality Code in Erlang is a great talk about factoring code in general, with all the examples in Erlang, of course.
- The Scala programming langauge seems interesting and is developing quite a following.
- The Free Lunch is Over, Herb Sutter, Dr. Dobb's Journal, March 2005.
- Rob Pike talk: Concurrency is not Parallelism, why concurrency, intro to go.
- Edsger W. Dijkstra is one of our most influential computing pioneers. The University of Texas at Austin maintains a site of his numerous contributions. EWD 123 is extremely good and describes many of the problems and solutions you'll see in this course.