{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "

Next

\n", "

Tour of Scala

\n", "
\n", "\n", "# Introduction\n", "\n", "## Welcome to the tour\n", "This tour contains bite-sized introductions to the most frequently used features\n", "of Scala. It is intended for newcomers to the language.\n", "\n", "This is just a brief tour, not a full language tutorial. If\n", "you want that, consider obtaining [a book](https://docs.scala-lang.org/books.html) or consulting\n", "[other resources](https://docs.scala-lang.org/learn.html).\n", "\n", "## What is Scala?\n", "Scala is a modern multi-paradigm programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages.\n", "\n", "## Scala is object-oriented ##\n", "Scala is a pure object-oriented language in the sense that [every value is an object](unified-types.ipynb). Types and behavior of objects are described by [classes](classes.ipynb) and [traits](traits.ipynb). Classes are extended by subclassing and a flexible [mixin-based composition](mixin-class-composition.ipynb) mechanism as a clean replacement for multiple inheritance.\n", "\n", "## Scala is functional ##\n", "Scala is also a functional language in the sense that [every function is a value](unified-types.ipynb). Scala provides a [lightweight syntax](basics.ipynb#functions) for defining anonymous functions, it supports [higher-order functions](higher-order-functions.ipynb), it allows functions to be [nested](nested-functions.ipynb), and supports [currying](multiple-parameter-lists.ipynb). Scala's [case classes](case-classes.ipynb) and its built-in support for [pattern matching](pattern-matching.ipynb) model algebraic types used in many functional programming languages. [Singleton objects](singleton-objects.ipynb) provide a convenient way to group functions that aren't members of a class.\n", "\n", "Furthermore, Scala's notion of pattern matching naturally extends to the [processing of XML data](https://github.com/scala/scala-xml/wiki/XML-Processing) with the help of [right-ignoring sequence patterns](regular-expression-patterns.ipynb), by way of general extension via [extractor objects](extractor-objects.ipynb). In this context, [for comprehensions](for-comprehensions.ipynb) are useful for formulating queries. These features make Scala ideal for developing applications like web services.\n", "\n", "## Scala is statically typed ##\n", "Scala is equipped with an expressive type system that enforces statically that abstractions are used in a safe and coherent manner. In particular, the type system supports:\n", "\n", "* [generic classes](generic-classes.ipynb)\n", "* [variance annotations](variances.ipynb)\n", "* [upper](upper-type-bounds.ipynb) and [lower](lower-type-bounds.ipynb) type bounds,\n", "* [inner classes](inner-classes.ipynb) and [abstract types](abstract-types.ipynb) as object members\n", "* [compound types](compound-types.ipynb)\n", "* [explicitly typed self references](self-types.ipynb)\n", "* [implicit parameters](implicit-parameters.ipynb) and [conversions](implicit-conversions.ipynb)\n", "* [polymorphic methods](polymorphic-methods.ipynb)\n", "\n", "[Type inference](type-inference.ipynb) means the user is not required to annotate code with redundant type information. In combination, these features provide a powerful basis for the safe reuse of programming abstractions and for the type-safe extension of software.\n", "\n", "## Scala is extensible ##\n", "\n", "In practice, the development of domain-specific applications often requires domain-specific language extensions. Scala provides a unique combination of language mechanisms that make it easy to smoothly add new language constructs in the form of libraries.\n", "\n", "In many cases, this can be done without using meta-programming facilities such as macros. For example,\n", "\n", "* [Implicit classes](http://docs.scala-lang.org/overviews/core/implicit-classes.ipynb) allow adding extension methods to existing types.\n", "* [String interpolation](https://docs.scala-lang.org/overviews/core/string-interpolation.html) is user-extensible with custom interpolators.\n", "\n", "## Scala interoperates\n", "\n", "Scala is designed to interoperate well with the popular Java Runtime Environment (JRE). In particular, the interaction with the mainstream object-oriented Java programming language is as smooth as possible. Newer Java features like SAMs, [lambdas](higher-order-functions.ipynb), [annotations](annotations.ipynb), and [generics](generic-classes.ipynb) have direct analogues in Scala.\n", "\n", "Those Scala features without Java analogues, such as [default](default-parameter-values.ipynb) and [named parameters](named-arguments.ipynb), compile as close to Java as they can reasonably come. Scala has the same compilation model (separate compilation, dynamic class loading) like Java and allows access to thousands of existing high-quality libraries.\n", "\n", "## Enjoy the tour!\n", "\n", "Please continue to the [next page](basics.ipynb) in the Contents menu to read more.\n", "

Next

\n", "

Tour of Scala

\n", "
" ] } ], "metadata": { "kernelspec": { "display_name": "Scala (2.13)", "language": "scala", "name": "scala213" }, "language_info": { "codemirror_mode": "text/x-scala", "file_extension": ".scala", "mimetype": "text/x-scala", "name": "scala", "nbconvert_exporter": "script", "version": "2.13.1" } }, "nbformat": 4, "nbformat_minor": 4 }