Download - Scala Day by Day
![Page 1: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/1.jpg)
SCALA DAY BY DAYWhat means to work with Scala. A story from a previous Java Developerby Ionut Andonescu23 April 2016, Iasi
![Page 2: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/2.jpg)
Sponsors
![Page 3: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/3.jpg)
Sponsors
![Page 4: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/4.jpg)
SUMMARY Intro (Java Evolution) Scala Refresh ( Java - to - Scala) Scala Patterns Interesting/Weird Things Questions
![Page 5: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/5.jpg)
INTRO Java Evolution
![Page 6: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/6.jpg)
JAVA Imperative language Statically typed Runs on JVM
JDK 1.0 (21 January 1996) …… JDK SE 8 (18 March, 2014)
![Page 7: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/7.jpg)
JAVA EVOLUTIONJDK SE 8 JDK SE 9
code reorganization lightweight JSON API JEP 286
addition of lambda expressions shift to functional programming
![Page 8: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/8.jpg)
JEP 286: LOCAL VARIABLE TYPE INFERENCE Goal “We seek to improve the developer experience by reducing the ceremony associated with writing Java code, while maintaining Java's commitment to static type safety, by allowing developers to elide the often-unnecessary manifest declaration of local variable types.”
![Page 9: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/9.jpg)
74%
12%
10%3%1%
What do you think of the proposed Local Variable Type In-ference feature overall? *Takipi
I think it'a great idea!
Meh, it'a OK.
I think it'a bad idea!
Not sure
Other
![Page 10: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/10.jpg)
JEP 286: SYNTAX CHOICES var x = expr only (like C#) var, plus val for immutable locals (like Scala, Kotlin) var, plus let for immutable locals (like Swift) auto x = expr (like C++) const x = expr (already a reserved word) final x = expr (already a reserved word) let x = expr def x = expr (like Groovy) x := expr (like Go)
![Page 11: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/11.jpg)
23.7
48.1
14
34
7.2
Possible syntax options*Takipi
var only
var and val
var and let
let only
auto only
Other
![Page 12: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/12.jpg)
SCALA Object-functional language Statically typed Runs on JVM First version - 20 January 2004 latest & stable version - 8 March 2016 (2.11.8)
Around 500.000 developers are using Scala * http://www.scala-lang.org/blog/2016/03/14/announcing-the-scala-center.html
![Page 13: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/13.jpg)
SCALA REFRESH Java - to - Scala
![Page 14: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/14.jpg)
DIFFERENCESObvious differences
semicolons variable declaration : val/var method declarations inferring type information
lazy val imported file types methods with empty argument lists options either
Syntactic Sugar and more features
partial functions ranges: 1 to n reserved words if statement for comprehensions call by name / call by value try catch organized code in files and namespaces
![Page 15: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/15.jpg)
JAVA CODE TO
![Page 16: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/16.jpg)
SCALA METHODS
![Page 17: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/17.jpg)
SCALA FUNCTIONAL
![Page 18: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/18.jpg)
CLASS/INTERFACE CREATION
![Page 19: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/19.jpg)
CASE CLASSES
![Page 20: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/20.jpg)
PATTERN MATCHING
![Page 21: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/21.jpg)
FUNCTIONS With default value
![Page 22: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/22.jpg)
FUNCTIONS With named parameters
![Page 23: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/23.jpg)
FUNCTIONS With nested functions
![Page 24: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/24.jpg)
FUNCTIONS Passed as argumentReturned as value
![Page 25: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/25.jpg)
SCALA PATTERNS Interesting/Weird Things
![Page 26: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/26.jpg)
TUPLES
![Page 27: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/27.jpg)
IMUTABILITY VS MUTABILITY Problem:“Separate students from a given List into separate groups: those from Romania and those outside of Romania”
![Page 28: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/28.jpg)
IMUTABILITY VS MUTABILITY
![Page 29: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/29.jpg)
IMUTABILITY VS MUTABILITY
![Page 30: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/30.jpg)
IMUTABILITY VS MUTABILITY
![Page 31: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/31.jpg)
IMUTABILITY VS MUTABILITY
![Page 32: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/32.jpg)
MONADS
![Page 33: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/33.jpg)
Pug monad
![Page 34: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/34.jpg)
OPTION
![Page 35: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/35.jpg)
EITHER
![Page 36: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/36.jpg)
FUTURE
![Page 37: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/37.jpg)
TRY
![Page 38: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/38.jpg)
MAP & FLATMAPscala.util.Try
def map[U](f: T => U): Try[U]Maps the given function to the value from this Success or returns this if this is a Failure. def flatMap[U](f: T => Try[U]): Try[U]Returns the given function applied to the value from this Success or returns this if this is a Failure. ……
scala.Optiondef map[B](f: A => B): Option[B]Returns a scala.Some containing the result of applying f to this scala.Option's value if this scala.Option is nonempty. Otherwise returndef flatMap[B](f: A => Option[B]): Option[B]Returns the result of applying f to this scala.Option's value if this scala.Option is nonempty. Returns None if this scala.Option is empty. ……
![Page 39: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/39.jpg)
![Page 40: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/40.jpg)
WHAT MEANS TO WORK WITH SCALA?
![Page 41: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/41.jpg)
“Unlike with many traditional functional languages, Scala allows a gradual, easy migration to a more functional style.
You can start to use it as a “Java without semicolons”. Over time, you can progress to gradually eliminate mutable state in your applications, phasing in safe functional composition patterns instead. As Scala programmers we believe that this progression is often a good idea.
At the same time, Scala is not opinionated; you can use it with any style you prefer.”
http://www.scala-lang.org/what-is-scala.html
![Page 42: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/42.jpg)
QUESTIONS
![Page 43: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/43.jpg)
THE END.
![Page 44: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/44.jpg)
![Page 45: Scala Day by Day](https://reader036.vdocuments.us/reader036/viewer/2022081515/58e8d2a51a28abb3398b5933/html5/thumbnails/45.jpg)
SCALA DAY BY DAYIonut Andonescu
23 April 2016, Iasi
Please fill the online evaluation form after event