SlideShare a Scribd company logo
1 of 32
Download to read offline
WHY SCALA IS NOT MY IDEAL LANGUAGE
Ruslan Shevchenko
https://github.com/rssh
@rssh1
AND WHAT I CAN DO WITH THIS
ANY SUFFICIENTLY ADVANCED DEVELOPMENT CONSIDERED HARMFUL
OVERVIEW
WHY SCALA IS NOT MY IDEAL LANGUAGE AND WHAT I CAN DO WITH THIS
• Implicit mismatch.
• inexistent ‘ideal’ solution
• ‘Cooperative’ solutions
• (ways to tell something to users of you code)
• Asynchronous programming
• Errors handling
• Async - the ideal way in ideal world and workarounds in real ;)
• Actors / Transputers
• Compiler
• Effects
• Extensibility
IMPLICIT MISMATCH
• Configuring runtime behaviour via implicit.
• Wildly used anti-pattern
• Mongo reactive-db driver
• Scala standard library.
MONGO SALACT CONTEXT
CONFIGURE RUNTIME BEHAVIOUR VIA IMPLICIT-S
import com.mongodb.casbah.Imports._
import com.novus.salat._
// import our context
import com.mycompany.salatcontext._
……
import com.mongodb.casbah.Imports._
import com.novus.salat._
// import standard context
import com.novus.salat.global._
……
File A:
File B:
SCALA STANDARD LIBRARY
CONFIGURE RUNTIME BEHAVIOUR VIA IMPLICIT-S
val zf = for( x <- XService.retrieve();
y <- YService.retrieve(x)
) yield
combine(x, y)
val z = Await(zf, 1 minute)
Q: Where it’s block ?
//note: slide changed, version shown during first presentation was without last line. [sorry].
and reference to full example.
//full example: http://bit.ly/1oPF5zM
WHAT TO DO ?
CONFIGURING RUNTIME BEHAVIOUR
• Do not use such libraries/frameworks (?)
• Block of imports as entity which possible to compose.
• require language changes
• motivation for @annotated imports pre-sip (2012)
• http://bit.ly/1NfVIej (proposal itself)
• patch against scalac & scaladoc 2.10
WHAT TO DO ?
CONFIGURING RUNTIME BEHAVIOUR
• Do not use such libraries/frameworks (?)
• Block of imports as entity which possible to compose.
• require language changes
• motivation for @annotated imports pre-sip (2012)
• http://bit.ly/1NfVIej (proposal itself)
• patch against scalac & scaladoc 2.10
EXAMPLE OF USAGE
ANNOTATED IMPORTS
object ConfiguredSalat {
@exported import com.mongodb.casbah.Imports._
@exported import com.novus.salat._
// our context
@exported import com.mycompany.salatcontext._
}
e ConfiguredSalat.scala
File A:
import com.mycompany.ConfiguredSalat._
……
File B:
import com.mycompany.ConfiguredSalat._
……
WHAT TO DO ?
CONFIGURING RUNTIME BEHAVIOUR
• Do not use such libraries/frameworks (?)
• Patch compiler.
// submitted pre-SIP was closed
as ‘too big change, maybe later’
WHAT TO DO ?
CONFIGURING RUNTIME BEHAVIOUR
• Do not use such libraries/frameworks (?)
• Patch compiler.
• Try not to write big programs.
• Provide wrapper which will force developers to read
docs ;))))
• FORCE USERS OF YOU WRAPPER TO UNDERSTAND PROBLEM
• ALLOW TO DO EVERYTHING
COOPERATIVE FIX
object ThinkAboutFuture {
implicit val `[implicit execution context is disabled]`:
ExecutionContext = ???
implicit val `(implicit execution context is disbled)`:
ExecutionContext = ???
implicit object knowledge
}
Config:
Service:
class MyCoreContext {
def baseService()
(implicit ThinkAboutFuture.knowledge.type):
Future[MyService] =
………
}
• FORCE USERS OF YOU WRAPPER TO UNDERSTAND PROBLEM
• ALLOW TO DO EVERYTHING
COOPERATIVE FIX
import ThinkAboutFuture._
object ReenableGlobalContext {
implicit def ec = ExecutionContext.Implicits.global._
………
}
not
• MORE ABOUT FUTURE
ASYNC PROGRAMMING
Future{
throw new RuntimeException(“Be-Be-Be!!!”)
}
- community accepted way to spawn task without return.
object FuturePlus {
def apply[T](body: =>T): Future[T] =
Future(body)(myEc)
def exec[T](body: =>T): Unit =
FuturePlus(body).onFailure{
case ex => handleException(_)
}(myEc)
}
// write own spawn methods
// use some lint tools, like wartremover
• MORE ABOUT FUTURE
ASYNC PROGRAMMING
Future{
throw new RuntimeException(“Be-Be-Be!!!”)
}
java.lang.RuntimeException: Be-Be-Be !!!
at x.Test$$anonfun$main$2.apply(X.scala:49)
at x.Test$$anonfun$main$2.apply(X.scala:47)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scal
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
at scala.concurrent.impl.ExecutionContextImpl
$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107
• MORE ABOUT FUTURE
ASYNC PROGRAMMING
- From where it was spawn ?
java.lang.RuntimeException: Be-Be-Be !!!
at x.Test$$anonfun$main$2.apply(X.scala:49)
at x.Test$$anonfun$main$2.apply(X.scala:47)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
at scala.concurrent.impl.ExecutionContextImpl
$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
- Can I see full stack-trace ?
// problem - that getting stack trace is expensive
TRACK FUTURE APPLY
• Let’s patch byte-code.
InvokeVirtual s/c/Future$ apply
(Ls/Function0;Ls/c/ExecutionContext;)Ls/c/Future
InvokeStatic t/TrackedFuture rapply
(Ls/c/Future;Ls/Function0;Ls/c/ExecutionContext;)Ls/c/Future
TRACK FUTURE APPLY
libraryDependencies += "com.github.rssh" %% "trackedfuture" % "0.1"
fork := true
javaOptions += s"""-javaagent:${System.getProperty("user.home")}/.ivy2/local/
com.github.rssh/trackedfuture_2.11/0.1/jars/trackedfuture_2.11.jar"""
small agent: https://github.com/rssh/trackedfuture
[error] java.lang.RuntimeException: Be-Be-Be !!!
[error] at x.Test$$anonfun$main$2.apply(X.scala:49)
[error] at x.Test$$anonfun$main$2.apply(X.scala:47)
[error] at trackedfuture.runtime.TrackedFuture$$anon$1.run(TrackedFuture.scala:21)
[error] at scala.concurrent.impl.ExecutionContextImpl
$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121)
[error] at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
[error] at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
[error] at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
[error] at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:
107)
[error] at java.lang.Thread.getStackTrace(Thread.java:1552)
[error] at trackedfuture.runtime.TrackedFuture$.apply(TrackedFuture.scala:13)
TRACK FUTURE APPLY
[error] java.lang.RuntimeException: Be-Be-Be !!!
[error] at x.Test$$anonfun$main$2.apply(X.scala:49)
[error] at x.Test$$anonfun$main$2.apply(X.scala:47)
[error] at trackedfuture.runtime.TrackedFuture$$anon$1.run(TrackedFuture.scala:2
[error] at scala.concurrent.impl.ExecutionContextImpl
$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121)
[error] at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
[error] at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool
[error] at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:19
[error] at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThre
107)
[error] at java.lang.Thread.getStackTrace(Thread.java:1552)
[error] at trackedfuture.runtime.TrackedFuture$.apply(TrackedFuture.scala:13)
[error] at trackedfuture.runtime.TrackedFuture$.rapply(TrackedFuture.scala:39)
[error] at trackedfuture.runtime.TrackedFuture.rapply(TrackedFuture.scala)
[error] at x.InDBFuture$.apply(X.scala:26)
[error] at x.InDBFuture$.exec(X.scala:29)
[error] at x.Test$.main(X.scala:47)
[error] at x.Test.main(X.scala)
[success] Total time: 1 s, completed Apr 9, 2016 2
ASYNC PROGRAMMING
Future is low-level interface,
like manual memory management in C
— configure execution context for db connections [1]
— spawn from Actor future with this db context [2]
— actually run query and retrieve the data [3]
— send retrieved data to place, where it can be used
(in map or to the same mailbox) [4]
How to retrieve data few times via SQL Query in Actor ?
4 steps, why not 1 ?
ASYNC PROGRAMMING
Future is low-level interface,
like manual memory management in C
Management execution flow: Async
• SIP-22
• transform code with async to state machine
val respFut = async {
val dayOfYear = await(futureDOY).body
val daysLeft = await(futureDaysLeft).body
Ok(s"$dayOfYear: $daysLeft days left!")
}
ASYNC
In ideal world, we should forget about Future and
use Async in business logic.
Async is a second-size citizen in scala.
• Luck of exception support // no technical reason for this.
• Luck of hight-level functions support
• still SIP, no 1.0 version
• expose set of macro/compiler bugs.
ASYNC => GO
ASYNC PROGRAMMING
def copy(inf: File, outf: File): Long =
goScope {
val in = new FileInputStream(inf)
defer{ in.close() }
val out = new FileOutputStream(outf);
defer{ out.close() }
out.getChannel() transferFrom(in.getChannel(), 0, Long.MaxV
}
• Part of scala-gopher:
• https://github.com/rssh/scala-gopher
• wrapper around async:
• defer instead try/catch/finally
• Hight-level function support
NOT IMPLEMENTED IDEAS ABOUT HIGHT-LEVEL FUNCTION
SUPPORT
ASYNC PROGRAMMING
async{
val l = for(i <- 1 to N) yield {
await(retrieve something i)
}
} IMPOSSIBLE
async{
var l = IndexedSeq[X]()
var i = 0
while(i < N) {
l += await(retrieve something i)
}
}
• Hight-level function support
• before generation of async, wrap type classes for well-
known hight-order functions:
• map( A (with awaits) ) => mapAsync(Future[A])
• allows to write own type classes
• when TASTY will be available: try to generate async
variants in simple cases.
NOT IMPLEMENTED IDEAS ABOUT HIGHT-LEVEL FUNCTION
SUPPORT
ASYNC PROGRAMMING
ASYNC
COMPILER SUPPORT
• can async be better integrated with compiler ?
• async is very low-level interface,
• like automatic memory management in C++
• Hight level way:
• Effects in type system.
• (X@Ex; Y@Ey) => Y @ (Ex+Ey) [in ideal world]
• (X; Y) => Y [ now ]
• ability to specialise execution context by effects.
// SCALA [Q PART]
• lim <?>
Hight-level DSL
Specialised DSL (Q, SQL)
Scala
Java/NPJava
C
ASM
// SCALA [Q PART]
• lim <?>
Hight-level DSL
Q
Scala
Java/NPJava
C
ASM
code <=> run time complexity
possible to track behaviour
looking at code
code =/= run time complexity
syntax sugar, implicits, std
// SCALA [Q PART]
• lim <?>
Hight-level DSL
Q
Scala
Java/NPJava
C
ASM
verbose API,
verbose imports
leaked low-level issues
Hight-level fluent API;
carefully optimised;
controlled low-level platform
// SCALA [Q PART]
• lim <?>
Hight-level DSL
Q
Scala
Java/NPJava
C
ASM
s.split(‘|’).toSeq flatMap (_.split(‘=‘)).
… verify that it-s int
…
(!/) “I=|”0:fix
// SCALA [Q PART]
• DSL construction: boilerplate factory
- Internal
- own set of types and globals;
- — no way to set precedence
- — manual construction
- — import needed postfix,
- macroses (limited).
- — awkward reflection API
- — traversing instead construction.
- — run after typing phase.
// SCALA [Q PART]
• Scala is one of my favourite languages.
• It can be sufficiently better.
• Maybe[support for compiler plugins]
• Any[sufficiently advanced development]
considered harmful
• Questions [?]; Ideas[?] ; — call me

More Related Content

What's hot

[COSCUP 2020] How to use llvm frontend library-libtooling
[COSCUP 2020] How to use llvm frontend library-libtooling[COSCUP 2020] How to use llvm frontend library-libtooling
[COSCUP 2020] How to use llvm frontend library-libtoolingDouglas Chen
 
JRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVMJRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVMCharles Nutter
 
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)ngotogenome
 
