Scala - the good, the bad and the very ugly
-
Upload
bozhidar-bozhanov -
Category
Software
-
view
23.557 -
download
4
description
Transcript of Scala - the good, the bad and the very ugly
![Page 1: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/1.jpg)
ScalaThe good, the bad and the very ugly
![Page 2: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/2.jpg)
Vanity slide● Senior software engineer @ TomTom● Using scala for more than a year● Stackoverflow (couldn’t miss that)● http://techblog.bozho.net● @bozhobg● (Yes, I’m making presentations about programming
languages in PowerPoint with screenshots of code)
![Page 3: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/3.jpg)
The good● functional and object-oriented● JVM-based● val, type inference
● expressive● DSL-friendly
![Page 4: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/4.jpg)
The good● case classes - immutable, value classes
● embrace immutability - immutable collections by default
● automatic conversion from and to Java collections
![Page 5: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/5.jpg)
The good● no null - Option[Foo]
● Reusing java instruments (e.g. guava, slf4j, even spring and hibernate)
● goodies – e.g. instantiating collections without unnecessary brackets or type declarations
![Page 6: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/6.jpg)
Partially applied functions
![Page 7: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/7.jpg)
TraitsMultiple inheritance done right
![Page 8: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/8.jpg)
The bad● tools
o The compiler is too slowo IDE-s (Eclipse and IntelliJ) breako sbt (build tool) is buggy
● ecosystemo Many java libraries cannot/should not be usedo Most frameworks and libraries and in early phaseo binary incompatible => one artifact for each scala version
● lambdas are slower than in Java 8
![Page 9: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/9.jpg)
![Page 10: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/10.jpg)
The bad● Heavy in terms of concepts and keywords:
implicits, for comprehensions, lazy, case class, case object, currying, partially applied functions vs partial functions =>
● Steep learning curve● Syntactic diabetes
![Page 11: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/11.jpg)
Syntactic diabetes
![Page 12: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/12.jpg)
Implicitsimplicit val, implicit def, implicitly, (implicit argument)
If anywhere in the execution context there is an implicit definition, any function can read it with(implicit foo: String) => the horror!
Saves initialization (e.g. of some tool)
![Page 13: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/13.jpg)
The bad
One thing can be written in many ways and there is no “right” way.
![Page 14: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/14.jpg)
![Page 15: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/15.jpg)
![Page 16: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/16.jpg)
The bad
“Concise” doesn’t necessarily mean fast to write or easy to read
![Page 17: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/17.jpg)
![Page 18: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/18.jpg)
The bad
Productivity – do we gain or lose?
![Page 19: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/19.jpg)
The very uglycryptic
![Page 20: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/20.jpg)
![Page 21: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/21.jpg)
![Page 22: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/22.jpg)
![Page 23: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/23.jpg)
![Page 24: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/24.jpg)
![Page 25: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/25.jpg)
scala> List(1,2,3).toSet()
![Page 26: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/26.jpg)
res0: Boolean = false
List(1,2,3).toSetres0: s.c.immutable.Set[Int] = Set(1, 2, 3)
![Page 27: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/27.jpg)
Philosophy● Should the language stop us from shooting
ourselves in the foot?● Should this be at the expense of its
expressiveness?● Where is the balance?● Who is scala suitable for?
![Page 28: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/28.jpg)
Optimistic● IDEs are getting better● Frameworks are getting mature● Twitter and the language author are
releasing guidelines and best practices (scala – the good parts)
● invokeDynamic (SI-8359)
![Page 29: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/29.jpg)
Conclusion● I wouldn’t recommend scala for a general-purpose new
project● In an actual project most of the defficiencies are
relatively easy to overcome● I would recommend scala for a small, side module● It’s interesting to work with, due to the functional aspect● Don’t give the users of your language, API or product all
of the possible options – they will misuse them.
![Page 30: Scala - the good, the bad and the very ugly](https://reader036.fdocuments.us/reader036/viewer/2022081513/553a40664a7959b26f8b4aa9/html5/thumbnails/30.jpg)
Questions?
def ? = ???