Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the main features of Scala

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "what are the main features of Scala". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Why Scala?

Although the use of Java is more popular in the field of big data, and Python also has the momentum of catching up from behind, Scala has always been in an unshakable position. The core code of Spark,Kafka,Flink that we are familiar with is developed by Scala.

So mastering Scala can not only learn the source code of big data components, but also greatly improve the efficiency of big data development.

This is why Scala's salary level has been so far ahead.

According to the global programming language salary statistics in 2019, there is no doubt that Scala, which ranks among the top several, is a language with the same excellent job requirements as income. Of course, there are differences between income and geography. For example, in the United States, Scala has the highest income of $143k, followed by Clojure ($139k), Go ($136k), Erlang ($135k) and Objective-C ($132k).

The data is based on the Stack Oveflow2019 annual survey of developers on programming language compensation rankings.

Why is there such a high salary?

This is probably due to the characteristics of Scala:

Elegance: this is the first consideration for framework designers. The users of the framework are application development programmers, and the elegance of API directly affects the user experience.

Speed: the Scala language is expressive, one line of code is worth Java, and the development speed is fast; Scala is statically compiled, so it is much faster than JRuby,Groovy.

Can integrate into the Hadoop ecosystem: Hadoop is now the de facto standard of big data, Spark is not to replace Hadoop, but to improve the Hadoop ecology. Most of the JVM language may think of Java, but the API made by Java is too ugly, or it takes too much effort to implement an elegant API.

This is why the source code of many big data components is Scala development.

After mastering Scala, we can rapidly develop Flink,Spark and other big data projects, the development efficiency has been greatly improved, and the use of functional programming, the code will be more concise, cool.

What is Scala?

Scala is born at the Lobsang Federal Institute of Technology (EPEL) in Switzerland and is an abbreviation for Extensible language (Scalable Language). Scala is a multi-paradigm programming language designed to integrate the features of object-oriented programming and functional programming. You can use Scala to write more concise programs, you can also be used to build large and complex systems, and you can access any Java class library and interact with the Java framework.

We can see the description of Scala through the official website:

Scala combines object-oriented and functional programming in one concise, high-level language. Scala's static types help avoid bugs in complex applications, and its JVM and JavaScript runtimes let you build high-performance systems with easy access to huge ecosystems of libraries.

The main features of Scala are as follows: 1. It runs on JVM and JavaScript.

Scala takes advantage of the high performance of JVM, as well as the rich tools and class libraries of Java. But Scala doesn't just support JVM,Scala-Js. It already supports Scala running on Js!

Scala-js is a compiler that compiles scala into js. The purpose is to build a stable and scalable js application using many class libraries and strongly typed features of scala.

2. Static type

In the Scala language, static typing (static typing) is a tool for building robust applications. Scala fixes some flaws in the Java type system and eliminates a lot of redundant code through type deduction (typeinference).

Dynamic and static languages

Dynamically typed language: refers to a language that does data type checking at run time. When programming with dynamic language, you don't have to assign a data type to a variable, the language will record the data type internally the first time you assign a value to a variable. Python and Ruby are typical dynamically typed languages.

Statically typed languages: in contrast to dynamically typed languages, its data type checking occurs during compilation, that is, the data type of a variable is declared when the program is written. C, C++, C #, and Java are all typical representatives of statically typed languages.

Strongly typed language and weakly typed language

Strongly typed language: a language that enforces the definition of data types. Two different types of variables are not allowed to operate with each other until type conversion is enforced. Strongly typed languages are type-safe languages such as Java,C# and Python, such as "int I = 0. 0" in Java, which cannot be compiled.

Weakly typed language: a language in which data types can be ignored. In contrast to strongly typed languages, a variable can be assigned values of different data types, allowing a block of memory to be treated as multiple types, such as directly adding integer variables to character variables. JavaScript,PHP is a weakly typed language.

Note that strongly typed languages are inferior to weakly typed languages in speed, and using weakly typed languages can save a lot of code and have higher development efficiency. For building large projects, using a strongly typed language may be more canonical and reliable than using weakly typed languages.

3. Mixed programming paradigm-object-oriented programming, functional programming.

Scala fully supports object-oriented programming (OOP). Features (trait) are introduced to improve the object model of Java. Trait can succinctly implement new types by using hybrid structures (maxin composition). In Scala, everything is an object, even a numeric type.

Scala also fully supports functional programming (FP), which has been regarded as the best tool for solving concurrency, big data, and code correctness problems. Using immutable values, functions, higher-order functions, and function sets helps to write concise, powerful, and correct code.

Functional programming is more concerned with data mapping. Using functional programming, such as WordCount with Spark, requires only one line of code.

Sc.textFile ("/ home/centos/test.txt"). FlatMap (_ .split (")). Map ((_, 1)). ReduceByKey (_ + _). Collect

4. Complex type system

Scala extends the Java type to provide more flexible generics and improvements that help improve the correctness of the code. By using type deduction. Code written by Scala can be as concise as code written in a dynamic typed language.

5. Concise, elegant and flexible grammar

With Scala, the verbose expressions in Java are gone and replaced by a concise Scala dialect. Scala provides tools that can be used to build domain-specific languages (DSL), as well as user-friendly API interfaces.

6. Scalable architecture

With Scala, you can write short explanatory scripts and glue them into large-scale distributed applications. The following four language mechanisms help to improve the scalability of the system:

Hybrid structure implemented using trait

Abstract type members and generics

Nested class

Explicit self-type (self type)

Scala has a close relationship with Java, and Scala can be regarded as an upgraded version of Java, and these advantages also give Scala a huge competitive advantage.

The relationship between Scala and Java

Scala has its unique charm, coupled with big data, the increase of stream computing development, Scala has more and more opportunities to show its talents, so it is difficult to say whether we will choose big data because of Scala or because big data chose Scala.

This is the end of the content of "what are the main features of Scala". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report