Dive into ROP - a quick introduction to Return Oriented Programming
Dive into ROP - a quick introduction to Return Oriented ProgrammingDive into ROP - a quick introduction to Return Oriented Programming
Dive into ROP - a quick introduction to Return Oriented ProgrammingSaumil Shah
 
Return-Oriented Programming: Exploits Without Code Injection
Return-Oriented Programming: Exploits Without Code InjectionReturn-Oriented Programming: Exploits Without Code Injection
Return-Oriented Programming: Exploits Without Code Injectionguest9f4856
 
Triton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON ChinaTriton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON ChinaWei-Bo Chen
 
java8-patterns
java8-patternsjava8-patterns
java8-patternsJustin Lin
 
The Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerThe Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerVladimir Sedach
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Charles Nutter
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scalatod esking
 
Taking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyTaking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyHaim Yadid
 
Building microservices with Kotlin
Building microservices with KotlinBuilding microservices with Kotlin
Building microservices with KotlinHaim Yadid
 
Introduction to Khronos SYCL
Introduction to Khronos SYCLIntroduction to Khronos SYCL
Introduction to Khronos SYCLMin-Yih Hsu
 
Code lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf LinzCode lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf LinzIvan Krylov
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9Ivan Krylov
 
Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Jimmy Schementi
 
