Many technologies will be learned in the big data learning process, but Scala is undoubtedly essential. How can we quickly understand Scala in the big data technology learning process, I want to learn more about this and thank you for the detailed materials provided by Mr. Yu from codo big data.
As we all know, spark supports four languages: R, Python, Java, and Scala, but the real underlying implementation language is Scala. In my previous practices, in addition to Python, I will also use Scala to practice it again. In the face of large-scale data modeling, we recommend that you use hadoop and spark for engineering development to make full use of the computing resources of the cluster. This article allows you to quickly learn Scala and learn how to learn and use Scala.
1. which groups are suitable for learning Scala?
You must have a clear career development plan, instead of chasing the trend to learn things in disorder and learning what you want to use, rather than learning what you want to do!
Therefore, if you are positioning as a big data development engineer and data application architect, you need to understand and learn from the bottom layer!
If you are positioning as an ETL engineer and data mining engineer, you need to understand and learn from practical applications!
In addition, I do not recommend that you think about it. After all, you cannot use it in your work scenarios.
2. Which stage is suitable for learning Scala?
I don't support learning it directly as soon as I come up, because it's just a thousand miles away. I hope you have a certain foundation for python or Java, and I want to learn more about some hadoop/spark applications, in order to be better and get started faster, rather than getting stuck in the confusion: "What is the purpose of learning it? ".
For the learning sequence, we recommend that you use Java-hadoop-hive-hbase-Flume-Kafka-storm-Scala-spark.
3. What are the advantages of Scala?
Learning it doesn't mean you can install it during the interview, because it's not good if you only know what it is, but are self-defeating.
The original intention of learning it is because there is a need in the actual work scenario, and the platform cluster environment decides to use appropriate tools to do the right thing.
As far as my current experience is concerned, it is certainly more suitable for large-scale data engineering development than Python and R, and more suitable for the production and use of online mining businesses. It is also more concise and efficient for development than mapreduce and Java, and can improve computing efficiency.
Of course, technology is not limited to the use of only one language, but from the Business and Environment perspective, flexible selection of the appropriate language for development, so that technology can serve the business.
4. How can I learn Scala?
You can choose to purchase related books or search for learning resources online. There are many such resources, but inexperienced friends, especially those with no foundation, are recommended for system learning, self-taught or reliable training institutions
5. what knowledge should be mastered?
In addition to network learning materials, we will share some basic knowledge to help you focus on your learning.
① Language background (understanding)
Scala is a static programming language that targets the Java Virtual Machine (JVM) runtime environment and combines the best features of object-oriented and functional programming.
Scala is a purely object-oriented language. Although Java is an object-oriented language, it is not purely because the basic data type of Java is not a class and there are static member variables and static methods in Java. On the contrary, Scala is purely object-oriented. Every value is an object, and every operation is a method call.
Scala is also a mature functional language. Function programming has two guiding ideology:
A. A function is a header equivalent, that is, a function is a value and is in the same status as other types (such as integers and strings). A function can be passed as a parameter or returned as a return value, you can also define functions in functions;
B. program operations should map input values to output values rather than local modifications, that is, function calls should not produce side effects, although functional programming languages encourage the use of "no side effects" method, but Scala does not force you to do this.
Scala allows you to use a directive programming style, but with your deep understanding of Scala, you may prefer a more functional programming style. To change to functional programming, you should try to use Val, immutable object, and method without side effects, instead of VaR, variable object, and method with side effects. What you need to understand is that it will be very difficult to change from functional programming to functional programming. Therefore, you must make full preparations and make continuous efforts.
Scala runs on the JVM and can access any Java class library and interoperate with the Java framework. Scala also extensively reuses Java classes and class libraries.
② Use ide To implement Hello Scala (Practice)
In addition to the scala interpreter, I often use IDE for development, such as developing a demo program using a deployed environment.
object Demo {def main(args: Array[String]) {println("Hello Scala.")}}
Note:
01. In Scala, the ";" after the statement is optional. When multiple statements are in the same row, you must add a semicolon, but it is not recommended to put multiple statements in one row.
02. We recommend that you use two spaces for code indent. Regular friends will prefer a tab key.
03. Scala indexes also start from 0, but the ancestor starts from 1.
04. Whether it is the import method or the matching method, using _ is equivalent to the * function in Java.
③ Scala data type (commonly used)
It has seven numeric types: byte, Char, short, Int, long, float, and double, and two non-numeric types: Boolean and unit (only one value "()", it is equivalent to void in Java and C ++, that is, null value ).
These types are abstract final classes (new or inherited classes cannot be used). defined in Scala packages, these classes are the packaging of Basic Java data types, therefore, it has the same length as the Java basic data type.
In addition, scala uses the string in the Java. lang package. In Scala, a constant is also called a literal. A string literal is composed of characters contained in double quotes. Scala also provides a syntax to define a String constant-the original string, it starts and ends with three double quotes. A string can contain any character.
In Scala, we use methods instead of forced type conversion to convert numeric types, such as 99.44.toint and 97. tochar.
④ Scala variable type (commonly used)
It has two types of variables: Val and var. Val is like the final variable in Java, and VaR is like the non-final variable in Java.
Since Scala is fully object-oriented, Val and VAR only declare whether the object reference is immutable or variable, and do not explain the variability of the object to which the reference points.
Initialization is required when declaring a variable. Otherwise, the variable is abstract. If no variable type is specified, the compiler will deduce its type from the expression that initializes it.
You can also specify the type when necessary, but note that in Scala, the type of the variable or function is always written behind the name of the variable or function.
Val STR: String = "Hello scala ."
⑤ Scala control structure (common)
It has a fundamental difference from other programming languages, that is, almost all constructed Syntax structures have values, making the program structure more streamlined.
It has few built-in control structures, such as if, while, for, try, match, and function call. Therefore, it is sufficient to be familiar with these classes. So few reasons are that Scala supports function literal at the syntax level.
In addition, scala does not have break and continue statements. If similar functions are required, they can be implemented indirectly, such as using boolean control variables and nested functions.
⑥ Scala Function Definition (commonly used)
When defining a function, in addition to recursive functions, You can omit the type declaration of the return value. It will deduce the type of the return value based on the type of the expression after Sign =, at the same time, the value of the expression after "=" is the return value of the function. You do not need to use the return statement.
It is recommended that you use expression values instead of return values. Of course, you can also explicitly use return values as needed.
def getNowDate():String={var now:Date = new Date()var dateFormat:SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd")var todatTime = dateFormat.format(now)todatTime}
The preceding functions are used to obtain the current date, for example, 2018-10-19 today. The return value type must be specified for recursive functions, as shown in the following Fibonacci sequence:
def fac(n: Int) : Int = if(n <= 0 ) 1 else n * fac(n-1)
Finally, if no function value is returned, the default return value is unit.
7. Scala Exception Handling (common)
It is similar to Java, but it is also different. For example, it does not need to declare functions or methods in advance, it may throw some exceptions. In addition, throw and try-catch-finally expressions all have values. If no exception is thrown, try is the value of the expression. When an exception is caught, catch is the expression value. When an exception is thrown but not captured, no return value is returned. Finally is used to calculate the expression value. However, it is often used to close files and connect files.
That is to say, if you want to quickly get started with Scala, you can develop small models, data processing logic, and so on. The above seven points of Knowledge basically cover your short-term learning direction. For more in-depth knowledge points, you can check for missing information in the future and conduct research and study based on actual scenarios, to use.
For more learning materials, please leave me a message.
6. What is the key to learning Scala well?
This is also a general method for learning any language or even craft. It is simplified and summarized here. More details need to be learned.
First: solid foundation;
Second: Find more development scenarios to practice, in order to train your hands, encounter new problems, and train your problem solving skills;
Third: In case of development difficulties, what are the bottlenecks first? Search for more network materials for targeted solutions;
Fourth: Completely develop a full-process data project, or even a business scenario model, and integrate scattered knowledge;
You may understand the truth, but you must select the correct method to get twice the result with half the effort.
This article from: https://www.toutiao.com/a6613915647984271886? Tt_from = mobile_qq & utm_campaign = client_share & timestamp = 1539994648 & App = news_article & utm_source = mobile_qq & IID = 46395736178 & utm_medium = toutiao_android & group_id = 6613915647984271886
How to quickly learn Scala