JavaScript is arguably the most popular language in the world. It runs in the browser, on the server, on mobile devices, and even powers the Internet of things. In spite of being completely ubiquitous, JavaScript is also the most hated language on the planet.
Unlike other programming languages, JavaScript straddles the line between imperative, object-oriented languages and functional ones. It was originally designed to be a version of the Scheme language for the browser. Which begs the questions, what if we programmed JavaScript functionally?
In this session, we will take a well-known programming problem and first implemented imperatively, then progressively make it more functional. Along the way, we will discuss what makes a language functional.
Best of all we will just use the latest version of JavaScript, ES-2015. No need for any additional libraries. So if you are looking for a different way to code JS, or only curious to learn a bit more about FP, please join us.
Scala in-practice-3-years by Patric Fornasier, Springr, presented at Pune Sca...Thoughtworks
3 years ago, Springer decided to use Scala on a large, strategic project. This talk is about the journey the development teams made. Why did they choose Scala in the first place? Did they get what they hoped for? What challenges and surprises did they encounter along the way? And, most importantly, are they still happy with their choice?
JavaScript is arguably the most popular language in the world. It runs in the browser, on the server, on mobile devices, and even powers the Internet of things. In spite of being completely ubiquitous, JavaScript is also the most hated language on the planet.
Unlike other programming languages, JavaScript straddles the line between imperative, object-oriented languages and functional ones. It was originally designed to be a version of the Scheme language for the browser. Which begs the questions, what if we programmed JavaScript functionally?
In this session, we will take a well-known programming problem and first implemented imperatively, then progressively make it more functional. Along the way, we will discuss what makes a language functional.
Best of all we will just use the latest version of JavaScript, ES-2015. No need for any additional libraries. So if you are looking for a different way to code JS, or only curious to learn a bit more about FP, please join us.
Scala in-practice-3-years by Patric Fornasier, Springr, presented at Pune Sca...Thoughtworks
3 years ago, Springer decided to use Scala on a large, strategic project. This talk is about the journey the development teams made. Why did they choose Scala in the first place? Did they get what they hoped for? What challenges and surprises did they encounter along the way? And, most importantly, are they still happy with their choice?
Networks and Types - the Future of Akka @ ScalaDays NYC 2018Konrad Malawski
A look into the upcoming soon-to-be-stable typed Actor APIs in Akka. Shown at Scala Days NYC 2018, while Akka 2.5.13 was out. Looking at what will become the stable Akka Typed.
Introducing Scala to your Ruby/Java Shop : My experiences at IGNManish Pandit
With the move to SOA, IGN's API engineering became a traditional Java/Ruby shop. We introduced Scala to the team in August '11. As of April '12 we have our major services running on Scala, and we could not be happier. I'll talk about the strategic & tactical rationale, gradual introduction to the new language, cultivating experts and mentoring junior developers. We will also cover the common roadblocks the leaders may run into, addressing the concerns of engineers and stakeholders, and building an engineering culture that facilitates innovation and talent growth. Please note that this talk is not a Ruby/Java/Scala religious debate - we believe in using the best tool for the job; and what works for us may not work for every org (which is where the culture comes in). My team's journey from "Holy crap! This looks academic and scary!" to "Let me whip out a service by EOD today" in a matter of months is something I am very proud of, and would love to share it with fellow developer community.
Paul Graham, the founder of startup incubator YCombinator, put it best when he described LISP as his old company's secret weapon. Think about, if you use all of the same tools as everyone else, how do you expect to achieve better results?
Clojure is a LISP language created in 2009 by Rich Hickey. Built initially on the Java Virtual Machine (JVM) it has since been ported to run on Microsoft and JavaScript. (That's right the browser). Clojure gives you all of the power and stability of the JVM without the clunkiness of Java.
Most developers have never worked with a functional language before and many who have found the use of parenthesis instead of braces intimidating. Don't worry. Once it is broken down to you, I think you will see the beauty of it.
In this fast and fun session, we will build an app using Clojure. We will enhance it, test it and explore why functional is a better programming model than OOPs. We will even explore why such programs are better at multitasking than object oriented ones.
Over the past few years, web-applications have started to play an increasingly important role in our lives. We expect them to be always available and the data to be always fresh. This shift into the realm of real-time data processing is now transitioning to physical devices, and Gartner predicts that the Internet of Things will grow to an installed base of 26 billion units by 2020.
Reactive web-applications are an answer to the new requirements of high-availability and resource efficiency brought by this rapid evolution. On the JVM, a set of new languages and tools has emerged that enable the development of entirely asynchronous request and data handling pipelines. At the same time, container-less application frameworks are gaining increasing popularity over traditional deployment mechanisms.
This talk is going to give you an introduction into one of the most trending reactive web-application stack on the JVM, involving the Scala programming language, the concurrency toolkit Akka and the web-application framework Play. It will show you how functional programming techniques enable asynchronous programming, and how those technologies help to build robust and resilient web-applications.
Debugging Spark: Scala and Python - Super Happy Fun Times @ Data Day Texas 2018Holden Karau
Apache Spark is one of the most popular big data projects, offering greatly improved performance over traditional MapReduce models. Much of Apache Spark’s power comes from lazy evaluation along with intelligent pipelining, which can make debugging more challenging. Holden Karau and Joey Echeverria explore how to debug Apache Spark applications, the different options for logging in Spark’s variety of supported languages, and some common errors and how to detect them.
Spark’s own internal logging can often be quite verbose. Holden and Joey demonstrate how to effectively search logs from Apache Spark to spot common problems and discuss options for logging from within your program itself. Spark’s accumulators have gotten a bad rap because of how they interact in the event of cache misses or partial recomputes, but Holden and Joey look at how to effectively use Spark’s current accumulators for debugging before gazing into the future to see the data property type accumulators that may be coming to Spark in future versions. And in addition to reading logs and instrumenting your program with accumulators, Spark’s UI can be of great help for quickly detecting certain types of problems. Holden and Joey cover how to quickly use the UI to figure out if certain types of issues are occurring in your job.
The talk will wrap up with Holden trying to get everyone to buy several copies of her new book, High Performance Spark.
Akka and the Zen of Reactive System DesignLightbend
In order to be successful with asynchronous programming, when coming from synchronous execution models you need to change your mindset and look at things from a slightly different perspective. In order to use Akka at it's best, you will have to change the way you think about application design (loosen coupling in space and time between components), and re-think what you've maybe learned in the past.
In this talk we uncover a number of rules that serve as a guide in designing concurrent distributed applications, how those apply to Akka, and how they can help you in daily app development.
Aimed at developers through architects, Akka team happy hAkker, Konrad Malawski, bends your parameters with regards to application design and asynchronous execution models.
Networks and Types - the Future of Akka @ ScalaDays NYC 2018Konrad Malawski
A look into the upcoming soon-to-be-stable typed Actor APIs in Akka. Shown at Scala Days NYC 2018, while Akka 2.5.13 was out. Looking at what will become the stable Akka Typed.
Introducing Scala to your Ruby/Java Shop : My experiences at IGNManish Pandit
With the move to SOA, IGN's API engineering became a traditional Java/Ruby shop. We introduced Scala to the team in August '11. As of April '12 we have our major services running on Scala, and we could not be happier. I'll talk about the strategic & tactical rationale, gradual introduction to the new language, cultivating experts and mentoring junior developers. We will also cover the common roadblocks the leaders may run into, addressing the concerns of engineers and stakeholders, and building an engineering culture that facilitates innovation and talent growth. Please note that this talk is not a Ruby/Java/Scala religious debate - we believe in using the best tool for the job; and what works for us may not work for every org (which is where the culture comes in). My team's journey from "Holy crap! This looks academic and scary!" to "Let me whip out a service by EOD today" in a matter of months is something I am very proud of, and would love to share it with fellow developer community.
Paul Graham, the founder of startup incubator YCombinator, put it best when he described LISP as his old company's secret weapon. Think about, if you use all of the same tools as everyone else, how do you expect to achieve better results?
Clojure is a LISP language created in 2009 by Rich Hickey. Built initially on the Java Virtual Machine (JVM) it has since been ported to run on Microsoft and JavaScript. (That's right the browser). Clojure gives you all of the power and stability of the JVM without the clunkiness of Java.
Most developers have never worked with a functional language before and many who have found the use of parenthesis instead of braces intimidating. Don't worry. Once it is broken down to you, I think you will see the beauty of it.
In this fast and fun session, we will build an app using Clojure. We will enhance it, test it and explore why functional is a better programming model than OOPs. We will even explore why such programs are better at multitasking than object oriented ones.
Over the past few years, web-applications have started to play an increasingly important role in our lives. We expect them to be always available and the data to be always fresh. This shift into the realm of real-time data processing is now transitioning to physical devices, and Gartner predicts that the Internet of Things will grow to an installed base of 26 billion units by 2020.
Reactive web-applications are an answer to the new requirements of high-availability and resource efficiency brought by this rapid evolution. On the JVM, a set of new languages and tools has emerged that enable the development of entirely asynchronous request and data handling pipelines. At the same time, container-less application frameworks are gaining increasing popularity over traditional deployment mechanisms.
This talk is going to give you an introduction into one of the most trending reactive web-application stack on the JVM, involving the Scala programming language, the concurrency toolkit Akka and the web-application framework Play. It will show you how functional programming techniques enable asynchronous programming, and how those technologies help to build robust and resilient web-applications.
Debugging Spark: Scala and Python - Super Happy Fun Times @ Data Day Texas 2018Holden Karau
Apache Spark is one of the most popular big data projects, offering greatly improved performance over traditional MapReduce models. Much of Apache Spark’s power comes from lazy evaluation along with intelligent pipelining, which can make debugging more challenging. Holden Karau and Joey Echeverria explore how to debug Apache Spark applications, the different options for logging in Spark’s variety of supported languages, and some common errors and how to detect them.
Spark’s own internal logging can often be quite verbose. Holden and Joey demonstrate how to effectively search logs from Apache Spark to spot common problems and discuss options for logging from within your program itself. Spark’s accumulators have gotten a bad rap because of how they interact in the event of cache misses or partial recomputes, but Holden and Joey look at how to effectively use Spark’s current accumulators for debugging before gazing into the future to see the data property type accumulators that may be coming to Spark in future versions. And in addition to reading logs and instrumenting your program with accumulators, Spark’s UI can be of great help for quickly detecting certain types of problems. Holden and Joey cover how to quickly use the UI to figure out if certain types of issues are occurring in your job.
The talk will wrap up with Holden trying to get everyone to buy several copies of her new book, High Performance Spark.
Akka and the Zen of Reactive System DesignLightbend
In order to be successful with asynchronous programming, when coming from synchronous execution models you need to change your mindset and look at things from a slightly different perspective. In order to use Akka at it's best, you will have to change the way you think about application design (loosen coupling in space and time between components), and re-think what you've maybe learned in the past.
In this talk we uncover a number of rules that serve as a guide in designing concurrent distributed applications, how those apply to Akka, and how they can help you in daily app development.
Aimed at developers through architects, Akka team happy hAkker, Konrad Malawski, bends your parameters with regards to application design and asynchronous execution models.
nephrotic syndrome is characterized by hypoalbuminemia, proteinuria, edema & hyperlipidemia. It is frequently found in children but also not uncommon in adults
Lipid profile is an important group of tests used to diagnose hyperlipidemias. it is also used in Investigating Myocardial infarction , Diabetes mellitus & nephrotic syndrome
Incremental Development with Lisp: Building a Game and a WebsiteJames Long
I show how powerful incremental development with Lisp/Scheme is by showing a website and game I created by running the application and developing them real-time.
The State of Managed Runtimes 2013, by Attila SzegediZeroTurnaround
There’s JVM, and that’s it, right? Well, not exactly. Even within JVM, there’s an increasing support for running all kinds of non-Java languages: we have invokedynamic, but it’s being improved, and new layers of functionality are emerging on top of it, making JVM a better home for all kinds of programming languages. There’s life outside of JVM too. JavaScript seems to be a new assembler-lever compilation target even for C programs (I’ll show some amusing examples of what exactly you can run these days in a browser) , and there are some independent efforts at managed runtimes in various stages of completion that seem promising – PyPy, Topaz, Rubinius, Parrot VM (it’s alive again!). This talk is admittedly a language-runtime-enthusiast’s walk-through the things he finds interesting happening this year. Recorded at GeekOut 2013.
The Inclusive Web: hands-on with HTML5 and jQuerycolinbdclark
Driven by technologies such as HTML5, JavaScript, and jQuery, innovative new user experiences are thriving on the Web. This workshop, presented by Justin Obara and Colin Clark from the Fluid community (http://fluidproject.org), will provide Web designers and developers with an overview of modern Web accessibility techniques, providing hands-on ways to make HTML5 and jQuery-based applications more accessible, flexible, and inclusive of a diverse range of users. We’ll also cover some of the features of Fluid Infusion, an application framework built on top of jQuery.
3. Agenda
• What am I doing here?
• A small tour of functional reactive programming
in Scala
• What’s a game, from a functional perspective
• Type-safe Entity-Component-System
implementation(bonus)
5. What Am I Doing Here?
• Introducing Scala
!
•
•
6. What Am I Doing Here?
• Introducing Scala
• Promoting LibGDX(hopefully)
•
•
7. What Am I Doing Here?
• Introducing Scala
• Promoting LibGDX(hopefully)
• Sharing my humble opinions about reactive
functional programming
•
8. What Am I Doing Here?
• Introducing Scala
• Promoting LibGDX(hopefully)
• Sharing my humble opinions about reactive
functional programming
• It’s not really about game developement
9. What Am I Doing Here?
• Introducing Scala
• Promoting LibGDX(hopefully)
• Sharing my humble opinions about reactive
functional programming
• It’s not really about game developement
(Yes I lied :))
11. I’m Not an Evangelist!
• Scala(or RxScala, or functional programming, or
any other buzzword) is not the holy grail…
!
•
12. I’m Not an Evangelist!
• Scala(or RxScala, or functional programming, or
any other buzzword) is not the holy grail…
• Sometimes they’re ugly…
•
implicit def toGdxArray[T<:AnyRef]!
(iterable: Iterable[T])!
(implicit arg0: ClassTag[T])!
: com.badlogic.gdx.utils.Array[T] = {!
new com.badlogic.gdx.utils.Array[T](iterable.toArray)!
}!
18. LibGDX
• A cross-platform game engine
• Desktop/Android/iOS(robovm)/HTML5(GWT)
• You can use any JVM-based language
• (except HTML5, casue GWT compiles Java
directely)
19. More on LibGDX
• Basic Structure
!
!
!
class MyGame extends Game {!
override def create() {!
// initialize!
}!
!
override def render() {!
val delta = Gdx.graphics.getDeltaTime!
// updateGame(delta)!
// renderGame()!
}!
}!
20. More on LibGDX
• Render
!
!
!
spriteBatch.begin()!
val texture = new TextureRegion(!
! new Texture(Gdx.files.internal(“images/bg.png"))!
)!
spriteBatch.draw(texture, 0, 0}!
spriteBatch.end()!
22. More on LibGDX
• Load assets with different resolutions
!
!
!
val resolutions = List(new Resolution(320, 480, "320x480"),!
new Resolution(640, 1136, "640x1136"))!
val resolver = new ResolutionFileResolver(!
! ! ! ! ! ! new InternalFileHandleResolver(), resolutions)!
val manager = new AssetManager()!
manager.setLoader(classOf[Texture], new TextureLoader(resolver))!
manager.load("images/bg.png", classOf[Texture])!
// will load "images/640x1136/bg.png" on iPhone5!
23. More on LibGDX
• Call native code through Java
!
!
!
new IOSApplication(new Retinol(), config) {!
@Override!
public void log (String tag, String message) {!
Foundation.log("[info] " + tag + ": " + message);!
}!
};!
24. Small Tour of Functional Reactive
Programming in Scala
25. Small Tour of Functional Reactive
Programming in Scala
!
!
!
!
26. Small Tour of Functional Reactive
Programming in Scala
• The “Better Java”
!
!
!
27. Small Tour of Functional Reactive
Programming in Scala
• The “Better Java”
!
!
!
class Vector2 {!
private float x;!
private float y;!
public Vector2(float x, float y) {!
this.x = x;!
this.y = y;!
}!
public int getX() { return x; }!
public int getY() { return y; }!
}!
28. Small Tour of Functional Reactive
Programming in Scala
• The “Better Java”
!
!
!
case class Vector2(x: Float, y: Float)!
29. Small Tour of Functional Reactive
Programming in Scala
• The “Better Java”
!
!
• If there is a missing ID, get ready to watch the world burn
idList.stream().map(id -> dict.get(id).contains(name))!
30. Small Tour of Functional Reactive
Programming in Scala
• The “Better Java”
!
!
• If there is a missing ID, get ready to watch the world burn
… later!
idList.stream().map(id -> dict.get(id).contains(name))!
31. Small Tour of Functional Reactive
Programming in Scala
• The “Better Java”
!
!
•
idList.flatMap(dict.get(_))!
32. Small Tour of Functional Reactive
Programming in Scala
• The “Better Java”
!
!
• Thus, Scala is not just for “lambda expression”.
idList.flatMap(dict.get(_))!
33. Small Tour of Functional Reactive
Programming in Scala
34. Small Tour of Functional Reactive
Programming in Scala
35. Small Tour of Functional Reactive
Programming in Scala
•
36. Small Tour of Functional Reactive
Programming in Scala
• “Purely functional” language = Stateless.
!
!
!
37. Small Tour of Functional Reactive
Programming in Scala
• “Purely functional” language = Stateless.
• Scala is not pure, fortunately.
!
!
38. Small Tour of Functional Reactive
Programming in Scala
• “Purely functional” language = Stateless.
• Scala is not pure, fortunately?
!
!
list.foldLeft(List[Int]()) {!
(accu, elem) => f(elem) :: accu!
}!
for(elem <- list)!
newList = newList :+ elem!
39. Small Tour of Functional Reactive
Programming in Scala
• But it’s definitely a bad idea to pass mutable
non-singleton objects all around.
• Code like this really makes me cringe:
(from Unity)
GameObject.Find("Hand");!
40. Small Tour of Functional Reactive
Programming in Scala
• Thinking “what if I have to explicitly pass every
single dependeny through constructor” makes
me write better OOP code.
• More on this later.
41. Small Tour of Functional Reactive
Programming in Scala
42. Small Tour of Functional Reactive
Programming in Scala
43. Small Tour of Functional Reactive
Programming in Scala
• A way to implement Observer Pattern.
• An Observable is an event source. When a
new event occurs, it notifis all its Observers.
!
!
44. Small Tour of Functional Reactive
Programming in Scala
• A way to implement Observer Pattern.
• An Observable is an event source. When a
new event occurs, it notifis all its Observers.
!
!
val numbers = Observable.from(List(1,2,3,4))!
numbers.subscribe(n => println(n))!
45. Small Tour of Functional Reactive
Programming in Scala
• A way to implement Observer Pattern.
• An Observable is an event source. When a
new event occurs, it notifis all its Observers.
!
!
• Why bother?
val numbers = Observable.from(List(1,2,3,4))!
numbers.subscribe(n => println(n))!
46. Small Tour of Functional Reactive
Programming in Scala
• java.util.Observable isn’t good enough:
• No type parameter
• No composition
• No scheduling
47. Small Tour of Functional Reactive
Programming in Scala
• Type parameter
!
!
!
• util.Observable can only pass Object …
Observable.from(List(1,2,3))!
.map(_.toString)!
// Observable[String]!
48. Small Tour of Functional Reactive
Programming in Scala
• Composition
!
!
• The game loop should wait the assets to get
loaded.
val tickEventRx = ...!
val assetLoadingEventRx = ...!
val processor = GameProcessor(tickEventRx)!
49. Small Tour of Functional Reactive
Programming in Scala
• Composition
!
!
• Naturally dependency injection = better OO!
// The main game loop starts once all assets are loaded!
val newTickRx = tickRx awaitComplete assetLoadingRx!
val processor = GameProcessor(newTickRx)!
50. Small Tour of Functional Reactive
Programming in Scala
• Composition
!
!
•
def awaitComplete[U](that: Observable[U]): Observable[T] = {!
var completed = false!
that.subscribe(!
t => {},!
e => e.printStackTrace(),!
() => completed = true!
)!
observable.filter(t => completed)!
}!
51. Small Tour of Functional Reactive
Programming in Scala
• Scheduling
!
!
!
• It’s easy to integrate with other libraries cause
we can control when an Observable emits.
val TickScheduler: Scheduler = new rx.Scheduler {!
override def createWorker: rx.Scheduler.Worker = new TimerWorker!
}!
class TimerWorker extends rx.Scheduler.Worker {!
override def schedule(…): Subscription = {!
Timer.schedule(task, delaySeconds.toFloat)!
}!
}
52. What’s a Game, from a
Functional Perspective
• Game = Simulation with Inputs
!
!
53. What’s a Game, from a
Functional Perspective
• Simulation = apply a function repeatively
!
!
finalWorld = update(update(...update(world)...))!
update(world) = world of next tick
54. What’s a Game, from a
Functional Perspective
• Simulation = apply a function per frame
!
!
def onFrame(delta) {!
world = update(world, delta)!
render(world)!
}!
55. What’s a Game, from a
Functional Perspective
• Simulation = apply a function per frame
!
!
tickEventRx.subscribe(tickEvent =>!
world = update(world, tickEvent.delta)!
render(world)!
)!
56. What’s a Game, from a
Functional Perspective
• Wait a second! Inputs are events too!
!
!
touchDownEventRx.subscribe(touchDownEvent =>!
world = birdFlyUp(world)!
)!
57. What’s a Game, from a
Functional Perspective
• For example:
!
!
!
val touchSubject = Subject[TouchEvent]()!
!
gdxInput.setInputProcessor(new InputAdapter {!
override def touchDown(screenX: Int, screenY: Int,!
pointer: Int, button: Int): Boolean = {!
touchSubject.onNext(TouchDownEvent(screenX, screenY, pointer, button))!
true!
}!
})!
!
InputEventRxs(!
touchEventRx = touchSubject!
)!
58. What’s a Game, from a
Functional Perspective
• Now we have a consistent way to render images
& update objects & handle player
input(including network input)
!
!
class Processor(rxA, rxB...) {!
rxA.subscribe({!
world = foo(world)!
sideEffectA()!
})!
rxB.subscribe({!
world = foo(world)!
sideEffectB()!
})!
}!
59. What’s a Game, from a
Functional Perspective
• Now we have a consistent way to render images
& update objects & handle player
input(including network input)
!
!
class Processor(rxA, rxB...) {!
rxA.subscribe({!
world = foo(world)!
sideEffectA()!
})!
rxB.subscribe({!
world = foo(world)!
sideEffectB()!
})!
}!
60. What’s a Game, from a
Functional Perspective
• Necessary Evil…?
!
!
!
61. What’s a Game, from a
Functional Perspective
• The middle way!
!
!
!
trait Procedure!
trait SideEffect extends (World => Unit) with Procedure!
trait Transformation extends (World => World) with Procedure!
object Processor {!
def apply(rxA, rxB...): Observable[Procedure] {!
Observable.from(!
List(rxA.map(...),!
rxB.map(...)...)!
).flatten!
}!
}!
!
Observable.from(processorA, processorB...).flatten!
62. What’s a Game, from a
Functional Perspective
!
• Now we can decide the execution order, log the
procedures, combine similar side-effects, etc…
!
68. Type-Safe Another Entity-
Component-System
• Two questions:
• getComponent may return null.
• How to represent the dependencies between
components? e.g. Rigidbody requires
Transform.
69. Type-Safe Another Entity-
Component-System
• getComponent may return null
• We can make it return Option[Component]
instead of Component
• However it still leads unnecessary pattern
matching and collection traversal…
76. Type-Safe Another Entity-
Component-System
!
• Cake Pattern solved both problems: type safety
and dependency management.
• Downside: we can no longer dynamically add/
remove components into/from an entity.