1. Scala language overview


1. Scala language overview

Chapter 1, an overview of the Scala language

== knowledge structure ==

Scala is divided into several stages.

  • 1. Scala language overview
  • 2. Basic knowledge of Scala
  • Scala data structure
  • Scala is object-oriented
  • Scala functional programming

1. Scala language overview

1.1 learning tasks

1. Understand the features of Scala language
Learn to configure the Scala environment
Configure the IDE and write the first program in Scala

1.1 development history

Scala is a shorthand for Scalable Language, a multi-paradigm programming Language,

MartinOdersky of the federal institute of technology in lausanne began designing Scala in 2001 based on such a work.

Funnel is a functional programming idea and Petri net combined with a programming language.

Odersky’s previous work was Generic Java and javac (Sun Java compiler). Scala for the Java platform was released in late 2003 / early 2004. Scala for.net was released in June 2004. The second version of the language, v2.0, was released in March 2006.

As of September 2009, the latest version is version 2.7.6. Scala 2.8 anticipated features include the rewritten Scala collections library, named and default parameters for methods, package objects, and continuations.

In April 2009, Twitter announced that they had migrated most of their backend applications from Ruby to Scala, and the rest were planning to do the same. In addition, Wattzon has publicly announced that its entire platform is already written based on the Scala infrastructure.

1.2 events

  • Scala design started in EPFL in 2001;
  • The Java version was released in early 2004;
  • ⽉ six months in 2004, the.net release;
  • 3 ⽉ month 2006, Scala 2.0 Java release;
  • ⽉ month in May 2011, Odersky and Jonas founded Boner Typesafe;
  • In 2012, the officer ⽅ party stop ⽌ check maintenance Scala..net version;
  • Scala 2.11.2 was released in 2014
  • Scala 2.13.0 will be released in 2019

2. Introduction to Scala

2.1 programming paradigm

  • 2.1.1 imperative programming

A model of programming that describes what a computer needs to do. Almost all computer hardware work is instruction; Imperative programming is concerned with steps to solve problems, such as JAVA, C, etc

  • 2.1.2 functional programming

It treats computer operations as mathematical functions and avoids the use of program states and mutable objects. The most important foundation of a functional programming language is lambda calculus. Plus, the lambda function can accept the function as an input (argument) or output (efferent). Functional programming is concerned with the mapping of data and the transformation between data sets.

2.2 Scala language features

  • 1. Multi-paradigm programming language, both imperative and functional

All values are objects, and in that sense, it is a pure object-oriented language, whose types and behavior are described by classes and attributes. This is similar to Java.

In scala, all functions are values and functions can be arguments to other functions, so scala is a functional language. Again, this is similar to python. So we say that scala integrates Java and python features

  • 2, based on the JVM, can be seamlessly mixed with Java
  • 3. Concise and elegant language

If you’ve ever written Java, you know that scala takes a few lines of code to do a very complicated operation in Java, and scala is a lot less code

  • 4. Scala business success

Spark,Kafka, Scala is widely used in the field of big data

2.3 the scala ecosystem

1. Scala language overview
Scala is primarily based on the application of big data, so we’ll cover the basics of scala syntax and object-oriented and functional programming.

3. Environment configuration

The versions here are JDK-1.8.0_211, scala-2.11.12

Do not install the latest version, late will appear many version compatibility problems ==

JDK environment configuration -win version

Scala relies on the JDK environment, first making sure that the JDK environment is installed locally
1. Scala language overview

3.1, download

3.1.1 configuration of win version

Download address

Download the version of the response here

1. Scala language overview

Follow the instructions step by step to install the same JDK.

3.1.2 environment variable configuration

Right-click on my computer, click “properties”, and go to the page shown in the figure. Now start to configure environment variables, right click [my computer] — [properties] — [advanced system Settings] — [environment variables], as shown below:

1. Scala language overview

Hit input in variableSCALA_HOMEEnter Scala’s installation directory in the variable value.
1. Scala language overview
Set the Path variable

After setting up the environment, type in CMD, type scala, success can see the following information
1. Scala language overview

3.1.2 MAC version configuration

The MAC version installation is the same as above, download the corresponding MAC version, according to the tips all the way to install.

MAC version configuration

configurationSCALA_HOME, and then add SCALA_HOME to your Path

export SCALA_HOME=/Users/sunliangliang/Documents/develop-tools/scala-2.11.12

The installation is successful as shown below
1. Scala language overview

The first Scala program

4.1 interactive environment

1. Scala language overview
We saw that you can print it out, you can calculate it.

4.2 IDEA and Scala

  • 1, idea installation Scala plug-in

Prefrences-> plugins-> search(“scala”), ready to install
1. Scala language overview

  • 2. Idea configure Scala SDK

The SDK needs to be configured the first time

1. Scala language overview
Browse to the installation directory of Scala and select the SDK to configure successfully.

  • 3. Create projects

1. Scala language overview

  • 4. First demo
package com.tedu.fast

  * Describe: 
  * @Author sunliang
  * @Since 2019/06/12
object Helloworld {

  def main(args: Array[String]): Unit = {
    print("Hello world")

The code structure is as follows
1. Scala language overview
This completes the integration of IDEA and SCALA

== notes ==

1. Scala language overview
Type Kind selects Object instead of Class (Object can be compiled with main function entry, so it can Run directly in IDEA).

Some of the above information is from the Internet, if there are copyright issues. Please contact me:
email : [email protected]
WeChat: click add