Learn the basics in Scala including syntax, how to set up an environment, and various common data types.
Originally published by Aditya Sharma at https://www.datacamp.com
Scala was designed by Martin Odersky, a professor at École Polytechnique Fédérale de Lausanne (EPFL) in Switzerland and a German computer scientist. Martin started working on creating Scala in 2001, and it was first released in 2004.
Scala stands for
Scalable Language. It is a general-purpose, object-oriented language which has a few commonalities with the Java programming language. It provides support for functional programming. Many of Scala's design decisions were aimed to address the drawbacks of the Java programming language.
A few features that Scala offers are:
One Interesting fact about Scala is that it is widely used by companies like Apple, Twitter, Walmart, and Google because of its scalability and the capability of being used in backend operations.
Jupyter notebook is the most widely used tools in computer science, especially in the data science domain. It also has support for Scala development with the help of
Setting up the Scala environment in jupyter notebook is not rocket science. So, let's quickly set it up in just a few steps.
pip install spylon-kernel(Python 2)
pip3 install spylon-kernel(Python 3)
scala-kernelin jupyter notebook.
python -m spylon_kernel install(Python 2)
python3 -m spylon_kernel install(Python 3)
spylon-kernelalso installs some
pip install pyspark findspark(Python 2)
pip3 install pyspark findspark(Python 3)
spylon-kerneland you are good to go!
val x = 2 val y = 3 x*y
x: Int = 2 y: Int = 3 res1: Int = 6
Great! So as you can observe from the above output, you were successful in configuring the Scala environment in jupyter notebook.
Let's start by printing
Hello, World! in Scala.
As you can see, it was so simple, just a
Now, let's take a look at few Syntax related details in Scala:
dataCampwould have a different meaning in Scala.
Upper Case. If many words are combined to form a name of the class, each separate word's first letter should be in Upper Case. For example,
class namesmainly to distinguish the
class names. The method names should start with a Lower Case letter (Source). If multiple words are combined to form the name of the method, then each inner word's first letter should be in Upper Case. For example,
.scalato the end of the name. For example, Let's say
ScalaTutorialis the object name. Then the file should be saved as
main()method, which is a crucial part of every Scala Program.
Below figure shows the reserved words in Scala which cannot be used as constants or variables or as any other identifiers.
Data types in Scala are almost identical to many other programming languages like C, C++, Java, Python, etc. with similar memory footprint and precision.
Finally, let's take a look at a few of the data types that exist in Scala:
A few of the other data types are String, Boolean, Null.
Congratulations on finishing this tutorial.
It is a good starting point for beginners who are interested in learning Scala.
There is a plethora of information related to Scala that remains unraveled like if/else, for loops, various operators in Scala, etc., which will be covered in the future tutorials, so stay tuned!
Thanks for reading ❤
If you liked this post, share it with all of your programming buddies!
Data Science and Analytics market evolves to adapt to the constantly changing economic and business environments. Our latest survey report suggests that as the overall Data Science and Analytics market evolves to adapt to the constantly changing economic and business environments, data scientists and AI practitioners should be aware of the skills and tools that the broader community is working on. A good grip in these skills will further help data science enthusiasts to get the best jobs that various industries in their data science functions are offering.
In the programming world, Data types play an important role. Each Variable is stored in different data types and responsible for various functions. Python had two different objects, and They are mutable and immutable objects.
This Data Science with Python Tutorial will help you understand what is Data Science, basics of Python for data analysis, why learn Python, how to install Python, Python libraries for data analysis, exploratory analysis using Pandas, introduction to series and dataframe, loan prediction problem, data wrangling using Pandas, building a predictive model using Scikit-Learn and implementing logistic regression model using Python.
Become a data analysis expert using the R programming language in this [data science](https://360digitmg.com/usa/data-science-using-python-and-r-programming-in-dallas "data science") certification training in Dallas, TX. You will master data...
The agenda of the talk included an introduction to 3D data, its applications and case studies, 3D data alignment and more.