parenscript-tutorial
parenscript-tutorialparenscript-tutorial
parenscript-tutorialtutorialsruby
 
TypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without AnnotationsTypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without Annotationsmametter
 

What's hot (20)

[COSCUP 2020] How to use llvm frontend library-libtooling
[COSCUP 2020] How to use llvm frontend library-libtooling[COSCUP 2020] How to use llvm frontend library-libtooling
[COSCUP 2020] How to use llvm frontend library-libtooling
 
JRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVMJRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVM
 
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
 
Dive into ROP - a quick introduction to Return Oriented Programming
Dive into ROP - a quick introduction to Return Oriented ProgrammingDive into ROP - a quick introduction to Return Oriented Programming
Dive into ROP - a quick introduction to Return Oriented Programming
 
Return-Oriented Programming: Exploits Without Code Injection
Return-Oriented Programming: Exploits Without Code InjectionReturn-Oriented Programming: Exploits Without Code Injection
Return-Oriented Programming: Exploits Without Code Injection
 
Triton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON ChinaTriton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON China
 
Klee and angr
Klee and angrKlee and angr
Klee and angr
 
java8-patterns
java8-patternsjava8-patterns
java8-patterns
 
The Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerThe Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compiler
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scala
 
effective_r27
effective_r27effective_r27
effective_r27
 
