Best Way to Learn Scala
Published:
Very common question that I am being asked by many Java developers is how to learn Scala. With all due respects to my fellow friends, let me start my saying that I am not an expert in Scala, however this post is dedicated to all my young (or I should say beginner) fellows who want to attain a certain level of proficiency in Scala technology and somewhere would like to take my advice on this. Keep in mind that if you do not like the way propsed then just ignore me. OR better, suggest me what you think is the better way to learn
Do Not compare with Java
Whatever that can be done in Scala, can also be done in Java. So first & foremost stop comparing with Java. As you are (I am assuming) a proficient Java developer, you might have a tendency to think this is so easy to do in Java with help of editors or some third party frameworks.
Learn basics of Functional Programming
Scala is a functional programming language, so just leaning scala keywords would not be of much help to you unless you learn some basics about functional programming. Functional programming can be daunting, but remember that it isn’t only for PhDs, data scientists and architecture astronauts. For most of us, the real benefit of adopting a functional style is that our programs can be broken down into smaller, simpler pieces that are both more reliable and easier to understand. I recommend the reading following article to give yourself a basic understanding of Functional Programming
A practical introduction to functional programming
Learn the language basics
This is the first step for very obvious reason. If you don’t know the basics then you will never know either what to do next or what you are doing wrong. Initially, I do not expect from you to become the master of all basic stuffs like keywords, core concepts or basic coding techniques. What really I expect from you is just to read all the text available in below links, even if it just doesn’t make sense to you in the first attempt. Just keep reading it.
https://twitter.github.io/scala_school/basics.html
http://www.scala-lang.org/documentation/
When you are done with few links as two given above, re-read them again second time. Don’t skip any part of it. This time, things will start making more sense to you, and you will be able to connect between various concepts by yourself. If you are still not able to connect the pieces of information spread in multiple places, then keep repeating this step until you actually start relating the core concepts. Don’t worry about you are wrong or right, just relate them and better make note
Create some small programs
One of the best things I found while learning Scala is the Scala REPL is a tool (scala) for evaluating expressions in Scala. The scala command will execute a source script by wrapping it in a template and then compiling and executing the resulting program
Once you are confident that you are very much familiar with most basic stuffs/keywords and concepts and you can actually relate them somehow, you are welcome to second step where you will have to start building some very very basic scala programs e.g. hello world, simple addition and subtraction etc.
When you are writing the programs, keep in mind that first couple of programs are going to be real tough for you. But once you are done with them you will not face similar level of difficulty in next set of programs.
You may face difficulty so much that you may not able to type in your hello world program itself, all by yourself. Don’t hesitate, open google and search similar program. Don’t copy it using CTRL+C. Type into your IDE.
Some programs you may consider are
Sorting a list of number, names Determine whether a given integer number is prime Find out whether a list is a palindrome Pack consecutive duplicates of list elements into sublists Create advanced programs Now when you are done with making most of the baisc programs, and most importantly, you are comfortable into creating such basic programs, jump to this step. Here, I will suggest you to work hard on learning Collections. Give some special attention to Case classes & traits as these are heavily used in your Scala programs. Just start exploring various classes and interfaces involved into these APIs and start creating programs for them.
Create a sample Blogging Application
I always think creating web applications is the best way to horne your development skills. Remember It’s only by solving errors and dealing with real life examples that you begin to learn the concepts.
Here I suggest making an API based Blogging application. For the purpose of learning Scala, you can skip the UI part of the application.
Ask help from experts , your experienced friends, colleagues and every person you know and who can help you. Read all available good material which comes into your way when searching for solutions and simple learning the concepts. Do everything what is needed to build this application. Make them you sole objective for few days (or weeks or even months).
Let me assure you that by the time you end up completing the application, you will be much more confident than ever before.
Leave a Comment
Your email address will not be published. Required fields are marked *