© Toby Weston 2018

Toby Weston, Scala for Java Developers, https://doi.org/10.1007/978-1-4842-3108-1_7

7. Summary

Toby Weston

(1)London, UK

In this high-level tour, we talked about how Scala is both an OO language and a functional language. I mentioned that Scala in fact only has objects; there are no primitives, everything is an object.

We talked about Scala’s background, how it grew from an academic language to a commercially backed mainstream language, and how it runs on the JVM. This, in theory, lowers the barrier of adoption by making it easy to deploy to existing servers.

Running on the JVM also means there are plenty of libraries available to Scala, as Java interoperability is baked in. Despite some of the tools being behind and compilation time still being slow, Scala has been widely adopted and we see numerous big companies using it today.

We had a look at installing and running Scala. You saw the three ways Scala programs are typically run, and along the way were introduced to the Scala REPL.

We then moved on to a syntax tour and looked at some interesting language features.

In the syntax tour, we saw how to define variables and values, functions and methods, and saw how Scala reduces the boilerplate noise by inferring types and recognizing terminating conditions like return and semicolons automatically.

We saw how infix notation means you can avoid the classical dot notation and, importantly, we saw that method names can contain symbols. That’s how we’re able to use mathematical symbols naturally in code; they’re actually methods, so we can override them and, using the infix notation, use them without the noisy dots and brackets.

We also worked with some collection types and saw a couple of basic ways to enumerate them: the foreach and for loop syntax. We saw how easy it is to work with Java objects; value types like Int and Boolean are basically the same in Scala and Java. We had a good look at how Scala represents types in its class hierarchy, and learnt how to look things up in the ScalaDoc.

In terms of language features, we looked at some interesting aspects of the language when working with source files and packages, methods and method arguments, as well as some features geared up for functional programming.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.158.32