Taking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyTaking Kotlin to production, Seriously
Taking Kotlin to production, Seriously
 
Building microservices with Kotlin
Building microservices with KotlinBuilding microservices with Kotlin
Building microservices with Kotlin
 
Introduction to Khronos SYCL
Introduction to Khronos SYCLIntroduction to Khronos SYCL
Introduction to Khronos SYCL
 
Code lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf LinzCode lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf Linz
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
 
Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011
 
parenscript-tutorial
parenscript-tutorialparenscript-tutorial
parenscript-tutorial
 
TypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without AnnotationsTypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without Annotations
 

Similar to Why scala is not my ideal language and what I can do with this

BUILDING APPS WITH ASYNCIO
BUILDING APPS WITH ASYNCIOBUILDING APPS WITH ASYNCIO
BUILDING APPS WITH ASYNCIOMykola Novik
 
Advanced technic for OS upgrading in 3 minutes
Advanced technic for OS upgrading in 3 minutesAdvanced technic for OS upgrading in 3 minutes
Advanced technic for OS upgrading in 3 minutesHiroshi SHIBATA
 
Large-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 MinutesLarge-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 MinutesHiroshi SHIBATA
 
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)jeffz
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with serverEugene Yokota
 
High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2Niti Chotkaew
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax ApplicationsJulien Lecomte
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...Codemotion
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Enginecatherinewall
 
Drilling the Async Library
Drilling the Async LibraryDrilling the Async Library
Drilling the Async LibraryKnoldus Inc.
 
