SlideShare a Scribd company logo
1 of 23
Download to read offline
Short intro to Scala and the 
Play! Framework 
50 - 60 minutes 
Last updated: Sept 2014 falmeida1988@gmail.com 
Leveraging modern programming techniques to make 
safer, faster and more predictable applications
Scala - First encounter 
def hello() = { 
println("Hello, world!") 
} 
var aMap = Map("Red" -> "Apple", "Yellow" -> "Peach") 
aMap += ("Purple" -> "Grape") 
def factorial(x: BigInt): BigInt = 
if (x == 0) 1 else x * factorial(x - 1) 
class MyClass(index: Int, name: String) 
functions 
collections 
recursive functions 
classes
Scala - Background 
● Created by Martin Odersky at EPFL in 2003 
● Aimed at overcoming Java’s weaknesses while allowing for easy migration 
for former Java developers 
● One of the few object-functional languages (also: F#) 
● One of the JVM-compliant languages (also: groovy, clojure, jruby, jython)
Scala selling points 
● Functional/Object Oriented hybrid - use one, the other, or both 
● More elegant, less painful concurrency constructs 
● Uncluttered, concise syntax 
● Seamless interoperability and compatibility with Java 
● Typing: expressive type system / static typing / type safety / type inference
Quick syntax walkthrough 
● no type declaration prior to use (due to type-inference) 
var msg = "Hello, world!" 
● braces are only needed for multiline blocks 
def max(x: Int, y: Int) = if (x > y) x else y 
def max2(x: Int, y: Int) = { 
if (x > y) x 
else y 
} 
no braces 
yes braces
Quick syntax walkthrough 
● no semicolons at the end (unless you want multiple statements) 
println(line); println(line) 
println(line) 
println(line) 
equivalent code
Quick syntax walkthrough 
● type comes after variable name (only when required or for usability) 
def max(x: Int, y: Int): Int = 
if (x > y) x else y 
val m = new HashMap[Int, String] () 
required types for 
val m1: Map[Int, String] = new HashMap() 
arguments 
optional return type 
either is acceptable 
not necessary to annotate both sides 
val m2: HashMap[Int, String] = new HashMap[Int, String] ()
Quick syntax walkthrough 
● val for immutable variables, var for mutable variables 
val msg = "Hello, world!" 
msg = "Another message!" // ERROR: reassignment to val 
var msg2 = "Hello, world!" 
msg2 = "Another message!" // no error
Quick syntax walkthrough 
● statements also return a value (if, for, while, def) - which means they are 
also expressions 
var result1 = "" 
if(marks >= 50) 
result = "passed" 
else 
result = "failed" 
val result2 = if(marks >= 50) 
"passed" 
else 
"failed" 
using if as a 
statement 
if as an expression
Quick syntax walkthrough 
● return statements are allowed but generally not needed 
def multiply(a: Int,b:Int):Int = 
return a*b 
def sum(x:Int,y:Int) = 
x + y 
def greet() = println( "Hello, world!" ) 
explicitly using return 
When no return is provided, 
last value computed by the 
function is returned 
Functions that return no 
useful values have a result 
type of Unit
Quick syntax walkthrough 
● function literals or anonymous functions 
(x: Int) => x * 2 
val double = (x: Int) => x * 2 
● example usage: as parameter to function map: 
List(1,2,3,4,5).map{ (x: Int) => x * 2 } 
//evaluates to List(2, 4, 6, 8, 10) 
a function that takes an Int 
and multiplies it by two 
function value being 
assigned to a variable 
function map takes another 
function as argument
Scala, Java Comparison 
scala class MyClass(index: Int, name: String) 
class MyClass { 
private int index; 
private String name; 
public MyClass(int index, String name) { 
this.index = index; 
this.name = name; 
} 
} 
java
Scala, Java Comparison 
scala val nameHasUpperCase = name.exists(_.isUpper) 
boolean nameHasUpperCase = false; 
for (int i = 0; i < name.length(); ++i) { 
if (Character.isUpperCase(name.charAt(i))) { 
nameHasUpperCase = true; 
break; 
} 
} 
java
Scala, Java Interoperability 
● You can use Java code in Scala as-is (i.e. no changes needed). 
● Scala classes can subclass Java classes, you can instantiate Java classes 
in Scala, you can access methods, fields (even if they are static), etc. 
● You can also use Scala code in Java projects, as long as you don’t use 
many advanced Scala concepts that are not possible in Java. 
● Similar code generated by Scala and Java usually generates the exact 
same bytecode, as can be verified using tools like javap
Environment 
● Console 
● sbt - dependency and package management 
● JVM integration 
● Typesafe products (Akka, Play, Activator, Spray, Slick, etc) 
● All of your favourite Java libraries 
● Testing suites (Unit, Integration, Acceptance, Property-based, etc) 
● Small but high-level community
Weaknesses 
● It’s a large language. Users are advised not to try to use many different 
concepts at the same time, especially when starting out. 
● Scala has a somewhat steep learning curve and its complex type system is 
powerful but hard to grasp at times. 
● Implicit conversions are useful but easily misused and may make code 
harder to understand. 
● Complex function signatures may put some off.
Play Framework 
● MVC Web Framework; supports Java and Scala 
● Created in 2007 
● Used at Linkedin, Coursera, The Guardian, etc. 
● Uses sbt for dependency management 
● As of September 2014, it has had 5000 commits by over 350 contributors. 
● The Simplest Possible Play App
Play Features 
● Play has all default features one can expect from a modern framework: 
○ MVC-based separation of concerns 
○ Support for ORMs (Java) or FRMs (Scala) 
○ Rich models with support for Forms, Validation, etc. 
○ Database Migration (called evolutions) 
○ Template engine (Scala-based) 
○ Extensive routing 
○ Support for REST-only Apps 
○ Lots of community-provided plugins 
○ Supported by Typesafe
Play - Application Layout 
app/ -- Application sources 
| assets/ -- LESS, Coffeescript sources 
| controllers/ -- Controllers 
| models/ -- Domain models 
| views/ -- Templates 
build.sbt -- Build configuration 
conf/ -- Configuration files 
| application.conf -- Main configuration file 
| routes -- Routes definition 
public/ -- Public folder (CSS, JS, etc) 
project/ -- sbt configuration files 
logs/ -- Logs 
target/ -- Generated files - ignore 
test/ -- Sources for tests
Play Framework - Examples 
● Displaying a view from a controller action 
package controllers 
import play.api._ 
import play.api.mvc._ 
object Application extends Controller { 
def index = Action { 
Ok(views.html.index("Your new application is ready.")) 
} 
} 
import libraries 
create a controller 
define actions as methods
Play Framework - Examples 
● Displaying a view with some data 
package controllers 
import models._ 
import play.api._ 
import play.api.mvc._ 
import play.api.Play.current 
object Application extends Controller { 
this method returns a List[Computer] 
def index = Action { implicit request => 
val computers = Computer .list 
Ok(views.html.web.index( "Hello! I'm the WEB!" , computers)) 
} 
} 
the Computer model was defined in 
package models (not shown here) 
instantiate a view file and feed it 
a string and a list of computers
Activator 
● Web-based IDE and project viewer, built by Typesafe 
● A large number of sample applications (templates) to study and learn from
Resources 
● Scala Programming Language (Wikipedia Article) 
● Scala official site 
● Typesafe 
● Programming in Scala Book on Amazon 
● A preset Virtual Machine for Scala/Play Development 
● Functional Programming Principles in Scala on Coursera 
● Principles of Reactive Programming on Coursera 
● Play Framework Official Website 
● ScalaJavaInterop Project 
● Play Framework (Wikipedia Article) 
● Using Scala on Heroku 
● Typesafe Activator 
● All Available Activator Templates

More Related Content

What's hot

Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play FrameworkKnoldus Inc.
 
Introduction to Asynchronous scala
Introduction to Asynchronous scalaIntroduction to Asynchronous scala
Introduction to Asynchronous scalaStratio
 
Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...All Things Open
 
Java Enterprise Edition Concurrency Misconceptions
Java Enterprise Edition Concurrency Misconceptions Java Enterprise Edition Concurrency Misconceptions
Java Enterprise Edition Concurrency Misconceptions Haim Yadid
 
Akka Actor presentation
Akka Actor presentationAkka Actor presentation
Akka Actor presentationGene Chang
 
Servlet and JSP
Servlet and JSPServlet and JSP
Servlet and JSPGary Yeh
 
Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1Matthew Barlocker
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Matthew Groves
 
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)Stephen Chin
 
