Play Flashcards
As at 2016 what was the only full-stack reactive web application framework for the JVM
play
Play is built on top of _______ and leverages its reactive behaviour by using __________
Netty
Asynchronous stream handling
Play deals with the typical concerns of web application development such as client- side resource handling, project compilation, and packaging by making use of
the sbt build tool
They have certainly evolved a lot over the past decades, especially in terms of CPU clock speed (MHz to GHz) and memory (kilobytes to gigabytes). The most significant change, however, which has happened in the past few years, is that although the clock speed of CPUs isn’t increasing very much, the
the number of cores each CPU has is changing
what is the von Neumann bottleneck
There is a shared bus between the program memory and data memory leads to the von Neumann bottleneck.
Because the single bus can only access one of the two classes of memory at a time, throughput is lower than the rate at which the CPU can work.
Roughly speaking, there are two categories of programming models in which web serv- ers can be placed.
Threaded
Evented
The threaded model
large numbers of threads take care of handling the incoming requests.
The evented model
a small number of request-processing threads communicate with each other through message passing.
Example of a threaded server
Apache Tomcat, IIS
The evented model only works if
the entire pipeline is asynchronous
What is the architectural challenge you seek to address with Actors and Events
Developing web applications fit for multicore architectures
Languages and tools favoring the use of ______ _______make it easier to develop web applications that have to deal with concurrent access.
immutable state
Building applications that don’t fail is extremely difficult, and if those applications are meant to be built at a reasonable pace it’s close to impossible. Instead of avoiding failure, reactive systems are designed and built from the ground up to embrace failure, leveraging the principle of
supervision
What are the 8 fallacies of distributed computing
1 The network is reliable 2 Latency is zero 3 Bandwidth is infinite 4 The network is secure 5 Topology doesn’t change 6 There is one administrator 7 Transport cost is zero 8 The network is homogeneous
What is an iteratee
An iteratee is a construct that allows you to consume streams of data asynchronously; it’s one of the cornerstones of the Play Framework.
The counterpart of an iteratee is
an enumerator
Just as the iteratee is an ____________, the enumerator is an ____________
asynchronous consumer of data,
asynchronous producer of data:
A component that lets you transform streaming data on the fly, called an
enumeratee
An Enumeratee[From, To] does what
takes chunks of type From from an enumerator and transforms them into chunks of type To.
How is using an Enumeratee different from using java.io.Inputstream and java.io.outputstream?
iteratees let you manipulate streams of data asynchronously. In prac- tice, this means that these streams won’t hold on to a thread in the absence of new data.
java.io.OutputStream blocks the thread it’s using until new data is available.
What is the The iteratee the enumerator and enumeratee in the fawcet analogy
The enumerator is the fawcet The Enumeratee is the nozzel of the fawcet The iteratee is the class that receives the flow of water
What is the collective term for iteratees, enumerators and enumeratees
Reactive streams
What is set to replace iteratees in the next release of Play
Akka streams
What are web sockets
is an advanced technology that makes it possible to open an interactive (full duplex) communication session between the user’s browser and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.
Play’s WebSocket handling mechanism is built around
Akka streams
play.extras.iteratees.Encoding.decode does what
decode a stream of bytes as a UTF-8 string.
play.extras.iteratees.JsonIteratees.jsSimpleObject
parse a single JSON object.
play.api.libs.iteratee.Enumeratee.grouped
will apply the jsSimpleObject iteratee over and over again until the stream is finished.
what is needed for sbt to correctly run a play app
Play needs to be imported in both the
build. sbt (or build.scala) file as well as the
plugins. sbt file
the _______________file is the page we will be able to see when we run our application
The views/main.scala.html file is the page we will be able to see when we run our application
why the file is named main.scala.html and not main.html
because it is a twirl template
what is the syntax to start a new play project using activator
activator new play-scala
conf/messages ?
this is where all of the default messages are stored (you could then have a messages file for every other localisation e.g. conf/messages.en-us (for english)
The I18nSupport trait gives you
an implicit Messages value as long as there is a Lang or a RequestHeader in the implicit scope.
play.api.i18n.I18nSupport
play.i18n.I18nSupport
what is the difference?
the .api is reserved for scala, otherwise it is Java
dependency injection
a technique whereby one object supplies the dependencies of another object
In dependency injection passing the service to the client, rather than allowing a client to build or find the service, is the fundamental requirement of the pattern.
This fundamental requirement means that
using values (services) produced within the class from new or static methods is prohibited
Twirl templates can be generated as a class rather than a static object by
declaring a constructor using a special @this(args) syntax at the top of the template.
Default dependency injection framework for Play
Guice