Professional Scala: Combine object-oriented and functional programming to build high-performance applications by Mads Hartmann & Ruslan Shevchenko
Author:Mads Hartmann & Ruslan Shevchenko [Hartmann, Mads]
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2018-07-30T23:00:00+00:00
Chapter 5. Scala Type System
In the previous chapter, we covered how to work with lists, which made us familiar with some design principles of the whole collections library. We also covered how to generalize to sequences and covered some more relevant data structures. Finally, we also covered how collections relate to monads and how we can use that knowledge to use some powerful abstractions in our code.
In this chapter, we will cover the type system and polymorphism. We will also cover the different types of variance, which provides a way to constrain parameterized types. Finally, we will cover some advanced types such as abstract type members, option, and so on.
Scala is statically typed. This means that the type of variables are known at compile time. The main advantage of statically typed languages is that a lot of checks can be done by the compiler, thus increasing the number of trivial bugs that are caught at an early stage. Statically typed languages are also friendlier to refactoring, as the programmer can feel safer about their changes as long as the code compiles.
However, Scala is more than statically typed. In this chapter, we will see how Scala's expressive type system enables and enforces statically typed sound abstractions. The ability to infer types reduces the programmers' workload of annotating the program with redundant type information. This chapter will build upon the fundamentals required for the next chapter, where will be talking about type classes and a type of polymorphism they enable: ad hoc polymorphism.
By the end of this chapter, you will be able to:
Identify the Scala type hierarchy
Use the features the Scala type system provides
Identify abstractions that the Scala type system enables
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(26286)
Hello! Python by Anthony Briggs(25212)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(24438)
Kotlin in Action by Dmitry Jemerov(23531)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(22873)
Dependency Injection in .NET by Mark Seemann(22660)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(21423)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(20266)
Grails in Action by Glen Smith Peter Ledbrook(19336)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(17050)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(16362)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(14074)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(12248)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(11527)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10638)
Hit Refresh by Satya Nadella(9216)
The Kubernetes Operator Framework Book by Michael Dame(8575)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8428)
Robo-Advisor with Python by Aki Ranin(8372)