System Integration with Akka and Apache Camel
System Integration with Akka and Apache CamelSystem Integration with Akka and Apache Camel
System Integration with Akka and Apache Camelkrasserm
 
Akka Cluster in Java - JCConf 2015
Akka Cluster in Java - JCConf 2015Akka Cluster in Java - JCConf 2015
Akka Cluster in Java - JCConf 2015Jiayun Zhou
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disquszeeg
 
Advanced akka features
Advanced akka featuresAdvanced akka features
Advanced akka featuresGrzegorz Duda
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN StackTroy Miles
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and ActivatorKevin Webber
 
Java EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSFJava EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSFJiayun Zhou
 
Don't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 InsteadDon't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 InsteadWASdev Community
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with GradleRyan Cuprak
 
Core web application development
Core web application developmentCore web application development
Core web application developmentBahaa Farouk
 

What's hot (20)

Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play Framework
 
Introduction to Asynchronous scala
Introduction to Asynchronous scalaIntroduction to Asynchronous scala
Introduction to Asynchronous scala
 
Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...
 
Java Enterprise Edition Concurrency Misconceptions
Java Enterprise Edition Concurrency Misconceptions Java Enterprise Edition Concurrency Misconceptions
Java Enterprise Edition Concurrency Misconceptions
 
Akka Actor presentation
Akka Actor presentationAkka Actor presentation
Akka Actor presentation
 