(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of us(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of usStefan Adolf
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptJohn Stevenson
 
How to Reverse Engineer Web Applications
How to Reverse Engineer Web ApplicationsHow to Reverse Engineer Web Applications
How to Reverse Engineer Web ApplicationsJarrod Overson
 
Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3kognate
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Eugene Yokota
 
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019Thomas Weise
 
Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...Codemotion
 

Similar to Why scala is not my ideal language and what I can do with this (20)

BUILDING APPS WITH ASYNCIO
BUILDING APPS WITH ASYNCIOBUILDING APPS WITH ASYNCIO
BUILDING APPS WITH ASYNCIO
 
Advanced technic for OS upgrading in 3 minutes
Advanced technic for OS upgrading in 3 minutesAdvanced technic for OS upgrading in 3 minutes
Advanced technic for OS upgrading in 3 minutes
 
Large-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 MinutesLarge-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 Minutes
 
React native
React nativeReact native
React native
 
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with server
 
Play framework
Play frameworkPlay framework
Play framework
 
High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax Applications
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
 
Drilling the Async Library
Drilling the Async LibraryDrilling the Async Library
Drilling the Async Library
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of us(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of us
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
 
How to Reverse Engineer Web Applications
How to Reverse Engineer Web ApplicationsHow to Reverse Engineer Web Applications
How to Reverse Engineer Web Applications
 
Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)
 
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019
 
Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...
 

More from Ruslan Shevchenko

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
 
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
 
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.Ruslan Shevchenko
 
Few simple-type-tricks in scala
Few simple-type-tricks in scalaFew simple-type-tricks in scala
Few simple-type-tricks in scalaRuslan 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
 
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
 
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
 
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
 

More from Ruslan Shevchenko (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]
 
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
 
N flavors of streaming
N flavors of streamingN flavors of streaming
N flavors of streaming
 
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
 
Few simple-type-tricks in scala
Few simple-type-tricks in scalaFew simple-type-tricks in scala
Few simple-type-tricks in scala
 
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
 
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.
 
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
 
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
 
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
 

Recently uploaded

CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 

Recently uploaded (20)

CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 

Why scala is not my ideal language and what I can do with this

  • 1. WHY SCALA IS NOT MY IDEAL LANGUAGE Ruslan Shevchenko https://github.com/rssh @rssh1 AND WHAT I CAN DO WITH THIS
  • 2. ANY SUFFICIENTLY ADVANCED DEVELOPMENT CONSIDERED HARMFUL
  • 3. OVERVIEW WHY SCALA IS NOT MY IDEAL LANGUAGE AND WHAT I CAN DO WITH THIS • Implicit mismatch. • inexistent ‘ideal’ solution • ‘Cooperative’ solutions • (ways to tell something to users of you code) • Asynchronous programming • Errors handling • Async - the ideal way in ideal world and workarounds in real ;) • Actors / Transputers • Compiler • Effects • Extensibility
  • 4. IMPLICIT MISMATCH • Configuring runtime behaviour via implicit. • Wildly used anti-pattern • Mongo reactive-db driver • Scala standard library.
  • 5. MONGO SALACT CONTEXT CONFIGURE RUNTIME BEHAVIOUR VIA IMPLICIT-S import com.mongodb.casbah.Imports._ import com.novus.salat._ // import our context import com.mycompany.salatcontext._ …… import com.mongodb.casbah.Imports._ import com.novus.salat._ // import standard context import com.novus.salat.global._ …… File A: File B:
  • 6. SCALA STANDARD LIBRARY CONFIGURE RUNTIME BEHAVIOUR VIA IMPLICIT-S val zf = for( x <- XService.retrieve(); y <- YService.retrieve(x) ) yield combine(x, y) val z = Await(zf, 1 minute) Q: Where it’s block ? //note: slide changed, version shown during first presentation was without last line. [sorry]. and reference to full example. //full example: http://bit.ly/1oPF5zM
  • 7. WHAT TO DO ? CONFIGURING RUNTIME BEHAVIOUR • Do not use such libraries/frameworks (?) • Block of imports as entity which possible to compose. • require language changes • motivation for @annotated imports pre-sip (2012) • http://bit.ly/1NfVIej (proposal itself) • patch against scalac & scaladoc 2.10
  • 8. WHAT TO DO ? CONFIGURING RUNTIME BEHAVIOUR • Do not use such libraries/frameworks (?) • Block of imports as entity which possible to compose. • require language changes • motivation for @annotated imports pre-sip (2012) • http://bit.ly/1NfVIej (proposal itself) • patch against scalac & scaladoc 2.10
  • 9. EXAMPLE OF USAGE ANNOTATED IMPORTS object ConfiguredSalat { @exported import com.mongodb.casbah.Imports._ @exported import com.novus.salat._ // our context @exported import com.mycompany.salatcontext._ } e ConfiguredSalat.scala File A: import com.mycompany.ConfiguredSalat._ …… File B: import com.mycompany.ConfiguredSalat._ ……
  • 10. WHAT TO DO ? CONFIGURING RUNTIME BEHAVIOUR • Do not use such libraries/frameworks (?) • Patch compiler. // submitted pre-SIP was closed as ‘too big change, maybe later’
  • 11. WHAT TO DO ? CONFIGURING RUNTIME BEHAVIOUR • Do not use such libraries/frameworks (?) • Patch compiler. • Try not to write big programs. • Provide wrapper which will force developers to read docs ;))))
  • 12. • FORCE USERS OF YOU WRAPPER TO UNDERSTAND PROBLEM • ALLOW TO DO EVERYTHING COOPERATIVE FIX object ThinkAboutFuture { implicit val `[implicit execution context is disabled]`: ExecutionContext = ??? implicit val `(implicit execution context is disbled)`: ExecutionContext = ??? implicit object knowledge } Config: Service: class MyCoreContext { def baseService() (implicit ThinkAboutFuture.knowledge.type): Future[MyService] = ……… }
  • 13. • FORCE USERS OF YOU WRAPPER TO UNDERSTAND PROBLEM • ALLOW TO DO EVERYTHING COOPERATIVE FIX import ThinkAboutFuture._ object ReenableGlobalContext { implicit def ec = ExecutionContext.Implicits.global._ ……… } not
  • 14. • MORE ABOUT FUTURE ASYNC PROGRAMMING Future{ throw new RuntimeException(“Be-Be-Be!!!”) } - community accepted way to spawn task without return. object FuturePlus { def apply[T](body: =>T): Future[T] = Future(body)(myEc) def exec[T](body: =>T): Unit = FuturePlus(body).onFailure{ case ex => handleException(_) }(myEc) } // write own spawn methods // use some lint tools, like wartremover
  • 15. • MORE ABOUT FUTURE ASYNC PROGRAMMING Future{ throw new RuntimeException(“Be-Be-Be!!!”) } java.lang.RuntimeException: Be-Be-Be !!! at x.Test$$anonfun$main$2.apply(X.scala:49) at x.Test$$anonfun$main$2.apply(X.scala:47) at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scal at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) at scala.concurrent.impl.ExecutionContextImpl $AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107
  • 16. • MORE ABOUT FUTURE ASYNC PROGRAMMING - From where it was spawn ? java.lang.RuntimeException: Be-Be-Be !!! at x.Test$$anonfun$main$2.apply(X.scala:49) at x.Test$$anonfun$main$2.apply(X.scala:47) at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24 at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) at scala.concurrent.impl.ExecutionContextImpl $AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) - Can I see full stack-trace ? // problem - that getting stack trace is expensive
  • 17. TRACK FUTURE APPLY • Let’s patch byte-code. InvokeVirtual s/c/Future$ apply (Ls/Function0;Ls/c/ExecutionContext;)Ls/c/Future InvokeStatic t/TrackedFuture rapply (Ls/c/Future;Ls/Function0;Ls/c/ExecutionContext;)Ls/c/Future
  • 18. TRACK FUTURE APPLY libraryDependencies += "com.github.rssh" %% "trackedfuture" % "0.1" fork := true javaOptions += s"""-javaagent:${System.getProperty("user.home")}/.ivy2/local/ com.github.rssh/trackedfuture_2.11/0.1/jars/trackedfuture_2.11.jar""" small agent: https://github.com/rssh/trackedfuture [error] java.lang.RuntimeException: Be-Be-Be !!! [error] at x.Test$$anonfun$main$2.apply(X.scala:49) [error] at x.Test$$anonfun$main$2.apply(X.scala:47) [error] at trackedfuture.runtime.TrackedFuture$$anon$1.run(TrackedFuture.scala:21) [error] at scala.concurrent.impl.ExecutionContextImpl $AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121) [error] at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [error] at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [error] at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [error] at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java: 107) [error] at java.lang.Thread.getStackTrace(Thread.java:1552) [error] at trackedfuture.runtime.TrackedFuture$.apply(TrackedFuture.scala:13)
  • 19. TRACK FUTURE APPLY [error] java.lang.RuntimeException: Be-Be-Be !!! [error] at x.Test$$anonfun$main$2.apply(X.scala:49) [error] at x.Test$$anonfun$main$2.apply(X.scala:47) [error] at trackedfuture.runtime.TrackedFuture$$anon$1.run(TrackedFuture.scala:2 [error] at scala.concurrent.impl.ExecutionContextImpl $AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121) [error] at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [error] at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool [error] at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:19 [error] at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThre 107) [error] at java.lang.Thread.getStackTrace(Thread.java:1552) [error] at trackedfuture.runtime.TrackedFuture$.apply(TrackedFuture.scala:13) [error] at trackedfuture.runtime.TrackedFuture$.rapply(TrackedFuture.scala:39) [error] at trackedfuture.runtime.TrackedFuture.rapply(TrackedFuture.scala) [error] at x.InDBFuture$.apply(X.scala:26) [error] at x.InDBFuture$.exec(X.scala:29) [error] at x.Test$.main(X.scala:47) [error] at x.Test.main(X.scala) [success] Total time: 1 s, completed Apr 9, 2016 2
  • 20. ASYNC PROGRAMMING Future is low-level interface, like manual memory management in C — configure execution context for db connections [1] — spawn from Actor future with this db context [2] — actually run query and retrieve the data [3] — send retrieved data to place, where it can be used (in map or to the same mailbox) [4] How to retrieve data few times via SQL Query in Actor ? 4 steps, why not 1 ?
  • 21. ASYNC PROGRAMMING Future is low-level interface, like manual memory management in C Management execution flow: Async • SIP-22 • transform code with async to state machine val respFut = async { val dayOfYear = await(futureDOY).body val daysLeft = await(futureDaysLeft).body Ok(s"$dayOfYear: $daysLeft days left!") }
  • 22. ASYNC In ideal world, we should forget about Future and use Async in business logic. Async is a second-size citizen in scala. • Luck of exception support // no technical reason for this. • Luck of hight-level functions support • still SIP, no 1.0 version • expose set of macro/compiler bugs.
  • 23. ASYNC => GO ASYNC PROGRAMMING def copy(inf: File, outf: File): Long = goScope { val in = new FileInputStream(inf) defer{ in.close() } val out = new FileOutputStream(outf); defer{ out.close() } out.getChannel() transferFrom(in.getChannel(), 0, Long.MaxV } • Part of scala-gopher: • https://github.com/rssh/scala-gopher • wrapper around async: • defer instead try/catch/finally
  • 24. • Hight-level function support NOT IMPLEMENTED IDEAS ABOUT HIGHT-LEVEL FUNCTION SUPPORT ASYNC PROGRAMMING async{ val l = for(i <- 1 to N) yield { await(retrieve something i) } } IMPOSSIBLE async{ var l = IndexedSeq[X]() var i = 0 while(i < N) { l += await(retrieve something i) } }
  • 25. • Hight-level function support • before generation of async, wrap type classes for well- known hight-order functions: • map( A (with awaits) ) => mapAsync(Future[A]) • allows to write own type classes • when TASTY will be available: try to generate async variants in simple cases. NOT IMPLEMENTED IDEAS ABOUT HIGHT-LEVEL FUNCTION SUPPORT ASYNC PROGRAMMING
  • 26. ASYNC COMPILER SUPPORT • can async be better integrated with compiler ? • async is very low-level interface, • like automatic memory management in C++ • Hight level way: • Effects in type system. • (X@Ex; Y@Ey) => Y @ (Ex+Ey) [in ideal world] • (X; Y) => Y [ now ] • ability to specialise execution context by effects.
  • 27. // SCALA [Q PART] • lim <?> Hight-level DSL Specialised DSL (Q, SQL) Scala Java/NPJava C ASM
  • 28. // SCALA [Q PART] • lim <?> Hight-level DSL Q Scala Java/NPJava C ASM code <=> run time complexity possible to track behaviour looking at code code =/= run time complexity syntax sugar, implicits, std
  • 29. // SCALA [Q PART] • lim <?> Hight-level DSL Q Scala Java/NPJava C ASM verbose API, verbose imports leaked low-level issues Hight-level fluent API; carefully optimised; controlled low-level platform
  • 30. // SCALA [Q PART] • lim <?> Hight-level DSL Q Scala Java/NPJava C ASM s.split(‘|’).toSeq flatMap (_.split(‘=‘)). … verify that it-s int … (!/) “I=|”0:fix
  • 31. // SCALA [Q PART] • DSL construction: boilerplate factory - Internal - own set of types and globals; - — no way to set precedence - — manual construction - — import needed postfix, - macroses (limited). - — awkward reflection API - — traversing instead construction. - — run after typing phase.
  • 32. // SCALA [Q PART] • Scala is one of my favourite languages. • It can be sufficiently better. • Maybe[support for compiler plugins] • Any[sufficiently advanced development] considered harmful • Questions [?]; Ideas[?] ; — call me