All Projects → Chymyst → Chymyst Core

Chymyst / Chymyst Core

Licence: apache-2.0
Declarative concurrency in Scala - The implementation of the chemical machine

Programming Languages

scala
5932 projects
dsl
153 projects
declarative
70 projects

Projects that are alternatives of or similar to Chymyst Core

Sobjectizer
An implementation of Actor, Publish-Subscribe, and CSP models in one rather small C++ framework. With performance, quality, and stability proved by years in the production.
Stars: ✭ 172 (+21.13%)
Mutual labels:  concurrency, multithreading, concurrent-programming, actor-model, csp
java-multithread
Códigos feitos para o curso de Multithreading com Java, no canal RinaldoDev do YouTube.
Stars: ✭ 24 (-83.1%)
Mutual labels:  concurrency, multithreading, parallelism, concurrent-programming
Zio
ZIO — A type-safe, composable library for async and concurrent programming in Scala
Stars: ✭ 3,167 (+2130.28%)
Mutual labels:  concurrency, asynchronous-programming, concurrent-programming, functional-programming
Concurrencpp
Modern concurrency for C++. Tasks, executors, timers and C++20 coroutines to rule them all
Stars: ✭ 340 (+139.44%)
Mutual labels:  concurrency, multithreading, asynchronous-programming, concurrent-programming
So 5 5
SObjectizer: it's all about in-process message dispatching!
Stars: ✭ 87 (-38.73%)
Mutual labels:  concurrency, multithreading, actor-model, csp
Tascalate Concurrent
Implementation of blocking (IO-Bound) cancellable java.util.concurrent.CompletionStage and related extensions to java.util.concurrent.ExecutorService-s
Stars: ✭ 144 (+1.41%)
Mutual labels:  concurrency, asynchronous-programming, concurrent-programming
Pht
A new threading extension for PHP
Stars: ✭ 175 (+23.24%)
Mutual labels:  concurrency, multithreading, parallelism
Actors.jl
Concurrent computing in Julia based on the Actor Model
Stars: ✭ 95 (-33.1%)
Mutual labels:  actor-model, concurrency, concurrent-programming
traffic
Massively real-time traffic streaming application
Stars: ✭ 25 (-82.39%)
Mutual labels:  actor-model, concurrency, concurrent-programming
scalable-concurrent-containers
High performance containers and utilities for concurrent and asynchronous programming
Stars: ✭ 101 (-28.87%)
Mutual labels:  concurrency, concurrent-programming, asynchronous-programming
transit
Massively real-time city transit streaming application
Stars: ✭ 20 (-85.92%)
Mutual labels:  actor-model, concurrency, concurrent-programming
Golang Tutorials
Go Tutorials - Let's get our hands really dirty by writing a lot of Golang code
Stars: ✭ 277 (+95.07%)
Mutual labels:  concurrency, concurrent-programming, functional-programming
Plasma
Plasma Programming Language
Stars: ✭ 133 (-6.34%)
Mutual labels:  concurrency, parallelism, functional-programming
theater
Actor framework for Dart. This package makes it easier to work with isolates, create clusters of isolates.
Stars: ✭ 29 (-79.58%)
Mutual labels:  actor-model, concurrency, multithreading
mux-stream
(De)multiplex asynchronous streams
Stars: ✭ 34 (-76.06%)
Mutual labels:  concurrency, concurrent-programming, asynchronous-programming
Hamsters.js
100% Vanilla Javascript Multithreading & Parallel Execution Library
Stars: ✭ 517 (+264.08%)
Mutual labels:  concurrency, multithreading, parallelism
Fucking Java Concurrency
🎏 Simple show cases of java concurrency problems, seeing 🙈 is believing 🐵
Stars: ✭ 779 (+448.59%)
Mutual labels:  concurrency, parallelism, concurrent-programming
Left Right
A lock-free, read-optimized, concurrency primitive.
Stars: ✭ 1,245 (+776.76%)
Mutual labels:  concurrency, multithreading
Go Concurrency
This repos has lots of Go concurrency, goroutine and channel usage and best practice examples
Stars: ✭ 84 (-40.85%)
Mutual labels:  concurrency, multithreading
Imminent
A composable Futures library for Clojure
Stars: ✭ 88 (-38.03%)
Mutual labels:  concurrency, parallelism

Join the chat at https://gitter.im/chymyst-core/Lobby Build Status Coverage Status License Github Tag Maven Central

Chymyst — declarative concurrency in Scala

This repository hosts Chymyst Core — a domain-specific language for purely functional, declarative concurrency, implemented as a Scala library. Chymyst is a framework-in-planning that will build upon Chymyst Core to enable creating concurrent applications declaratively.

Chymyst (pronounced “chemist”) is a clean-room implementation of the chemical machine paradigm, known in the academic world as Join Calculus (JC). JC has the same expressive power as CSP (Communicating Sequential Processes) and the Actor model, but is easier to use and reason about, more high-level and more declarative. (See also Conceptual overview of concurrency.)

The code is extensively tested under Oracle JDK 8 with Scala 2.11.8, 2.11.11, and 2.12.2-2.12.6.

Version history and roadmap

Overview of Chymyst and the chemical machine programming paradigm

Concurrency in Reactions: Get started with this extensive tutorial book

Selected tutorial chapters from the book:

Project documentation at Github Pages

From actors to reactions: a guide for those familiar with the Actor model

Show me the code: An ultra-short guide to Chymyst

A "Hello, world" project

Presentations on Chymyst and on the chemical machine programming paradigm

Nov. 18, 2017: Declarative concurrent programming with Chymyst. Presented at the Scale by the Bay conference

Oct. 16, 2017: Declarative concurrent programming with Join Calculus. Presented at the Scala Bay meetup:

July 2017: Industry-Strength Join Calculus: Declarative concurrent programming with Chymyst: Draft of a paper describing Chymyst and its approach to join calculus

Nov. 11, 2016: Concurrent Join Calculus in Scala. Presented at Scalæ by the Bay 2016:

Main features of the chemical machine

Comparison of the chemical machine vs. academic Join Calculus

Comparison of the chemical machine vs. the Actor model

Comparison of the chemical machine vs. the coroutines / channels approach (CSP)

Developer documentation for Chymyst Core

Example: the "dining philosophers" problem

The following code snippet is a complete runnable example that implements the logic of “dining philosophers” in a fully declarative and straightforward way.

import io.chymyst.jc._

object Main extends App {
   /** Print message and wait for a random time interval. */
  def wait(message: String): Unit = {
    println(message)
    Thread.sleep(scala.util.Random.nextInt(20))
  }
  
  val hungry1 = m[Unit]
  val hungry2 = m[Unit]
  val hungry3 = m[Unit]
  val hungry4 = m[Unit]
  val hungry5 = m[Unit]
  val thinking1 = m[Unit]
  val thinking2 = m[Unit]
  val thinking3 = m[Unit]
  val thinking4 = m[Unit]
  val thinking5 = m[Unit]
  val fork12 = m[Unit]
  val fork23 = m[Unit]
  val fork34 = m[Unit]
  val fork45 = m[Unit]
  val fork51 = m[Unit]
  
  site (
    go { case thinking1(_)  wait("Socrates is thinking");  hungry1() },
    go { case thinking2(_)  wait("Confucius is thinking"); hungry2() },
    go { case thinking3(_)  wait("Plato is thinking");     hungry3() },
    go { case thinking4(_)  wait("Descartes is thinking"); hungry4() },
    go { case thinking5(_)  wait("Voltaire is thinking");  hungry5() },
  
    go { case hungry1(_) + fork12(_) + fork51(_)  wait("Socrates is eating");  thinking1() + fork12() + fork51() },
    go { case hungry2(_) + fork23(_) + fork12(_)  wait("Confucius is eating"); thinking2() + fork23() + fork12() },
    go { case hungry3(_) + fork34(_) + fork23(_)  wait("Plato is eating");     thinking3() + fork34() + fork23() },
    go { case hungry4(_) + fork45(_) + fork34(_)  wait("Descartes is eating"); thinking4() + fork45() + fork34() },
    go { case hungry5(_) + fork51(_) + fork45(_)  wait("Voltaire is eating");  thinking5() + fork51() + fork45() }
  )
  // Emit molecules representing the initial state:
  thinking1() + thinking2() + thinking3() + thinking4() + thinking5()
  fork12() + fork23() + fork34() + fork45() + fork51()
  // Now reactions will start and print messages to the console.
}

Status of the project

The Chymyst Core library is in alpha pre-release, with very few API changes envisioned for the future.

The semantics of the chemical machine (restricted to single-host, multi-core computations) is fully implemented and tested on many nontrivial examples.

The library JAR is published to Maven Central.

Extensive tutorial and usage documentation is available.

Unit tests (more than 500 at the moment) exercise all aspects of the DSL provided by Chymyst. Test coverage is 100% according to codecov.io.

Test suites also complement the tutorial book and include examples such as barriers, asynchronous and synchronous rendezvous, local critical sections, parallel “or”, parallel map/reduce, parallel merge-sort, “dining philosophers”, as well as many other concurrency algorithms.

Performance benchmarks indicate that Chymyst Core can schedule about 100,000 reactions per second per CPU core, and the performance bottleneck is in submitting jobs to threads (a distant second bottleneck is pattern-matching in the internals of the library).

Run unit tests

sbt test

The tests will print some error messages and exception stack traces — this is normal, as long as all tests pass.

Some tests are timed and will fail on a slow machine.

Run the benchmark application

sbt benchmark/run will run the benchmarks.

To build the benchmark application as a self-contained JAR, run

sbt clean benchmark/assembly

Then run it as

java -jar benchmark/target/scala-2.11/benchmark-assembly-*.jar

To run with FlightRecorder:

sbt benchmark/runFR

This will create the file benchmark.jfr in the current directory. Open that file with jmc (Oracle's "Java Mission Control" tool) to inspect Code and then the "Hot Methods" (places where most time is spent).

Use Chymyst Core in your programs

Chymyst Core is published to Maven Central. To pull the dependency, add this to your build.sbt at the appropriate place:

libraryDependencies += "io.chymyst" %% "chymyst-core" % "latest.integration"

To use the chemical machine DSL, add import io.chymyst.jc._ in your Scala sources.

See the "hello, world" project for an example.

Build the library JARs

To build the library JARs:

sbt core/package core/package-doc

This will prepare JAR assemblies as well as their Scaladoc documentation packages.

The main library is in the core JAR assembly (core/target/scala-2.11/core-*.jar). User code should depend on that JAR only.

Prepare new release

  • Edit the version string at the top of build.sbt
  • Make sure there is a description of changes for this release at the top of docs/roadmap.md
  • Commit everything to master and add tag with release version
  • Push everything (with tag) to master; build must pass on CI

Publish to Sonatype

$ sbt
> project core
> +publishSigned
> sonatypeRelease

If sonatypeRelease fails due to any problems with POM files while +publishSigned succeeded, it is possible to release manually on the Sonatype web site (requires login). Go to "Staging Repositories" and execute the actions to "promote" the release.

Trivia

Robert Boyle's self-flowing flask

This drawing is by Robert Boyle, who was one of the founders of the science of chemistry. In 1661 he published a treatise titled “The Sceptical Chymist”, from which the Chymyst framework borrows its name.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].