Servlet and JSP
Servlet and JSPServlet and JSP
Servlet and JSP
 
Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017
 
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
 
System Integration with Akka and Apache Camel
System Integration with Akka and Apache CamelSystem Integration with Akka and Apache Camel
System Integration with Akka and Apache Camel
 
Akka Cluster in Java - JCConf 2015
Akka Cluster in Java - JCConf 2015Akka Cluster in Java - JCConf 2015
Akka Cluster in Java - JCConf 2015
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
 
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter PilgrimJavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
 
Advanced akka features
Advanced akka featuresAdvanced akka features
Advanced akka features
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN Stack
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
Java EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSFJava EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSF
 
Don't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 InsteadDon't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 Instead
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
 
Core web application development
Core web application developmentCore web application development
Core web application development
 

Viewers also liked

Scala, Play Framework и SBT для быстрого прототипирования и разработки веб-пр...
Scala, Play Framework и SBT для быстрого прототипирования и разработки веб-пр...Scala, Play Framework и SBT для быстрого прототипирования и разработки веб-пр...
Scala, Play Framework и SBT для быстрого прототипирования и разработки веб-пр...Magneta AI
 
Play Framework: The Basics
Play Framework: The BasicsPlay Framework: The Basics
Play Framework: The BasicsPhilip Langer
 
sbt, past and future / sbt, 傾向と対策
sbt, past and future / sbt, 傾向と対策sbt, past and future / sbt, 傾向と対策
sbt, past and future / sbt, 傾向と対策scalaconfjp
 
4º básico a semana 03 de junio al 10 de junio
4º básico a  semana  03 de junio al 10 de junio4º básico a  semana  03 de junio al 10 de junio
4º básico a semana 03 de junio al 10 de junioColegio Camilo Henríquez
 
Recruit, Retain, Realize - How Third Party Transactional Data Can Power Your ...
Recruit, Retain, Realize - How Third Party Transactional Data Can Power Your ...Recruit, Retain, Realize - How Third Party Transactional Data Can Power Your ...
Recruit, Retain, Realize - How Third Party Transactional Data Can Power Your ...Doug Oldfield
 
Postavte zeď mezi svoje vývojáře
Postavte zeď mezi svoje vývojářePostavte zeď mezi svoje vývojáře
Postavte zeď mezi svoje vývojářeLadislav Prskavec
 
Marquette Social Listening presentation
Marquette Social Listening presentationMarquette Social Listening presentation
Marquette Social Listening presentation7Summits
 
807 103康八上 my comic book
807 103康八上 my comic book807 103康八上 my comic book
807 103康八上 my comic bookAlly Lin
 
อุปกรณ์เครือข่ายงคอมพิวเตอร์
อุปกรณ์เครือข่ายงคอมพิวเตอร์อุปกรณ์เครือข่ายงคอมพิวเตอร์
อุปกรณ์เครือข่ายงคอมพิวเตอร์ooh Pongtorn
 
