SlideShare a Scribd company logo
LiftwebŁukasz Kuczera
Scala the next Java ?Łukasz Kuczera
ScalaStatically typed with types inferentionObject-functionalCompiles to Java bytecodeAnd CLI .Net
HistoriaPizzaGJEPFL
Pizza
Scala and Lift presentation
Scala and Lift presentation
ScalaType InferenceUniform Access PrincipleClosuresHigher Order FunctionsPattern MatchingActorsGenericsNative XML supportAbstract control structuresImplicit conversions and parametersAdvanced for expressionsAnnotationsCombinator parsingTraitsDuck typingNull „safety”
„If I where to choose language other thanJava it would be Scala”
„I can honestly say if someone had shown me the Programming in Scala book by Martin Odersky, Lex Spoon & Bill Venners back in 2003 I'd probably have never created Groovy”
„Scala, it must be stated, is the current heir apparent to the Java throne. No other language on the JVM seems as capable of being a "replacement for Java" as Scala, and the momentum behind Scala is now unquestionable”
Scala and Lift presentation
Scala - Basicsclass Test {// variable definitionvar n = 5// value definitionval i = 10// function definitiondef printit(x: Any) = println(x)def sum(i: Int, n: Int) = i+n}object Test extends Test {def main(args: Array[String]): Unit = {  	printit(sum(i,n))  }}
Class Parameters - Javapublicclass Person {	private String name;	privateintage;publicPerson(String name, int age) {		this.name = name;		this.age = age;	}	public String getName() {		returnname;	}	publicvoid setName(String name) {		this.name = name;	}	publicint getAge() {		returnage;	}	publicvoid setAge(int age) {		this.age = age;	}}
Class Parameters - ScalaclassPerson(var name: String, var age: Int)
Working with arraysJavapublicclass Partition {Person[] all;Person[] adults;Person[] minors;	 { ArrayList<Person> minorsList = new ArrayList<Person>();ArrayList<Person> adultsList = new ArrayList<Person>();for(int i=0; i<all.length; i++ ) {	(all[i].age<18 ? adultsList: minorsList).add(all[i]);	 	}		minors = (Person[]) minorsList.toArray();		adults = (Person[]) adultsList.toArray();}}
Working with arraysScalaval all: Array[Person]val (minors, adults) = all.partition(_.age<18)
Null’s – JavaMap<String, String> capitals = newHashMap<String, String>();capitals.put("Poland", "Warsaw");System.out.println(capitals.get("Polska").trim());Exception in thread "main" java.lang.NullPointerException
Null’s - Scala  val capitals = Map("Poland" -> "Warsaw");val capitalOption: Option[String] = capitals.get("Polska")  capitalOption match {case Some(value) => println(value)case None => println("Not found")case _ =>  }if(capitalOption.isDefined) println(capitalOption.get)  println(capitalOption getOrElse "Not found")
XMLval xml = <a href="http://example.com">		    <customTagb="foo">		       <deepTagb="bar" />Custom content  		    </customTag>	       </a>println(xml \ "customTag")println(xml \\ "deepTag")println(xml \\ "@b")println(xml \ "customTag" \ "deepTag" \ "@b")Outputs:<customTag b="foo"><deepTag b="bar"></deepTag>Custom content</customTag><deepTag b="bar"></deepTag>foobarbar
XMLval xml =<divclass="rsswidget"><ul><liclass="rsswidgettitle"><ahref="http://www.quotationspage.com/qotd.html">Quotes of the Day</a></li><liclass="rsswidgetitem"><ahref="http://www.quotationspage.com/quotes/C._P._Snow">C. P. Snow</a></li><liclass="rsswidgetitem"><ahref="http://www.quotationspage.com/quotes/unknown">unknown</a></li><liclass="rsswidgetitem"><ahref="http://www.quotationspage.com/quotes/Frederick">Frederick</a></li></ul> ...</div>(xml \\ "@href").slice(1,4).foreach(url =>     println("URL:"+url)val con = new URL(url.toString).openConnectionval reader = newBufferedReader(newInputStreamReader(con.getInputStream, "ISO-8859-1"))var line = "";while(line != null) {      line = reader.readLineif(line != null) println(line)    }    con.getInputStream.close)
ActorsEasier concurrencyMessage passing instead of locksAsynchronusImplemented using Java threadsScalaActors, Akka, Lift - CometActor
Actorsclass ActorUser {def send(msg: Any) = ScalaActor ! msg}object ScalaActor extends Actor {	/* The $actor's mailbox. */// private[actors] val mailbox = new MQueue[Msg]("Reactor")	def act() {		receive {		    case"ping!" => println("pinged!");case ("ping!", actor: Actor) => actor ! "pong!"		    case msg => println("unhandled message type:"+msg)		}	}}
GuiceMinimize mutabilityAvoid static state@NullableJSR 308 - @NonNull
LiftChat Application Using Comet
Build ToolsSBT MavenGradleJRebel
IDE	IntelliJ IDEANetbeansEclipse
HTTP GET
Ajax
Comet
Scala and Lift presentation
Linkshttp://days2010.scala-lang.org/node/136 - lots of Scala videoshttp://twit.tv/floss125 - Lifts Creator interviewhttp://www.youtube.com/watch?v=01rXrI6xelE – Scala creator speak at Google tech talks
Thank YouQ&A

More Related Content

PPTX
Scala == Effective Java
PPTX
Scala 3camp 2011
PDF
Es.next
PDF
Scala vs Java 8 in a Java 8 World
PPTX
AST - the only true tool for building JavaScript
PPTX
Don't Be Afraid of Abstract Syntax Trees
PDF
JavaScript on the GPU
PDF
GR8Conf 2011: GPars
Scala == Effective Java
Scala 3camp 2011
Es.next
Scala vs Java 8 in a Java 8 World
AST - the only true tool for building JavaScript
Don't Be Afraid of Abstract Syntax Trees
JavaScript on the GPU
GR8Conf 2011: GPars

What's hot (19)

PDF
JDK8 : parallel programming made (too ?) easy
PPSX
Spring has got me under it’s SpEL
KEY
Mirah Talk for Boulder Ruby Group
PDF
"How was it to switch from beautiful Perl to horrible JavaScript", Viktor Tur...
PPTX
Mastering Java Bytecode With ASM - 33rd degree, 2012
PPT
Scala introduction
PPTX
Coffee script
PPTX
All about scala
PPTX
Introduction to kotlin + spring boot demo
PDF
A Scala Corrections Library
PPT
Mastering Java ByteCode
PPT
Building a java tracer
PPTX
Beyond java8
PDF
Kotlin advanced - language reference for android developers
PDF
A Re-Introduction to JavaScript
KEY
Google Guava
PDF
Comparing JVM languages
PPTX
Scala on Android
JDK8 : parallel programming made (too ?) easy
Spring has got me under it’s SpEL
Mirah Talk for Boulder Ruby Group
"How was it to switch from beautiful Perl to horrible JavaScript", Viktor Tur...
Mastering Java Bytecode With ASM - 33rd degree, 2012
Scala introduction
Coffee script
All about scala
Introduction to kotlin + spring boot demo
A Scala Corrections Library
Mastering Java ByteCode
Building a java tracer
Beyond java8
Kotlin advanced - language reference for android developers
A Re-Introduction to JavaScript
Google Guava
Comparing JVM languages
Scala on Android
Ad

Viewers also liked (17)

PDF
The Common Debian Build System (CDBS)
KEY
Around "Hello World" in 30 Days
KEY
Java to scala
ODP
A Tour Of Scala
PDF
Scala Sjug 09
PPTX
Liftweb
PDF
Testing practicies not only in scala
PPTX
Scala-Ls1
ODP
MySQL Monitoring Shoot Out
ZIP
Why Scala for Web 2.0?
PPTX
MySQL DBA
KEY
PPT
Scala Talk at FOSDEM 2009
PPTX
A Brief Intro to Scala
PDF
Scala Days NYC 2016
PPTX
Real time Analytics with Apache Kafka and Apache Spark
PDF
Scala, Akka, and Play: An Introduction on Heroku
The Common Debian Build System (CDBS)
Around "Hello World" in 30 Days
Java to scala
A Tour Of Scala
Scala Sjug 09
Liftweb
Testing practicies not only in scala
Scala-Ls1
MySQL Monitoring Shoot Out
Why Scala for Web 2.0?
MySQL DBA
Scala Talk at FOSDEM 2009
A Brief Intro to Scala
Scala Days NYC 2016
Real time Analytics with Apache Kafka and Apache Spark
Scala, Akka, and Play: An Introduction on Heroku
Ad

Similar to Scala and Lift presentation (20)

PPT
ODP
Why Scala?
PPTX
Qcon2011 functions rockpresentation_scala
PDF
ODP
Naïveté vs. Experience
PDF
Scala for the doubters. Максим Клыга
PDF
Scala in Places API
PPTX
Oop2010 Scala Presentation Stal
PDF
Live coding scala 'the java of the future'
PDF
Stepping Up : A Brief Intro to Scala
PPTX
Jugar Introduccion a Scala
PPT
Scala presentationjune112011
PDF
The things we don't see – stories of Software, Scala and Akka
PPT
Scala in a nutshell by venkat
PDF
Scala - just good for Java shops?
PPT
On Scala Slides - OSDC 2009
ODP
AST Transformations
PPT
Rewriting Java In Scala
PDF
Functional Java 8 - Introduction
PDF
Gatling @ Scala.Io 2013
Why Scala?
Qcon2011 functions rockpresentation_scala
Naïveté vs. Experience
Scala for the doubters. Максим Клыга
Scala in Places API
Oop2010 Scala Presentation Stal
Live coding scala 'the java of the future'
Stepping Up : A Brief Intro to Scala
Jugar Introduccion a Scala
Scala presentationjune112011
The things we don't see – stories of Software, Scala and Akka
Scala in a nutshell by venkat
Scala - just good for Java shops?
On Scala Slides - OSDC 2009
AST Transformations
Rewriting Java In Scala
Functional Java 8 - Introduction
Gatling @ Scala.Io 2013

More from Scalac (13)

PDF
Applicative functors by Łukasz Marchewka
PDF
AWS Api Gateway by Łukasz Marchewka Scalacc
PDF
Do ECTL not ETL: the art and science of data cleansing in data pipelines by P...
PDF
React Hooks by Oleksandr Oleksiv Scalac
PDF
Introduction to Scala by Piotr Wiśniowski Scalac
PDF
ZIO actors by Mateusz Sokół Scalac
PDF
Why functional programming and category theory strongly matters - Piotr Parad...
PDF
Big picture of category theory in scala with deep dive into contravariant and...
PDF
How to write automated tests and don’t lose your mind by Dorian Sarnowski Scalac
PDF
Do you have that Spark in your ECTL? by Piotr Sych Scalac
PDF
Can we automate the process of backlog prioritizing? by Adam Gadomski Scalac
PDF
How to create the right sales funnel for your business? by Maciej Greń
PDF
ActorRef[Typed] by Andrzej Kopeć
Applicative functors by Łukasz Marchewka
AWS Api Gateway by Łukasz Marchewka Scalacc
Do ECTL not ETL: the art and science of data cleansing in data pipelines by P...
React Hooks by Oleksandr Oleksiv Scalac
Introduction to Scala by Piotr Wiśniowski Scalac
ZIO actors by Mateusz Sokół Scalac
Why functional programming and category theory strongly matters - Piotr Parad...
Big picture of category theory in scala with deep dive into contravariant and...
How to write automated tests and don’t lose your mind by Dorian Sarnowski Scalac
Do you have that Spark in your ECTL? by Piotr Sych Scalac
Can we automate the process of backlog prioritizing? by Adam Gadomski Scalac
How to create the right sales funnel for your business? by Maciej Greń
ActorRef[Typed] by Andrzej Kopeć

Scala and Lift presentation

  • 2. Scala the next Java ?Łukasz Kuczera
  • 3. ScalaStatically typed with types inferentionObject-functionalCompiles to Java bytecodeAnd CLI .Net
  • 8. ScalaType InferenceUniform Access PrincipleClosuresHigher Order FunctionsPattern MatchingActorsGenericsNative XML supportAbstract control structuresImplicit conversions and parametersAdvanced for expressionsAnnotationsCombinator parsingTraitsDuck typingNull „safety”
  • 9. „If I where to choose language other thanJava it would be Scala”
  • 10. „I can honestly say if someone had shown me the Programming in Scala book by Martin Odersky, Lex Spoon & Bill Venners back in 2003 I'd probably have never created Groovy”
  • 11. „Scala, it must be stated, is the current heir apparent to the Java throne. No other language on the JVM seems as capable of being a "replacement for Java" as Scala, and the momentum behind Scala is now unquestionable”
  • 13. Scala - Basicsclass Test {// variable definitionvar n = 5// value definitionval i = 10// function definitiondef printit(x: Any) = println(x)def sum(i: Int, n: Int) = i+n}object Test extends Test {def main(args: Array[String]): Unit = { printit(sum(i,n)) }}
  • 14. Class Parameters - Javapublicclass Person { private String name; privateintage;publicPerson(String name, int age) { this.name = name; this.age = age; } public String getName() { returnname; } publicvoid setName(String name) { this.name = name; } publicint getAge() { returnage; } publicvoid setAge(int age) { this.age = age; }}
  • 15. Class Parameters - ScalaclassPerson(var name: String, var age: Int)
  • 16. Working with arraysJavapublicclass Partition {Person[] all;Person[] adults;Person[] minors; { ArrayList<Person> minorsList = new ArrayList<Person>();ArrayList<Person> adultsList = new ArrayList<Person>();for(int i=0; i<all.length; i++ ) { (all[i].age<18 ? adultsList: minorsList).add(all[i]); } minors = (Person[]) minorsList.toArray(); adults = (Person[]) adultsList.toArray();}}
  • 17. Working with arraysScalaval all: Array[Person]val (minors, adults) = all.partition(_.age<18)
  • 18. Null’s – JavaMap<String, String> capitals = newHashMap<String, String>();capitals.put("Poland", "Warsaw");System.out.println(capitals.get("Polska").trim());Exception in thread "main" java.lang.NullPointerException
  • 19. Null’s - Scala val capitals = Map("Poland" -> "Warsaw");val capitalOption: Option[String] = capitals.get("Polska") capitalOption match {case Some(value) => println(value)case None => println("Not found")case _ => }if(capitalOption.isDefined) println(capitalOption.get) println(capitalOption getOrElse "Not found")
  • 20. XMLval xml = <a href="http://example.com"> <customTagb="foo"> <deepTagb="bar" />Custom content </customTag> </a>println(xml \ "customTag")println(xml \\ "deepTag")println(xml \\ "@b")println(xml \ "customTag" \ "deepTag" \ "@b")Outputs:<customTag b="foo"><deepTag b="bar"></deepTag>Custom content</customTag><deepTag b="bar"></deepTag>foobarbar
  • 21. XMLval xml =<divclass="rsswidget"><ul><liclass="rsswidgettitle"><ahref="http://www.quotationspage.com/qotd.html">Quotes of the Day</a></li><liclass="rsswidgetitem"><ahref="http://www.quotationspage.com/quotes/C._P._Snow">C. P. Snow</a></li><liclass="rsswidgetitem"><ahref="http://www.quotationspage.com/quotes/unknown">unknown</a></li><liclass="rsswidgetitem"><ahref="http://www.quotationspage.com/quotes/Frederick">Frederick</a></li></ul> ...</div>(xml \\ "@href").slice(1,4).foreach(url => println("URL:"+url)val con = new URL(url.toString).openConnectionval reader = newBufferedReader(newInputStreamReader(con.getInputStream, "ISO-8859-1"))var line = "";while(line != null) { line = reader.readLineif(line != null) println(line) } con.getInputStream.close)
  • 22. ActorsEasier concurrencyMessage passing instead of locksAsynchronusImplemented using Java threadsScalaActors, Akka, Lift - CometActor
  • 23. Actorsclass ActorUser {def send(msg: Any) = ScalaActor ! msg}object ScalaActor extends Actor { /* The $actor's mailbox. */// private[actors] val mailbox = new MQueue[Msg]("Reactor") def act() { receive { case"ping!" => println("pinged!");case ("ping!", actor: Actor) => actor ! "pong!" case msg => println("unhandled message type:"+msg) } }}
  • 24. GuiceMinimize mutabilityAvoid static state@NullableJSR 308 - @NonNull
  • 29. Ajax
  • 30. Comet
  • 32. Linkshttp://days2010.scala-lang.org/node/136 - lots of Scala videoshttp://twit.tv/floss125 - Lifts Creator interviewhttp://www.youtube.com/watch?v=01rXrI6xelE – Scala creator speak at Google tech talks