SlideShare a Scribd company logo
1 of 39
Download to read offline
CSCSP WITH IDIOMATIC SCALA
SCALA-GOPHER
https://github.com/rssh/scala-gopher
goo.gl/dbT3P7
Ruslan Shevchenko
VertaMedia
scala-gopher
❖ Akka extension + Macros on top of SIP22-async
❖ Integrate CSP Algebra and scala concurrency primitives
❖ Provides:
❖ asynchronous API inside general control-flow
❖ pseudo-synchronous API inside go{ .. } or async{ ..}
blocks
❖ Techreport: goo.gl/dbT3P7
def nPrimes(n:Int):Future[List[Int]]= {
val in = makeChannel[Int]()
val out = makeChannel[Int]()
go {
for(i <- 1 to Int.MaxValue) in.write(i)
}
go {
select.fold(in){ (ch,s) =>
s match {
case p:ch.read => out.write(p)
ch.filter(_ % p != 0)
}
}
}
go {
for(i <- 1 to n) yield out.read
}
}
def nPrimes(n:Int):Future[List[Int]]= {
val in = makeChannel[Int]()
val out = makeChannel[Int]()
go {
for(i <- 1 to n*n) out.write(i)
}
go {
select.fold(in){ (ch,s) =>
s match {
case p:ch.read => out.write(p)
ch.filter(_ % p != 0)
}
}
}
go {
for(i <- 1 to n) yield out.read
}
}
go {
for(i <- 1 to Int.MaxValue)
in.write(i)
}
def nPrimes(n:Int):Future[List[Int]]= {
val in = makeChannel[Int]()
val out = makeChannel[Int]()
go {
for(i <- 1 to Int.MaxValue) in.write(i)
}
go {
select.fold(in){ (ch,s) =>
s match {
case p:ch.read => out.write(p)
ch.filter(_ % p != 0)
}
}
}
go {
for(i <- 1 to n) yield out.read
}
}
go {
select.fold(in){ (ch,s) =>
s match {
case p:ch.read => out.write(p)
ch.filter(_ % p != 0)
}
}
}
def nPrimes(n:Int):Future[List[Int]]= {
val in = makeChannel[Int]()
val out = makeChannel[Int]()
go {
for(i <- 1 to Int.MaxValue) in.write(i)
}
go {
select.fold(in){ (ch,s) =>
s match {
case p:ch.read => out.write(p)
ch.filter(_ % p != 0)
}
}
}
go {
for(i <- 1 to n) yield out.read
}
}
go {
for(i <- 1 to n) yield out.read
}
def nPrimes(n:Int):Future[List[Int]]= {
val in = makeChannel[Int]()
val out = makeChannel[Int]()
go {
for(i <- 1 to Int.MaxValue) in.write(i)
}
go {
select.fold(in){ (ch,s) =>
s match {
case p:ch.read => out.write(p)
ch.filter(_ % p != 0)
}
}
}
go {
for(i <- 1 to n) yield out.read
}
}
Goroutines
❖ go[X](body: X):Future[X]
❖ Wrapper around async +
❖ translation of high-order functions into async form
❖ handling of defer statement
Goroutines
❖ translation of hight-order functions into async form
❖ f(g): f: (A=>B)=>C in g: A=>B,
❖ g is invocation-only in f iff
❖ g called in f or in some h inside f : g invocation-only in h
❖ g is
❖ not stored in memory behind f
❖ not returned from f as return value
❖ Collection API high-order methods are invocation-only
Translation of invocation-only functions
❖ f: ((A=>B)=>C), g: (A=>B), g invocation-only in f
❖ f’: ((A=>Future[B])=>Future[C]) g’: (A=>Future[B])
❖ await(g’) == g => await(f’) == f
❖ f’ => await[translate(f)]
❖ g(x) => await(g’(x))
❖ h(g) => await(h’(g’)) iff g is invocation-only in h
❖ That’s all
❖ (implemented for specific shapes and parts of scala collection
API)
def nPrimes(n:Int):Future[List[Int]]= {
val in = makeChannel[Int]()
val out = makeChannel[Int]()
go {
for(i <- 1 to n*n) in.write(i)
}
go {
select.fold(in){ (ch,s) =>
s match {
case p:ch.read => out.write(p)
ch.filter(_ % p != 0)
}
}
}
go {
for(i <- 1 to n) yield out.read
}
}
go {
for(i <- 1 to n) yield out.read
}
go {
(1 to n).map(i => out.read)
}
async{
await(t[(1 to n).map(i => out.read)])
}
async{
await((1 to n).mapAsync(t[i => async(out.read)]))
}
async{
await((1 to n).mapAsync(i => async(await(out.aread)))
}
mapAsync(i => out.aread)
Channels
❖ Channel[A] <: Input[A] + Output[A]
❖ Unbuffered
❖ Buffered
❖ Dynamically growing buffers [a-la actor mailbox]
❖ One-time channels [Underlaying promise/Future]
❖ Custom
CSP
Input[A] - internal API
trait Input[A]
{
type read = A
def cbread(f: ContRead[A,B]=>Option[
ContRead.In[A] => Future[Continuated[B]])
…..
}
case class ContRead[A,B](
function: F,
channel: Channel[A],
flowTermination: FlowTermination[B]
)
// in ConRead companion object
sealed trait In[+A]
case class Value(a:A) extends In[A]
case class Failure(ex: Throwable] extends In[Nothing]
case object Skip extends In[Nothing]
case object ChannelClosed extends In[Nothing]
ContRead[A,B].F
Continuated[B]
• ContRead
• ContWrite
• Skip
• Done
• Never
Input[A] - external API
trait Input[A]
{
……
def aread: Future[A] = <implementation…>
def read: A = macro <implementation … >
….
def map[B](f: A=>B): Input[B] = ….
// or, zip, filter, … etc
await(aread)
+ usual operations on streams in functional language
Output[A] - API
trait Output[A]
{
type write = A
def cbwrite(f: ContWrite[A,B]=>Option[
(A,Future[Continuated[B]])],
ft: FlowTermination[B])
…..
def awrite(a:A): Future[A] = ….
def write(a:A): A = …. << await(awrite)
….
ContWrite[A,B].F
case class ContWrite[A,B](
function: F,
channel: Channel[A],
flowTermination: FlowTermination[B]
)
Selector ss
go {
for{
select{
case c1 -> x : … // P
case c2 <- y : … // Q
}
}
Go language:
go {
select.forever {
case x : c1.read => … // P
case y : c2.write => … // Q
}
}
Scala:
Provide set of flow combinators:
forever, once, fold
select.aforever {
case x : c1.read => … // P
case y : c2.write => … // Q
}
select: fold API
def fibonacci(c: Output[Long], quit: Input[Boolean]): Future[(Long,Long)] =
select.afold((0L,1L)) { case ((x,y),s) =>
s match {
case x: c.write => (y, x+y)
case q: quit.read =>
select.exit((x,y))
}
}
fold/afold:
• special syntax for tuple support
• ’s’: selector pseudoobject
• s match must be the first statement
• select.exit((..)) to return value from flow
Transputer
❖ Actor-like object with set of input/output ports, which
can be connected by channels
❖ Participate in actor systems supervisors hierarchy
❖ SelectStatement
❖ A+B (parallel execution, common restart)
❖ replicate
Transputer: select
class Zipper[T] extends SelectTransputer
{
val inX: InPort[T]
val inY: InPort[T]
val out: OutPort[(T,T)]
loop {
case x: inX.read => val y = inY.read
out write (x,y)
case y: inY.read => val x = inX.read
out.write((x,y))
}
}
inX
inY
out
Transputer: replicate
val r = gopherApi.replicate[SMTTransputer](10)
( r.dataInput.distribute( (_.hashCode % 10 ) ).
.controlInput.duplicate().
out.share()
)
dataInput
controlInput
share
Programming techniques
❖ Dynamic recursive dataflow schemas
❖ configuration in state
❖ Channel-based two-wave generic API
❖ expect channels for reply
Dynamic recursive dataflow
select.fold(output){ (out, s) => s match {
case x:input.read => select.once {
case x:out.write =>
case select.timeout => control.distributeBandwidth match {
case Some(newOut) => newOut.write(x)
out | newOut
case None => control.report("Can't increase bandwidth")
out
}
}
case select.timeout => out match {
case OrOutput(frs,snd) => snd.close
frs
case _ => out
}
}
dynamically increase and decrease bandwidth in dependency from load
Dynamic recursive dataflow
select.fold(output){ (out, s) => s match {
case x:input.read => select.once {
case x:out.write =>
case select.timeout => control.distributeBandwidth match {
case Some(newOut) => newOut.write(x)
out | newOut
case None => control.report("Can't increase bandwidth")
out
}
}
case select.timeout => out match {
case OrOutput(frs,snd) => snd.close
frs
case _ => out
}
}
dynamically increase and decrease bandwidth in dependency from load
case select.timeout =>
control.distributeBandwidth match {
case Some(newOut) => newOut.write(x)
out | newOut
case None =>
control.report("Can't increase bandwidth")
out
Dynamic recursive dataflow
select.fold(output){ (out, s) => s match {
case x:input.read => select.once {
case x:out.write =>
case select.timeout => control.distributeBandwidth match {
case Some(newOut) => newOut.write(x)
out | newOut
case None => control.report("Can't increase bandwidth")
out
}
}
case select.timeout => out match {
case OrOutput(frs,snd) => snd.close
frs
case _ => out
}
}
dynamically increase and decrease bandwidth in dependency from load
case select.timeout => out match {
case OrOutput(frs,snd) => snd.close
frs
case _ => out
}
Channel-based generic API
❖ Endpoint instead function call
❖ f: A=>B
❖ endpoint: Channel[A,Channel[B]]
❖ Recursive
❖ case class M(A,Channel[M])
❖ f: (A,M) => M (dataflow configured by input)
Channel-based generic API
trait Broadcast[T]
{
val listeners: Output[Channel[T]]
val messages: Output[T]
def send(v:T):Unit = { messages.write(v) }
….
• message will received by all listeners
Channel-based generic API
class BroadcastImpl[T]
{
val listeners: Channel[Channel[T]]
val messages: Channel[T] = makeChannel[Channel[T]]
def send(v:T):Unit = { messages.write(v) }
….
}
// private part
case class Message(next:Channel[Message],value:T)
select.afold(makeChannel[Message]) { (bus, s) =>
s match {
case v: messages.read => val newBus = makeChannel[Message]
current.write(Message(newBus,v))
newBus
case ch: listeners.read => select.afold(bus) { (current,s) =>
s match {
case msg:current.read => ch.awrite(msg.value)
current.write(msg)
msg.next
}
}
current
Channel-based generic API
val listeners: Channel[Channel[T]]
val messages: Channel[T] = makeChannel[]
// private part
case class Message(next:Channel[Message],value:T)
select.afold(makeChannel[Message]) { (bus, s) =>
s match {
case v: message.read => val newBus = makeChannel[Message]
current.write(Message(newBus,v))
newBus
case ch: listener.read => select.afold(bus) { (current,s) =>
s match {
case msg:current.read => ch.awrite(msg.value)
current.write(msg)
msg.next
}
}
• state - channel [bus], for which all listeners are subscribed
• on new message - send one to bus with pointer to the next bus state
• listener on new message in bus - handle, change current and send again
• on new listener - propagate
Channel-based generic API
val listener: Channel[Channel[T]]
val message: Channel[T] = makeChannel[]
// private part
case class Message(next:Channel[Message],value:T)
select.afold(makeChannel[Message]) { (bus, s) =>
s match {
case v: message.read => val newBus = makeChannel[Message]
current.write(Message(newBus,v))
newBus
case ch: listener.read => select.afold(bus) { (current,s) =>
s match {
case msg:current.read => ch.awrite(msg.value)
msg.next
}
}
current
• state - channel [bus], for which all listeners are subscribed
• on new message - send one to bus with pointer to the next bus state
• listener on new message in bus - handle, change current and send again
• on new listener - propagate
s match {
case msg:current.read => ch.awrite(msg.value)
current.write(msg)
msg.next
}
Channel-based generic API
val listener: Channel[Channel[T]]
val message: Channel[T] = makeChannel[]
// private part
case class Message(next:Channel[Message],value:T)
select.afold(makeChannel[Message]) { (bus, s) =>
s match {
case v: message.read => val newBus = makeChannel[Message]
current.write(Message(newBus,v))
newBus
case ch: listener.read => select.afold(bus) { (current,s) =>
s match {
case msg:current.read => ch.awrite(msg.value)
current.write(msg)
msg.next
}
}
current
• state - channel [bus], for which all listeners are subscribed
• on new message - send one to bus with pointer to the next bus state
• listener on new message in bus - handle, change current and send again
•
val newBus = makeChannel[Message]
current.write(Message(newBus,v))
newBus
Scala concurrency libraries
Flexibility
Scalability
Level
Actors
• Actors
• low level,
• great flexibility and scalability
• Akka-Streams
• low flexibility
• hight-level, scalable
• SCO
• low scalability
• hight-level, flexible
• Reactive Isolated
• hight-level, scalable,
• allows delegation
• Gopher
• can emulate each style
Streams
SCO
Subscript
Language
Gopher vs Reactive Isolates
• Isolate
• Events
• Channel
• Transputer/fold
• Input
• Output
Gopher Isolates
One writerMany writers
Channel must have owner
Local Distributed
Loosely coupled (growing buffer)CSP + growing buffer
Scala-gopher: early experience reports
❖ Not 1.0 yet
❖ Helper functionality in industrial software projects.
(utilities, small team)
❖ Generally: positive
❖ transformation of invocation-only hight-order methods
into async form
❖ recursive dynamic data flows
❖ Error handling needs some boilerplate
Error handling: language level issue
val future = go {
………
throw some exception
}
go {
……….
throw some exception
}
Go {
…………
throw some exception
}
Core scala library:
Future.apply
(same issue)
Error is ignored
Developers miss-up Go/go
Errors in ignored value: possible language changes.
❖ Possible solutions:
❖ Optional implicit conversion for ignored value
❖ Special optional method name for calling with ignored value
❖ Special return type
trait Ignored[F]
object Future
{
implicit def toIgnored(f:Future):Ignored[Future] =
….
def go[X](f: X): Future[X]
def go_ignored[X](f:X): Unit
def go(f:X): Ignored[Future[X]] =
Scala-Gopher: Future directions
❖ More experience reports (try to use)
❖ Extended set of notifications
❖ channel.close, overflow
❖ Distributed case
❖ new channel types with explicit distributed semantics
Scala-Gopher: Conclusion
❖ Native integration of CSP into Scala is possible
❖ have a place in a Scala concurrency model zoo
❖ Bring well-established techniques to Scala world
❖ (recursive dataflow schemas; channel API)
❖ Translation of invocation-only high-order functions into
async form can be generally recommended.
❖ (with TASTY transformation inside libraries can be done
automatically)
Thanks for attention
❖ Questions ?
❖ https://github.com/rssh/scala-gopher
❖ ruslan shevchenko: ruslan@shevchenko.kiev.ua

More Related Content

What's hot

Programming Languages: some news for the last N years
Programming Languages: some news for the last N yearsProgramming Languages: some news for the last N years
Programming Languages: some news for the last N yearsRuslan Shevchenko
 
JDK8 Functional API
JDK8 Functional APIJDK8 Functional API
JDK8 Functional APIJustin Lin
 
Scala introduction
Scala introductionScala introduction
Scala introductionvito jeng
 
Scala: functional programming for the imperative mind
Scala: functional programming for the imperative mindScala: functional programming for the imperative mind
Scala: functional programming for the imperative mindSander Mak (@Sander_Mak)
 
Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)Sumant Tambe
 
Scala clojure techday_2011
Scala clojure techday_2011Scala clojure techday_2011
Scala clojure techday_2011Thadeu Russo
 
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017Hardik Trivedi
 
Lego: A brick system build by scala
Lego: A brick system build by scalaLego: A brick system build by scala
Lego: A brick system build by scalalunfu zhong
 
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Sumant Tambe
 
Introduction to D programming language at Weka.IO
Introduction to D programming language at Weka.IOIntroduction to D programming language at Weka.IO
Introduction to D programming language at Weka.IOLiran Zvibel
 
Swift and Kotlin Presentation
Swift and Kotlin PresentationSwift and Kotlin Presentation
Swift and Kotlin PresentationAndrzej Sitek
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lispkyleburton
 
Kotlin boost yourproductivity
Kotlin boost yourproductivityKotlin boost yourproductivity
Kotlin boost yourproductivitynklmish
 
Gentle introduction to modern C++
Gentle introduction to modern C++Gentle introduction to modern C++
Gentle introduction to modern C++Mihai Todor
 
Scalaz Stream: Rebirth
Scalaz Stream: RebirthScalaz Stream: Rebirth
Scalaz Stream: RebirthJohn De Goes
 
C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012 C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012 Sumant Tambe
 
The Kotlin Programming Language, Svetlana Isakova
The Kotlin Programming Language, Svetlana IsakovaThe Kotlin Programming Language, Svetlana Isakova
The Kotlin Programming Language, Svetlana IsakovaVasil Remeniuk
 

What's hot (20)

Programming Languages: some news for the last N years
Programming Languages: some news for the last N yearsProgramming Languages: some news for the last N years
Programming Languages: some news for the last N years
 
JDK8 Functional API
JDK8 Functional APIJDK8 Functional API
JDK8 Functional API
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
Scala: functional programming for the imperative mind
Scala: functional programming for the imperative mindScala: functional programming for the imperative mind
Scala: functional programming for the imperative mind
 
Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)
 
Scala clojure techday_2011
Scala clojure techday_2011Scala clojure techday_2011
Scala clojure techday_2011
 
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
 
Compile time polymorphism
Compile time polymorphismCompile time polymorphism
Compile time polymorphism
 
Lego: A brick system build by scala
Lego: A brick system build by scalaLego: A brick system build by scala
Lego: A brick system build by scala
 
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
 
Introduction to D programming language at Weka.IO
Introduction to D programming language at Weka.IOIntroduction to D programming language at Weka.IO
Introduction to D programming language at Weka.IO
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
 
C++ overview
C++ overviewC++ overview
C++ overview
 
Swift and Kotlin Presentation
Swift and Kotlin PresentationSwift and Kotlin Presentation
Swift and Kotlin Presentation
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lisp
 
Kotlin boost yourproductivity
Kotlin boost yourproductivityKotlin boost yourproductivity
Kotlin boost yourproductivity
 
Gentle introduction to modern C++
Gentle introduction to modern C++Gentle introduction to modern C++
Gentle introduction to modern C++
 
Scalaz Stream: Rebirth
Scalaz Stream: RebirthScalaz Stream: Rebirth
Scalaz Stream: Rebirth
 
C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012 C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012
 
The Kotlin Programming Language, Svetlana Isakova
The Kotlin Programming Language, Svetlana IsakovaThe Kotlin Programming Language, Svetlana Isakova
The Kotlin Programming Language, Svetlana Isakova
 

Viewers also liked

8 minutes of functional primitives
8 minutes of functional primitives8 minutes of functional primitives
8 minutes of functional primitivesArthur Kushka
 
scala-gopher: async implementation of CSP for scala
scala-gopher:  async implementation of CSP  for  scalascala-gopher:  async implementation of CSP  for  scala
scala-gopher: async implementation of CSP for scalaRuslan Shevchenko
 
Openstack 101 by Jason Kalai
Openstack 101 by Jason KalaiOpenstack 101 by Jason Kalai
Openstack 101 by Jason KalaiMyNOG
 
Khoa van-tay-kaba-u10-fingerprint-doorlock-signed
Khoa van-tay-kaba-u10-fingerprint-doorlock-signedKhoa van-tay-kaba-u10-fingerprint-doorlock-signed
Khoa van-tay-kaba-u10-fingerprint-doorlock-signedProtocol Corporation
 
X2 t08 04 inequality techniques (2012)
X2 t08 04 inequality techniques (2012)X2 t08 04 inequality techniques (2012)
X2 t08 04 inequality techniques (2012)Nigel Simmons
 
0721
07210721
0721wzsse
 
Karmapa visit singapore 1999 magazine 噶瑪巴駕臨新加坡特刊
Karmapa visit singapore 1999 magazine 噶瑪巴駕臨新加坡特刊Karmapa visit singapore 1999 magazine 噶瑪巴駕臨新加坡特刊
Karmapa visit singapore 1999 magazine 噶瑪巴駕臨新加坡特刊Lin Zhang Sheng
 
Student Facilitator Presentation
Student Facilitator PresentationStudent Facilitator Presentation
Student Facilitator PresentationZoe Christo
 
对Cite space生成的kml文件进行可视化
对Cite space生成的kml文件进行可视化对Cite space生成的kml文件进行可视化
对Cite space生成的kml文件进行可视化cueb
 
Zhao_Work samples
Zhao_Work samplesZhao_Work samples
Zhao_Work samplesYajing Zhao
 
Reference: Mobile payment industry in china 2012-2015
Reference: Mobile payment industry in china 2012-2015 Reference: Mobile payment industry in china 2012-2015
Reference: Mobile payment industry in china 2012-2015 C. Keiko Funahashi
 
Building A Social Network Waa 1 17 07 V2 Draft
Building A Social Network   Waa   1 17 07 V2 DraftBuilding A Social Network   Waa   1 17 07 V2 Draft
Building A Social Network Waa 1 17 07 V2 DraftMarshall Sponder
 
Example of arrogance in quran the story of qarun and haman
Example of arrogance in quran the story of qarun and haman Example of arrogance in quran the story of qarun and haman
Example of arrogance in quran the story of qarun and haman Amel Hope
 

Viewers also liked (20)

8 minutes of functional primitives
8 minutes of functional primitives8 minutes of functional primitives
8 minutes of functional primitives
 
scala-gopher: async implementation of CSP for scala
scala-gopher:  async implementation of CSP  for  scalascala-gopher:  async implementation of CSP  for  scala
scala-gopher: async implementation of CSP for scala
 
Karylronco
KarylroncoKarylronco
Karylronco
 
Openstack 101 by Jason Kalai
Openstack 101 by Jason KalaiOpenstack 101 by Jason Kalai
Openstack 101 by Jason Kalai
 
dgdgdgdgd
dgdgdgdgddgdgdgdgd
dgdgdgdgd
 
Mig gig first draft
Mig gig first draftMig gig first draft
Mig gig first draft
 
D11jl
D11jlD11jl
D11jl
 
Khoa van-tay-kaba-u10-fingerprint-doorlock-signed
Khoa van-tay-kaba-u10-fingerprint-doorlock-signedKhoa van-tay-kaba-u10-fingerprint-doorlock-signed
Khoa van-tay-kaba-u10-fingerprint-doorlock-signed
 
X2 t08 04 inequality techniques (2012)
X2 t08 04 inequality techniques (2012)X2 t08 04 inequality techniques (2012)
X2 t08 04 inequality techniques (2012)
 
PMD PMP DIPLOMA
PMD PMP DIPLOMAPMD PMP DIPLOMA
PMD PMP DIPLOMA
 
0721
07210721
0721
 
Karmapa visit singapore 1999 magazine 噶瑪巴駕臨新加坡特刊
Karmapa visit singapore 1999 magazine 噶瑪巴駕臨新加坡特刊Karmapa visit singapore 1999 magazine 噶瑪巴駕臨新加坡特刊
Karmapa visit singapore 1999 magazine 噶瑪巴駕臨新加坡特刊
 
Student Facilitator Presentation
Student Facilitator PresentationStudent Facilitator Presentation
Student Facilitator Presentation
 
对Cite space生成的kml文件进行可视化
对Cite space生成的kml文件进行可视化对Cite space生成的kml文件进行可视化
对Cite space生成的kml文件进行可视化
 
Versos
VersosVersos
Versos
 
Zhao_Work samples
Zhao_Work samplesZhao_Work samples
Zhao_Work samples
 
Reference: Mobile payment industry in china 2012-2015
Reference: Mobile payment industry in china 2012-2015 Reference: Mobile payment industry in china 2012-2015
Reference: Mobile payment industry in china 2012-2015
 
Building A Social Network Waa 1 17 07 V2 Draft
Building A Social Network   Waa   1 17 07 V2 DraftBuilding A Social Network   Waa   1 17 07 V2 Draft
Building A Social Network Waa 1 17 07 V2 Draft
 
INGLES A1
INGLES A1INGLES A1
INGLES A1
 
Example of arrogance in quran the story of qarun and haman
Example of arrogance in quran the story of qarun and haman Example of arrogance in quran the story of qarun and haman
Example of arrogance in quran the story of qarun and haman
 

Similar to Scala-Gopher: CSP-style programming techniques with idiomatic Scala.

Embedding Generic Monadic Transformer into Scala. [Tfp2022]
Embedding Generic Monadic Transformer into Scala. [Tfp2022]Embedding Generic Monadic Transformer into Scala. [Tfp2022]
Embedding Generic Monadic Transformer into Scala. [Tfp2022]Ruslan Shevchenko
 
Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...
Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...
Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...GeeksLab Odessa
 
Generic Functional Programming with Type Classes
Generic Functional Programming with Type ClassesGeneric Functional Programming with Type Classes
Generic Functional Programming with Type ClassesTapio Rautonen
 
Scala Functional Patterns
Scala Functional PatternsScala Functional Patterns
Scala Functional Patternsleague
 
Fp in scala with adts part 2
Fp in scala with adts part 2Fp in scala with adts part 2
Fp in scala with adts part 2Hang Zhao
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 FocJAYA
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1AmIt Prasad
 
Делаем пользовательское Api на базе Shapeless
Делаем пользовательское Api на базе ShapelessДелаем пользовательское Api на базе Shapeless
Делаем пользовательское Api на базе ShapelessВадим Челышов
 
function in c
function in cfunction in c
function in csubam3
 
Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version] Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version] Ruslan Shevchenko
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4MKalpanaDevi
 
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...Data Con LA
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
 

Similar to Scala-Gopher: CSP-style programming techniques with idiomatic Scala. (20)

Embedding Generic Monadic Transformer into Scala. [Tfp2022]
Embedding Generic Monadic Transformer into Scala. [Tfp2022]Embedding Generic Monadic Transformer into Scala. [Tfp2022]
Embedding Generic Monadic Transformer into Scala. [Tfp2022]
 
Go a crash course
Go   a crash courseGo   a crash course
Go a crash course
 
Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...
Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...
Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...
 
N flavors of streaming
N flavors of streamingN flavors of streaming
N flavors of streaming
 
String Manipulation Function and Header File Functions
String Manipulation Function and Header File FunctionsString Manipulation Function and Header File Functions
String Manipulation Function and Header File Functions
 
Csp scala wixmeetup2016
Csp scala wixmeetup2016Csp scala wixmeetup2016
Csp scala wixmeetup2016
 
Generic Functional Programming with Type Classes
Generic Functional Programming with Type ClassesGeneric Functional Programming with Type Classes
Generic Functional Programming with Type Classes
 
Scala Functional Patterns
Scala Functional PatternsScala Functional Patterns
Scala Functional Patterns
 
Fp in scala with adts part 2
Fp in scala with adts part 2Fp in scala with adts part 2
Fp in scala with adts part 2
 
Fs2 - Crash Course
Fs2 - Crash CourseFs2 - Crash Course
Fs2 - Crash Course
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 
functions
functionsfunctions
functions
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1
 
Clojure+ClojureScript Webapps
Clojure+ClojureScript WebappsClojure+ClojureScript Webapps
Clojure+ClojureScript Webapps
 
Делаем пользовательское Api на базе Shapeless
Делаем пользовательское Api на базе ShapelessДелаем пользовательское Api на базе Shapeless
Делаем пользовательское Api на базе Shapeless
 
function in c
function in cfunction in c
function in c
 
Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version] Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version]
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
 

More from Ruslan Shevchenko

Papers We Love / Kyiv : PAXOS (and little about other consensuses )
Papers We Love / Kyiv :  PAXOS (and little about other consensuses )Papers We Love / Kyiv :  PAXOS (and little about other consensuses )
Papers We Love / Kyiv : PAXOS (and little about other consensuses )Ruslan Shevchenko
 
Scala / Technology evolution
Scala  / Technology evolutionScala  / Technology evolution
Scala / Technology evolutionRuslan Shevchenko
 
{co/contr} variance from LSP
{co/contr} variance  from LSP{co/contr} variance  from LSP
{co/contr} variance from LSPRuslan Shevchenko
 
Java & low latency applications
Java & low latency applicationsJava & low latency applications
Java & low latency applicationsRuslan Shevchenko
 
Jslab rssh: JS as language platform
Jslab rssh:  JS as language platformJslab rssh:  JS as language platform
Jslab rssh: JS as language platformRuslan Shevchenko
 
Behind OOD: domain modelling in post-OO world.
Behind OOD:  domain modelling in post-OO world.Behind OOD:  domain modelling in post-OO world.
Behind OOD: domain modelling in post-OO world.Ruslan Shevchenko
 
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
JDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation streamJDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation stream
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation streamRuslan Shevchenko
 
Ruslan.shevchenko: most functional-day-kiev 2014
Ruslan.shevchenko: most functional-day-kiev 2014Ruslan.shevchenko: most functional-day-kiev 2014
Ruslan.shevchenko: most functional-day-kiev 2014Ruslan Shevchenko
 
Web architecture - overview of techniques.
Web architecture - overview of  techniques.Web architecture - overview of  techniques.
Web architecture - overview of techniques.Ruslan Shevchenko
 
Javascript in modern scala backend. [russian]
Javascript in modern scala backend.  [russian]  Javascript in modern scala backend.  [russian]
Javascript in modern scala backend. [russian] Ruslan Shevchenko
 
implementation of 'go'-like language constructions in scala (russian)
implementation of 'go'-like language constructions in scala (russian)implementation of 'go'-like language constructions in scala (russian)
implementation of 'go'-like language constructions in scala (russian)Ruslan Shevchenko
 
Play/Scala as application platform (for http://wbcamp.in.ua 2013)
Play/Scala as application platform  (for http://wbcamp.in.ua 2013)Play/Scala as application platform  (for http://wbcamp.in.ua 2013)
Play/Scala as application platform (for http://wbcamp.in.ua 2013)Ruslan Shevchenko
 

More from Ruslan Shevchenko (20)

Svitla talks 2021_03_25
Svitla talks 2021_03_25Svitla talks 2021_03_25
Svitla talks 2021_03_25
 
Akka / Lts behavior
Akka / Lts behaviorAkka / Lts behavior
Akka / Lts behavior
 
Papers We Love / Kyiv : PAXOS (and little about other consensuses )
Papers We Love / Kyiv :  PAXOS (and little about other consensuses )Papers We Love / Kyiv :  PAXOS (and little about other consensuses )
Papers We Love / Kyiv : PAXOS (and little about other consensuses )
 
Scala / Technology evolution
Scala  / Technology evolutionScala  / Technology evolution
Scala / Technology evolution
 
{co/contr} variance from LSP
{co/contr} variance  from LSP{co/contr} variance  from LSP
{co/contr} variance from LSP
 
Scala jargon cheatsheet
Scala jargon cheatsheetScala jargon cheatsheet
Scala jargon cheatsheet
 
Java & low latency applications
Java & low latency applicationsJava & low latency applications
Java & low latency applications
 
IDLs
IDLsIDLs
IDLs
 
R ext world/ useR! Kiev
R ext world/ useR!  KievR ext world/ useR!  Kiev
R ext world/ useR! Kiev
 
Jslab rssh: JS as language platform
Jslab rssh:  JS as language platformJslab rssh:  JS as language platform
Jslab rssh: JS as language platform
 
Behind OOD: domain modelling in post-OO world.
Behind OOD:  domain modelling in post-OO world.Behind OOD:  domain modelling in post-OO world.
Behind OOD: domain modelling in post-OO world.
 
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
JDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation streamJDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation stream
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
 
Ruslan.shevchenko: most functional-day-kiev 2014
Ruslan.shevchenko: most functional-day-kiev 2014Ruslan.shevchenko: most functional-day-kiev 2014
Ruslan.shevchenko: most functional-day-kiev 2014
 
Web architecture - overview of techniques.
Web architecture - overview of  techniques.Web architecture - overview of  techniques.
Web architecture - overview of techniques.
 
R scala 17_05_2014
R scala 17_05_2014R scala 17_05_2014
R scala 17_05_2014
 
Javascript in modern scala backend. [russian]
Javascript in modern scala backend.  [russian]  Javascript in modern scala backend.  [russian]
Javascript in modern scala backend. [russian]
 
Osdn2013 rssh
Osdn2013 rsshOsdn2013 rssh
Osdn2013 rssh
 
implementation of 'go'-like language constructions in scala (russian)
implementation of 'go'-like language constructions in scala (russian)implementation of 'go'-like language constructions in scala (russian)
implementation of 'go'-like language constructions in scala (russian)
 
Play/Scala as application platform (for http://wbcamp.in.ua 2013)
Play/Scala as application platform  (for http://wbcamp.in.ua 2013)Play/Scala as application platform  (for http://wbcamp.in.ua 2013)
Play/Scala as application platform (for http://wbcamp.in.ua 2013)
 
Iteratee explained.
Iteratee explained.Iteratee explained.
Iteratee explained.
 

Recently uploaded

The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 

Recently uploaded (20)

Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 

Scala-Gopher: CSP-style programming techniques with idiomatic Scala.

  • 1. CSCSP WITH IDIOMATIC SCALA SCALA-GOPHER https://github.com/rssh/scala-gopher goo.gl/dbT3P7 Ruslan Shevchenko VertaMedia
  • 2. scala-gopher ❖ Akka extension + Macros on top of SIP22-async ❖ Integrate CSP Algebra and scala concurrency primitives ❖ Provides: ❖ asynchronous API inside general control-flow ❖ pseudo-synchronous API inside go{ .. } or async{ ..} blocks ❖ Techreport: goo.gl/dbT3P7
  • 3. def nPrimes(n:Int):Future[List[Int]]= { val in = makeChannel[Int]() val out = makeChannel[Int]() go { for(i <- 1 to Int.MaxValue) in.write(i) } go { select.fold(in){ (ch,s) => s match { case p:ch.read => out.write(p) ch.filter(_ % p != 0) } } } go { for(i <- 1 to n) yield out.read } }
  • 4. def nPrimes(n:Int):Future[List[Int]]= { val in = makeChannel[Int]() val out = makeChannel[Int]() go { for(i <- 1 to n*n) out.write(i) } go { select.fold(in){ (ch,s) => s match { case p:ch.read => out.write(p) ch.filter(_ % p != 0) } } } go { for(i <- 1 to n) yield out.read } } go { for(i <- 1 to Int.MaxValue) in.write(i) }
  • 5. def nPrimes(n:Int):Future[List[Int]]= { val in = makeChannel[Int]() val out = makeChannel[Int]() go { for(i <- 1 to Int.MaxValue) in.write(i) } go { select.fold(in){ (ch,s) => s match { case p:ch.read => out.write(p) ch.filter(_ % p != 0) } } } go { for(i <- 1 to n) yield out.read } } go { select.fold(in){ (ch,s) => s match { case p:ch.read => out.write(p) ch.filter(_ % p != 0) } } }
  • 6. def nPrimes(n:Int):Future[List[Int]]= { val in = makeChannel[Int]() val out = makeChannel[Int]() go { for(i <- 1 to Int.MaxValue) in.write(i) } go { select.fold(in){ (ch,s) => s match { case p:ch.read => out.write(p) ch.filter(_ % p != 0) } } } go { for(i <- 1 to n) yield out.read } } go { for(i <- 1 to n) yield out.read }
  • 7. def nPrimes(n:Int):Future[List[Int]]= { val in = makeChannel[Int]() val out = makeChannel[Int]() go { for(i <- 1 to Int.MaxValue) in.write(i) } go { select.fold(in){ (ch,s) => s match { case p:ch.read => out.write(p) ch.filter(_ % p != 0) } } } go { for(i <- 1 to n) yield out.read } }
  • 8. Goroutines ❖ go[X](body: X):Future[X] ❖ Wrapper around async + ❖ translation of high-order functions into async form ❖ handling of defer statement
  • 9. Goroutines ❖ translation of hight-order functions into async form ❖ f(g): f: (A=>B)=>C in g: A=>B, ❖ g is invocation-only in f iff ❖ g called in f or in some h inside f : g invocation-only in h ❖ g is ❖ not stored in memory behind f ❖ not returned from f as return value ❖ Collection API high-order methods are invocation-only
  • 10. Translation of invocation-only functions ❖ f: ((A=>B)=>C), g: (A=>B), g invocation-only in f ❖ f’: ((A=>Future[B])=>Future[C]) g’: (A=>Future[B]) ❖ await(g’) == g => await(f’) == f ❖ f’ => await[translate(f)] ❖ g(x) => await(g’(x)) ❖ h(g) => await(h’(g’)) iff g is invocation-only in h ❖ That’s all ❖ (implemented for specific shapes and parts of scala collection API)
  • 11. def nPrimes(n:Int):Future[List[Int]]= { val in = makeChannel[Int]() val out = makeChannel[Int]() go { for(i <- 1 to n*n) in.write(i) } go { select.fold(in){ (ch,s) => s match { case p:ch.read => out.write(p) ch.filter(_ % p != 0) } } } go { for(i <- 1 to n) yield out.read } } go { for(i <- 1 to n) yield out.read }
  • 12. go { (1 to n).map(i => out.read) } async{ await(t[(1 to n).map(i => out.read)]) } async{ await((1 to n).mapAsync(t[i => async(out.read)])) } async{ await((1 to n).mapAsync(i => async(await(out.aread))) } mapAsync(i => out.aread)
  • 13. Channels ❖ Channel[A] <: Input[A] + Output[A] ❖ Unbuffered ❖ Buffered ❖ Dynamically growing buffers [a-la actor mailbox] ❖ One-time channels [Underlaying promise/Future] ❖ Custom CSP
  • 14. Input[A] - internal API trait Input[A] { type read = A def cbread(f: ContRead[A,B]=>Option[ ContRead.In[A] => Future[Continuated[B]]) ….. } case class ContRead[A,B]( function: F, channel: Channel[A], flowTermination: FlowTermination[B] ) // in ConRead companion object sealed trait In[+A] case class Value(a:A) extends In[A] case class Failure(ex: Throwable] extends In[Nothing] case object Skip extends In[Nothing] case object ChannelClosed extends In[Nothing] ContRead[A,B].F Continuated[B] • ContRead • ContWrite • Skip • Done • Never
  • 15. Input[A] - external API trait Input[A] { …… def aread: Future[A] = <implementation…> def read: A = macro <implementation … > …. def map[B](f: A=>B): Input[B] = …. // or, zip, filter, … etc await(aread) + usual operations on streams in functional language
  • 16. Output[A] - API trait Output[A] { type write = A def cbwrite(f: ContWrite[A,B]=>Option[ (A,Future[Continuated[B]])], ft: FlowTermination[B]) ….. def awrite(a:A): Future[A] = …. def write(a:A): A = …. << await(awrite) …. ContWrite[A,B].F case class ContWrite[A,B]( function: F, channel: Channel[A], flowTermination: FlowTermination[B] )
  • 17. Selector ss go { for{ select{ case c1 -> x : … // P case c2 <- y : … // Q } } Go language: go { select.forever { case x : c1.read => … // P case y : c2.write => … // Q } } Scala: Provide set of flow combinators: forever, once, fold select.aforever { case x : c1.read => … // P case y : c2.write => … // Q }
  • 18. select: fold API def fibonacci(c: Output[Long], quit: Input[Boolean]): Future[(Long,Long)] = select.afold((0L,1L)) { case ((x,y),s) => s match { case x: c.write => (y, x+y) case q: quit.read => select.exit((x,y)) } } fold/afold: • special syntax for tuple support • ’s’: selector pseudoobject • s match must be the first statement • select.exit((..)) to return value from flow
  • 19. Transputer ❖ Actor-like object with set of input/output ports, which can be connected by channels ❖ Participate in actor systems supervisors hierarchy ❖ SelectStatement ❖ A+B (parallel execution, common restart) ❖ replicate
  • 20. Transputer: select class Zipper[T] extends SelectTransputer { val inX: InPort[T] val inY: InPort[T] val out: OutPort[(T,T)] loop { case x: inX.read => val y = inY.read out write (x,y) case y: inY.read => val x = inX.read out.write((x,y)) } } inX inY out
  • 21. Transputer: replicate val r = gopherApi.replicate[SMTTransputer](10) ( r.dataInput.distribute( (_.hashCode % 10 ) ). .controlInput.duplicate(). out.share() ) dataInput controlInput share
  • 22. Programming techniques ❖ Dynamic recursive dataflow schemas ❖ configuration in state ❖ Channel-based two-wave generic API ❖ expect channels for reply
  • 23. Dynamic recursive dataflow select.fold(output){ (out, s) => s match { case x:input.read => select.once { case x:out.write => case select.timeout => control.distributeBandwidth match { case Some(newOut) => newOut.write(x) out | newOut case None => control.report("Can't increase bandwidth") out } } case select.timeout => out match { case OrOutput(frs,snd) => snd.close frs case _ => out } } dynamically increase and decrease bandwidth in dependency from load
  • 24. Dynamic recursive dataflow select.fold(output){ (out, s) => s match { case x:input.read => select.once { case x:out.write => case select.timeout => control.distributeBandwidth match { case Some(newOut) => newOut.write(x) out | newOut case None => control.report("Can't increase bandwidth") out } } case select.timeout => out match { case OrOutput(frs,snd) => snd.close frs case _ => out } } dynamically increase and decrease bandwidth in dependency from load case select.timeout => control.distributeBandwidth match { case Some(newOut) => newOut.write(x) out | newOut case None => control.report("Can't increase bandwidth") out
  • 25. Dynamic recursive dataflow select.fold(output){ (out, s) => s match { case x:input.read => select.once { case x:out.write => case select.timeout => control.distributeBandwidth match { case Some(newOut) => newOut.write(x) out | newOut case None => control.report("Can't increase bandwidth") out } } case select.timeout => out match { case OrOutput(frs,snd) => snd.close frs case _ => out } } dynamically increase and decrease bandwidth in dependency from load case select.timeout => out match { case OrOutput(frs,snd) => snd.close frs case _ => out }
  • 26. Channel-based generic API ❖ Endpoint instead function call ❖ f: A=>B ❖ endpoint: Channel[A,Channel[B]] ❖ Recursive ❖ case class M(A,Channel[M]) ❖ f: (A,M) => M (dataflow configured by input)
  • 27. Channel-based generic API trait Broadcast[T] { val listeners: Output[Channel[T]] val messages: Output[T] def send(v:T):Unit = { messages.write(v) } …. • message will received by all listeners
  • 28. Channel-based generic API class BroadcastImpl[T] { val listeners: Channel[Channel[T]] val messages: Channel[T] = makeChannel[Channel[T]] def send(v:T):Unit = { messages.write(v) } …. } // private part case class Message(next:Channel[Message],value:T) select.afold(makeChannel[Message]) { (bus, s) => s match { case v: messages.read => val newBus = makeChannel[Message] current.write(Message(newBus,v)) newBus case ch: listeners.read => select.afold(bus) { (current,s) => s match { case msg:current.read => ch.awrite(msg.value) current.write(msg) msg.next } } current
  • 29. Channel-based generic API val listeners: Channel[Channel[T]] val messages: Channel[T] = makeChannel[] // private part case class Message(next:Channel[Message],value:T) select.afold(makeChannel[Message]) { (bus, s) => s match { case v: message.read => val newBus = makeChannel[Message] current.write(Message(newBus,v)) newBus case ch: listener.read => select.afold(bus) { (current,s) => s match { case msg:current.read => ch.awrite(msg.value) current.write(msg) msg.next } } • state - channel [bus], for which all listeners are subscribed • on new message - send one to bus with pointer to the next bus state • listener on new message in bus - handle, change current and send again • on new listener - propagate
  • 30. Channel-based generic API val listener: Channel[Channel[T]] val message: Channel[T] = makeChannel[] // private part case class Message(next:Channel[Message],value:T) select.afold(makeChannel[Message]) { (bus, s) => s match { case v: message.read => val newBus = makeChannel[Message] current.write(Message(newBus,v)) newBus case ch: listener.read => select.afold(bus) { (current,s) => s match { case msg:current.read => ch.awrite(msg.value) msg.next } } current • state - channel [bus], for which all listeners are subscribed • on new message - send one to bus with pointer to the next bus state • listener on new message in bus - handle, change current and send again • on new listener - propagate s match { case msg:current.read => ch.awrite(msg.value) current.write(msg) msg.next }
  • 31. Channel-based generic API val listener: Channel[Channel[T]] val message: Channel[T] = makeChannel[] // private part case class Message(next:Channel[Message],value:T) select.afold(makeChannel[Message]) { (bus, s) => s match { case v: message.read => val newBus = makeChannel[Message] current.write(Message(newBus,v)) newBus case ch: listener.read => select.afold(bus) { (current,s) => s match { case msg:current.read => ch.awrite(msg.value) current.write(msg) msg.next } } current • state - channel [bus], for which all listeners are subscribed • on new message - send one to bus with pointer to the next bus state • listener on new message in bus - handle, change current and send again • val newBus = makeChannel[Message] current.write(Message(newBus,v)) newBus
  • 32. Scala concurrency libraries Flexibility Scalability Level Actors • Actors • low level, • great flexibility and scalability • Akka-Streams • low flexibility • hight-level, scalable • SCO • low scalability • hight-level, flexible • Reactive Isolated • hight-level, scalable, • allows delegation • Gopher • can emulate each style Streams SCO Subscript Language
  • 33. Gopher vs Reactive Isolates • Isolate • Events • Channel • Transputer/fold • Input • Output Gopher Isolates One writerMany writers Channel must have owner Local Distributed Loosely coupled (growing buffer)CSP + growing buffer
  • 34. Scala-gopher: early experience reports ❖ Not 1.0 yet ❖ Helper functionality in industrial software projects. (utilities, small team) ❖ Generally: positive ❖ transformation of invocation-only hight-order methods into async form ❖ recursive dynamic data flows ❖ Error handling needs some boilerplate
  • 35. Error handling: language level issue val future = go { ……… throw some exception } go { ………. throw some exception } Go { ………… throw some exception } Core scala library: Future.apply (same issue) Error is ignored Developers miss-up Go/go
  • 36. Errors in ignored value: possible language changes. ❖ Possible solutions: ❖ Optional implicit conversion for ignored value ❖ Special optional method name for calling with ignored value ❖ Special return type trait Ignored[F] object Future { implicit def toIgnored(f:Future):Ignored[Future] = …. def go[X](f: X): Future[X] def go_ignored[X](f:X): Unit def go(f:X): Ignored[Future[X]] =
  • 37. Scala-Gopher: Future directions ❖ More experience reports (try to use) ❖ Extended set of notifications ❖ channel.close, overflow ❖ Distributed case ❖ new channel types with explicit distributed semantics
  • 38. Scala-Gopher: Conclusion ❖ Native integration of CSP into Scala is possible ❖ have a place in a Scala concurrency model zoo ❖ Bring well-established techniques to Scala world ❖ (recursive dataflow schemas; channel API) ❖ Translation of invocation-only high-order functions into async form can be generally recommended. ❖ (with TASTY transformation inside libraries can be done automatically)
  • 39. Thanks for attention ❖ Questions ? ❖ https://github.com/rssh/scala-gopher ❖ ruslan shevchenko: ruslan@shevchenko.kiev.ua