Reclaiming the idea of the University
Reclaiming the idea of the UniversityReclaiming the idea of the University
Reclaiming the idea of the UniversityRichard Hall
 
Scala play-framework
Scala play-frameworkScala play-framework
Scala play-frameworkAbdhesh Kumar
 
Introduzione a Netwrix Auditor 8.5
Introduzione a Netwrix Auditor 8.5Introduzione a Netwrix Auditor 8.5
Introduzione a Netwrix Auditor 8.5Maurizio Taglioretti
 
Multimodal Residual Learning for Visual QA
Multimodal Residual Learning for Visual QAMultimodal Residual Learning for Visual QA
Multimodal Residual Learning for Visual QANamHyuk Ahn
 

Viewers also liked (20)

Scala, Play Framework и SBT для быстрого прототипирования и разработки веб-пр...
Scala, Play Framework и SBT для быстрого прототипирования и разработки веб-пр...Scala, Play Framework и SBT для быстрого прототипирования и разработки веб-пр...
Scala, Play Framework и SBT для быстрого прототипирования и разработки веб-пр...
 
Play Framework: The Basics
Play Framework: The BasicsPlay Framework: The Basics
Play Framework: The Basics
 
sbt, past and future / sbt, 傾向と対策
sbt, past and future / sbt, 傾向と対策sbt, past and future / sbt, 傾向と対策
sbt, past and future / sbt, 傾向と対策
 
4º básico a semana 03 de junio al 10 de junio
4º básico a  semana  03 de junio al 10 de junio4º básico a  semana  03 de junio al 10 de junio
4º básico a semana 03 de junio al 10 de junio
 
Ingles
InglesIngles
Ingles
 
Recruit, Retain, Realize - How Third Party Transactional Data Can Power Your ...
Recruit, Retain, Realize - How Third Party Transactional Data Can Power Your ...Recruit, Retain, Realize - How Third Party Transactional Data Can Power Your ...
Recruit, Retain, Realize - How Third Party Transactional Data Can Power Your ...
 
Postavte zeď mezi svoje vývojáře
Postavte zeď mezi svoje vývojářePostavte zeď mezi svoje vývojáře
Postavte zeď mezi svoje vývojáře
 
Marquette Social Listening presentation
Marquette Social Listening presentationMarquette Social Listening presentation
Marquette Social Listening presentation
 
6º básico a semana 09 al 13 de mayo (1)
6º básico a semana 09  al 13 de  mayo (1)6º básico a semana 09  al 13 de  mayo (1)
6º básico a semana 09 al 13 de mayo (1)
 
807 103康八上 my comic book
807 103康八上 my comic book807 103康八上 my comic book
807 103康八上 my comic book
 
อุปกรณ์เครือข่ายงคอมพิวเตอร์
อุปกรณ์เครือข่ายงคอมพิวเตอร์อุปกรณ์เครือข่ายงคอมพิวเตอร์
อุปกรณ์เครือข่ายงคอมพิวเตอร์
 
Reclaiming the idea of the University
Reclaiming the idea of the UniversityReclaiming the idea of the University
Reclaiming the idea of the University
 
Scala play-framework
Scala play-frameworkScala play-framework
Scala play-framework
 
Frede space up paris 2013
Frede space up paris 2013Frede space up paris 2013
Frede space up paris 2013
 
Gamification review 1
Gamification review 1Gamification review 1
Gamification review 1
 
Giveandget.com
Giveandget.comGiveandget.com
Giveandget.com
 
User experience eBay
User experience eBayUser experience eBay
User experience eBay
 
Introduzione a Netwrix Auditor 8.5
Introduzione a Netwrix Auditor 8.5Introduzione a Netwrix Auditor 8.5
Introduzione a Netwrix Auditor 8.5
 
iProductive Environment Platform
iProductive Environment PlatformiProductive Environment Platform
iProductive Environment Platform
 
Multimodal Residual Learning for Visual QA
Multimodal Residual Learning for Visual QAMultimodal Residual Learning for Visual QA
Multimodal Residual Learning for Visual QA
 

Similar to Short intro to scala and the play framework

BCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersBCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersMiles Sabin
 
An Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersAn Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersMiles Sabin
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Martin Odersky
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java ProgrammersEric Pederson
 
An Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional ParadigmsAn Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional ParadigmsMiles Sabin
 
Basic info on java intro
Basic info on java introBasic info on java intro
Basic info on java introkabirmahlotra
 
Basic info on java intro
Basic info on java introBasic info on java intro
Basic info on java introkabirmahlotra
 
Scala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistScala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistpmanvi
 
A Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java DevelopersA Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java DevelopersMiles Sabin
 
Miles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersMiles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersSkills Matter
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
Scala clojure techday_2011
Scala clojure techday_2011Scala clojure techday_2011
Scala clojure techday_2011Thadeu Russo
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 

Similar to Short intro to scala and the play framework (20)

BCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersBCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java Developers
 
An Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersAn Introduction to Scala for Java Developers
An Introduction to Scala for Java Developers
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java Programmers
 
An Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional ParadigmsAn Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional Paradigms
 
Scala - core features
Scala - core featuresScala - core features
Scala - core features
 
Basic info on java intro
Basic info on java introBasic info on java intro
Basic info on java intro
 
Basic info on java intro
Basic info on java introBasic info on java intro
Basic info on java intro
 
Java
JavaJava
Java
 
Scala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistScala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologist
 
A Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java DevelopersA Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java Developers
 
Miles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersMiles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java Developers
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
Scala clojure techday_2011
Scala clojure techday_2011Scala clojure techday_2011
Scala clojure techday_2011
 
Scala ntnu
Scala ntnuScala ntnu
Scala ntnu
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
.NET Vs J2EE
.NET Vs J2EE.NET Vs J2EE
.NET Vs J2EE
 

More from Felipe

Aula rotulação automática - Automatic tagging
Aula rotulação automática - Automatic taggingAula rotulação automática - Automatic tagging
Aula rotulação automática - Automatic taggingFelipe
 
First steps with Keras 2: A tutorial with Examples
First steps with Keras 2: A tutorial with ExamplesFirst steps with Keras 2: A tutorial with Examples
First steps with Keras 2: A tutorial with ExamplesFelipe
 
Word embeddings introdução, motivação e exemplos
Word embeddings  introdução, motivação e exemplosWord embeddings  introdução, motivação e exemplos
Word embeddings introdução, motivação e exemplosFelipe
 
Cloud Certifications - Overview
Cloud Certifications - OverviewCloud Certifications - Overview
Cloud Certifications - OverviewFelipe
 
Elasticsearch for Data Analytics
Elasticsearch for Data AnalyticsElasticsearch for Data Analytics
Elasticsearch for Data AnalyticsFelipe
 
Cloudwatch: Monitoring your Services with Metrics and Alarms
Cloudwatch: Monitoring your Services with Metrics and AlarmsCloudwatch: Monitoring your Services with Metrics and Alarms
Cloudwatch: Monitoring your Services with Metrics and AlarmsFelipe
 
Cloudwatch: Monitoring your AWS services with Metrics and Alarms
Cloudwatch: Monitoring your AWS services with Metrics and AlarmsCloudwatch: Monitoring your AWS services with Metrics and Alarms
Cloudwatch: Monitoring your AWS services with Metrics and AlarmsFelipe
 
Online Machine Learning: introduction and examples
Online Machine Learning:  introduction and examplesOnline Machine Learning:  introduction and examples
Online Machine Learning: introduction and examplesFelipe
 
Aws cost optimization: lessons learned, strategies, tips and tools
Aws cost optimization: lessons learned, strategies, tips and toolsAws cost optimization: lessons learned, strategies, tips and tools
Aws cost optimization: lessons learned, strategies, tips and toolsFelipe
 
Exemplos de uso de apache spark usando aws elastic map reduce
Exemplos de uso de apache spark usando aws elastic map reduceExemplos de uso de apache spark usando aws elastic map reduce
Exemplos de uso de apache spark usando aws elastic map reduceFelipe
 
Pré processamento de grandes dados com Apache Spark
Pré processamento de grandes dados com Apache SparkPré processamento de grandes dados com Apache Spark
Pré processamento de grandes dados com Apache SparkFelipe
 
