Giter VIP home page Giter VIP logo

mit-6.945-project's Introduction

MIT 6.945 Project: async/await and actors implemented in MIT/GNU Scheme

Introduction

I took Prof. Gerald Jay Sussman's MIT 6.945 Large-scale Symbolic Systems (aka Adventures in Advanced Symbolic Programming) in spring 2019.

As part of the course, we were to propose and complete a project, implementing it in Scheme, utilizing the philosophy of the course, which was:

Concepts and techniques for the design and implementation of large software systems that can be adapted to uses not anticipated by the designer.

My draft proposal contains some interesting ideas, such as:

  1. Concurrency Substrate: async/await and actors

  2. Dataflow Language: implementing dataflow processes like those found in LabVIEW or VHDL

  3. Teachable Actors: teaching actors new behavior via new message processors

  4. 2D Graphics the Way I Think: generate 2D graphics and animation declaratively

  5. Scheme Type System: adding types to Scheme without them getting in the way

  6. Differential Forms Library: build a library to handle differential form calculations

In the end, I chose to implement async/await and actors in MIT/GNU Scheme, as I felt it was one that could be built off of to complete some of the other projects, most of which needed concurrency.

Code

The code for the project is found in concurrency.scm. The only dependency is MIT/GNU Scheme. The code is well documented and organized, so take a look! I think it is a relatively nice example of adding a useful feature like async/await to a programming language without editing the compiler or interpretor. In this case, async/await was built using a simple macro and thread-safe queues. Once you have async/await that executes on threads, actors are easily added to the system.

A small preview is below, which is the definition of the actor loop process that listens via blocking, which is intentional since every actor runs in its own thread, for new messages and then processes them.

;;; This procedure defines the actual actor process. This is what is launched as an
;;; asynchronous process. The actor-loop processes messages as they arive and then recursively
;;; evaluates to wait for the next message. This procedure handles messages global to all actors,
;;; such as the stop message.
(define (actor-loop state message-processors inbox)
  (let* ((message (pop! inbox))                                   ;; Wait for a message to arrive.
	 (message-name (car message))                             ;; Get the message's name.
	 (message-value (cadr message))                           ;; Get the message's value.
         (is-synchronous? (equal? 'sync (caddr message))))        ;; Check synchronous flag.
    (cond ((stop-message? message) state)                         ;; Check for the stop message.
	  (else (let ((procedure (get-message-processor-procedure message-name
								  message-processors)))
		  (if (equal? 'no-message-processor procedure)    ;; Check for a msg processor
		      (actor-loop state message-processors inbox) ;; Ignore the message
		      (actor-loop (procedure state message-value) ;; Process the message and
				  message-processors              ;;   update the state
				  inbox)))))))

Presentation

The presentation copied below gives a good high-level overview of the work.

slide-01 slide-02 slide-03 slide-04 slide-05 slide-06 slide-07 slide-08 slide-09 slide-10 slide-11 slide-12 slide-13 slide-14

mit-6.945-project's People

Contributors

bmitc avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

jgarte octaviordz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.