Upload
anatolii-kmetiuk
View
327
Download
2
Embed Size (px)
Citation preview
SubScript: A Process Algebra extension
progress and perspectives
Anatolii Kmetiuk Andre van Delft
Plan
• Introduction of the language
• Examples and features available
• Future development
Introduction of the language
Meet SubScript
• An extension to Scala programming language
• Adds a syntax for process description inspired by the Algebra of Communicating Processes
• Aims for simplification of event-driven and concurrent programming
Brief history• Started as a library (VM), then the syntax was added by a compiler fork - it was difficult to
get started
• Developed into a preprocessor based on parser combinators to specify the syntax. It is managed by an SBT plugin - easy to get started and play with the syntax
scalaVersion := "2.11.7"libraryDependencies += "org.subscript-lang" %% "subscript-swing" % "3.0.3"SubscriptSbt.projectSettings
addSbtPlugin("org.subscript-lang" %% "subscript-sbt-plugin" % "3.0.3")
build.sbt
project/build.sbt
Examples and features available
Example: Hello World
import subscript.languageimport subscript._import subscript.Predef._
object Main extends SubScriptApplication {
script live = println("Hello") println("World")
}
Short
Verbose import subscript.language
import subscript._import subscript.Predef._
object Main {
def main(args: Array[String]): Unit = runScript(live)
script live = {:println("Hello"):} {:println("World"):}}
Operators• Sequential: space, line break, “;” - identical
• Parallel: &&, &, ||, | - behaviour inspired by Boolean logic
• Choice: “+” operator selects between its operands
• Disruption: “/“ - left hand side disrupted by the right hand side
• Conditional: if-then-else (boolean script result values as a predicate), do-then-else (script success status as a predicate)
Data Flow• Each script can have a result value, it can be set
with a special syntax
• The result value can be processed using the dataflow notation
script.. live = msg ~~(message: String)~~> println(message) msg = ^"Hello World"
Example application: Eye Testobject Main extends SubScriptApplication {
script.. live = initGui [ new WaitScreen || initData^ ]~~(repos: Repositories)~~> [ new MainScreen(repos); let repos.close()]
initGui = javax.swing.UIManager.setLookAndFeel: "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"
initData = ^{*new DerbyRepo("eyetest-db")*}}
Example application: Eye Test
class Test extends Frame with FrameProcess {
script..
live = mainTestProcess^ / cancelBtn
mainTestProcess = eyeTest("Right")^^1 eyeTest("Left" )^^2
eyeTest(eyeName: String) = let testArea.font = new Font("Ariel", ..., 20) let testArea.text = s"Look with $eyeName eye, OK when ready" let answerField.enabled = false sleep: 250 Key.Enter + okBtn doTest( if(eyeName=="Right") previousScoreRight else previousScoreLeft )^}
Future development
Perspective directions
• User-computer interactions specification
• Prototyping & implementing the behaviour of consumer electronics:TV, cooking plates, ...
• Simulation & verification: railroad interlocking
• SubScriptJS: run in web browser; improve NodeJS
• Preprocessor: ScalaParse & Dotty
https://github.com/scala-subscript/koans
Getting Started: Koans
Getting Started: Cheat Sheet
https://www.cheatography.com/anatoliykmetyuk/cheat-sheets/subscript/
Getting Started: Homepage
• GitHub: https://github.com/scala-subscript/subscript
• Official website: http://subscript-lang.org/
Thank you for your attention!