Hadoop MapReduce and Apache Spark on EMR: comparing performance for distribut...
Hadoop MapReduce and Apache Spark on EMR: comparing performance for distribut...Hadoop MapReduce and Apache Spark on EMR: comparing performance for distribut...
Hadoop MapReduce and Apache Spark on EMR: comparing performance for distribut...Felipe
 
Boas práticas no desenvolvimento de software
Boas práticas no desenvolvimento de softwareBoas práticas no desenvolvimento de software
Boas práticas no desenvolvimento de softwareFelipe
 
Rachinations
RachinationsRachinations
RachinationsFelipe
 
Ausgewählte preußische Tugenden
Ausgewählte preußische TugendenAusgewählte preußische Tugenden
Ausgewählte preußische TugendenFelipe
 
Conceitos e exemplos em versionamento de código
Conceitos e exemplos em versionamento de códigoConceitos e exemplos em versionamento de código
Conceitos e exemplos em versionamento de códigoFelipe
 
DevOps Series: Extending vagrant with Puppet for configuration management
DevOps Series: Extending vagrant with Puppet for configuration managementDevOps Series: Extending vagrant with Puppet for configuration management
DevOps Series: Extending vagrant with Puppet for configuration managementFelipe
 
DevOps Series: Defining and Sharing Testable Machine Configurations with vagrant
DevOps Series: Defining and Sharing Testable Machine Configurations with vagrantDevOps Series: Defining and Sharing Testable Machine Configurations with vagrant
DevOps Series: Defining and Sharing Testable Machine Configurations with vagrantFelipe
 
D3.js 30-minute intro
D3.js   30-minute introD3.js   30-minute intro
D3.js 30-minute introFelipe
 

More from Felipe (19)

Aula rotulação automática - Automatic tagging
Aula rotulação automática - Automatic taggingAula rotulação automática - Automatic tagging
Aula rotulação automática - Automatic tagging
 
First steps with Keras 2: A tutorial with Examples
First steps with Keras 2: A tutorial with ExamplesFirst steps with Keras 2: A tutorial with Examples
First steps with Keras 2: A tutorial with Examples
 
Word embeddings introdução, motivação e exemplos
Word embeddings  introdução, motivação e exemplosWord embeddings  introdução, motivação e exemplos
Word embeddings introdução, motivação e exemplos
 
Cloud Certifications - Overview
Cloud Certifications - OverviewCloud Certifications - Overview
Cloud Certifications - Overview
 
Elasticsearch for Data Analytics
Elasticsearch for Data AnalyticsElasticsearch for Data Analytics
Elasticsearch for Data Analytics
 
Cloudwatch: Monitoring your Services with Metrics and Alarms
Cloudwatch: Monitoring your Services with Metrics and AlarmsCloudwatch: Monitoring your Services with Metrics and Alarms
Cloudwatch: Monitoring your Services with Metrics and Alarms
 
Cloudwatch: Monitoring your AWS services with Metrics and Alarms
Cloudwatch: Monitoring your AWS services with Metrics and AlarmsCloudwatch: Monitoring your AWS services with Metrics and Alarms
Cloudwatch: Monitoring your AWS services with Metrics and Alarms
 
Online Machine Learning: introduction and examples
Online Machine Learning:  introduction and examplesOnline Machine Learning:  introduction and examples
Online Machine Learning: introduction and examples
 
Aws cost optimization: lessons learned, strategies, tips and tools
Aws cost optimization: lessons learned, strategies, tips and toolsAws cost optimization: lessons learned, strategies, tips and tools
Aws cost optimization: lessons learned, strategies, tips and tools
 
Exemplos de uso de apache spark usando aws elastic map reduce
Exemplos de uso de apache spark usando aws elastic map reduceExemplos de uso de apache spark usando aws elastic map reduce
Exemplos de uso de apache spark usando aws elastic map reduce
 
Pré processamento de grandes dados com Apache Spark
Pré processamento de grandes dados com Apache SparkPré processamento de grandes dados com Apache Spark
Pré processamento de grandes dados com Apache Spark
 
Hadoop MapReduce and Apache Spark on EMR: comparing performance for distribut...
Hadoop MapReduce and Apache Spark on EMR: comparing performance for distribut...Hadoop MapReduce and Apache Spark on EMR: comparing performance for distribut...
Hadoop MapReduce and Apache Spark on EMR: comparing performance for distribut...
 
Boas práticas no desenvolvimento de software
Boas práticas no desenvolvimento de softwareBoas práticas no desenvolvimento de software
Boas práticas no desenvolvimento de software
 
Rachinations
RachinationsRachinations
Rachinations
 
Ausgewählte preußische Tugenden
Ausgewählte preußische TugendenAusgewählte preußische Tugenden
Ausgewählte preußische Tugenden
 
Conceitos e exemplos em versionamento de código
Conceitos e exemplos em versionamento de códigoConceitos e exemplos em versionamento de código
Conceitos e exemplos em versionamento de código
 
DevOps Series: Extending vagrant with Puppet for configuration management
DevOps Series: Extending vagrant with Puppet for configuration managementDevOps Series: Extending vagrant with Puppet for configuration management
DevOps Series: Extending vagrant with Puppet for configuration management
 
DevOps Series: Defining and Sharing Testable Machine Configurations with vagrant
DevOps Series: Defining and Sharing Testable Machine Configurations with vagrantDevOps Series: Defining and Sharing Testable Machine Configurations with vagrant
DevOps Series: Defining and Sharing Testable Machine Configurations with vagrant
 
D3.js 30-minute intro
D3.js   30-minute introD3.js   30-minute intro
D3.js 30-minute intro
 

Recently uploaded

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Short intro to scala and the play framework

  • 1. Short intro to Scala and the Play! Framework 50 - 60 minutes Last updated: Sept 2014 falmeida1988@gmail.com Leveraging modern programming techniques to make safer, faster and more predictable applications
  • 2. Scala - First encounter def hello() = { println("Hello, world!") } var aMap = Map("Red" -> "Apple", "Yellow" -> "Peach") aMap += ("Purple" -> "Grape") def factorial(x: BigInt): BigInt = if (x == 0) 1 else x * factorial(x - 1) class MyClass(index: Int, name: String) functions collections recursive functions classes
  • 3. Scala - Background ● Created by Martin Odersky at EPFL in 2003 ● Aimed at overcoming Java’s weaknesses while allowing for easy migration for former Java developers ● One of the few object-functional languages (also: F#) ● One of the JVM-compliant languages (also: groovy, clojure, jruby, jython)
  • 4. Scala selling points ● Functional/Object Oriented hybrid - use one, the other, or both ● More elegant, less painful concurrency constructs ● Uncluttered, concise syntax ● Seamless interoperability and compatibility with Java ● Typing: expressive type system / static typing / type safety / type inference
  • 5. Quick syntax walkthrough ● no type declaration prior to use (due to type-inference) var msg = "Hello, world!" ● braces are only needed for multiline blocks def max(x: Int, y: Int) = if (x > y) x else y def max2(x: Int, y: Int) = { if (x > y) x else y } no braces yes braces
  • 6. Quick syntax walkthrough ● no semicolons at the end (unless you want multiple statements) println(line); println(line) println(line) println(line) equivalent code
  • 7. Quick syntax walkthrough ● type comes after variable name (only when required or for usability) def max(x: Int, y: Int): Int = if (x > y) x else y val m = new HashMap[Int, String] () required types for val m1: Map[Int, String] = new HashMap() arguments optional return type either is acceptable not necessary to annotate both sides val m2: HashMap[Int, String] = new HashMap[Int, String] ()
  • 8. Quick syntax walkthrough ● val for immutable variables, var for mutable variables val msg = "Hello, world!" msg = "Another message!" // ERROR: reassignment to val var msg2 = "Hello, world!" msg2 = "Another message!" // no error
  • 9. Quick syntax walkthrough ● statements also return a value (if, for, while, def) - which means they are also expressions var result1 = "" if(marks >= 50) result = "passed" else result = "failed" val result2 = if(marks >= 50) "passed" else "failed" using if as a statement if as an expression
  • 10. Quick syntax walkthrough ● return statements are allowed but generally not needed def multiply(a: Int,b:Int):Int = return a*b def sum(x:Int,y:Int) = x + y def greet() = println( "Hello, world!" ) explicitly using return When no return is provided, last value computed by the function is returned Functions that return no useful values have a result type of Unit
  • 11. Quick syntax walkthrough ● function literals or anonymous functions (x: Int) => x * 2 val double = (x: Int) => x * 2 ● example usage: as parameter to function map: List(1,2,3,4,5).map{ (x: Int) => x * 2 } //evaluates to List(2, 4, 6, 8, 10) a function that takes an Int and multiplies it by two function value being assigned to a variable function map takes another function as argument
  • 12. Scala, Java Comparison scala class MyClass(index: Int, name: String) class MyClass { private int index; private String name; public MyClass(int index, String name) { this.index = index; this.name = name; } } java
  • 13. Scala, Java Comparison scala val nameHasUpperCase = name.exists(_.isUpper) boolean nameHasUpperCase = false; for (int i = 0; i < name.length(); ++i) { if (Character.isUpperCase(name.charAt(i))) { nameHasUpperCase = true; break; } } java
  • 14. Scala, Java Interoperability ● You can use Java code in Scala as-is (i.e. no changes needed). ● Scala classes can subclass Java classes, you can instantiate Java classes in Scala, you can access methods, fields (even if they are static), etc. ● You can also use Scala code in Java projects, as long as you don’t use many advanced Scala concepts that are not possible in Java. ● Similar code generated by Scala and Java usually generates the exact same bytecode, as can be verified using tools like javap
  • 15. Environment ● Console ● sbt - dependency and package management ● JVM integration ● Typesafe products (Akka, Play, Activator, Spray, Slick, etc) ● All of your favourite Java libraries ● Testing suites (Unit, Integration, Acceptance, Property-based, etc) ● Small but high-level community
  • 16. Weaknesses ● It’s a large language. Users are advised not to try to use many different concepts at the same time, especially when starting out. ● Scala has a somewhat steep learning curve and its complex type system is powerful but hard to grasp at times. ● Implicit conversions are useful but easily misused and may make code harder to understand. ● Complex function signatures may put some off.
  • 17. Play Framework ● MVC Web Framework; supports Java and Scala ● Created in 2007 ● Used at Linkedin, Coursera, The Guardian, etc. ● Uses sbt for dependency management ● As of September 2014, it has had 5000 commits by over 350 contributors. ● The Simplest Possible Play App
  • 18. Play Features ● Play has all default features one can expect from a modern framework: ○ MVC-based separation of concerns ○ Support for ORMs (Java) or FRMs (Scala) ○ Rich models with support for Forms, Validation, etc. ○ Database Migration (called evolutions) ○ Template engine (Scala-based) ○ Extensive routing ○ Support for REST-only Apps ○ Lots of community-provided plugins ○ Supported by Typesafe
  • 19. Play - Application Layout app/ -- Application sources | assets/ -- LESS, Coffeescript sources | controllers/ -- Controllers | models/ -- Domain models | views/ -- Templates build.sbt -- Build configuration conf/ -- Configuration files | application.conf -- Main configuration file | routes -- Routes definition public/ -- Public folder (CSS, JS, etc) project/ -- sbt configuration files logs/ -- Logs target/ -- Generated files - ignore test/ -- Sources for tests
  • 20. Play Framework - Examples ● Displaying a view from a controller action package controllers import play.api._ import play.api.mvc._ object Application extends Controller { def index = Action { Ok(views.html.index("Your new application is ready.")) } } import libraries create a controller define actions as methods
  • 21. Play Framework - Examples ● Displaying a view with some data package controllers import models._ import play.api._ import play.api.mvc._ import play.api.Play.current object Application extends Controller { this method returns a List[Computer] def index = Action { implicit request => val computers = Computer .list Ok(views.html.web.index( "Hello! I'm the WEB!" , computers)) } } the Computer model was defined in package models (not shown here) instantiate a view file and feed it a string and a list of computers
  • 22. Activator ● Web-based IDE and project viewer, built by Typesafe ● A large number of sample applications (templates) to study and learn from
  • 23. Resources ● Scala Programming Language (Wikipedia Article) ● Scala official site ● Typesafe ● Programming in Scala Book on Amazon ● A preset Virtual Machine for Scala/Play Development ● Functional Programming Principles in Scala on Coursera ● Principles of Reactive Programming on Coursera ● Play Framework Official Website ● ScalaJavaInterop Project ● Play Framework (Wikipedia Article) ● Using Scala on Heroku ● Typesafe Activator ● All Available Activator Templates