Wednesday 4 November 2015

Week 6 [02.11 - 08.11.2015] Scala - functional programming language


Scala is a modern programming language, it combines two paradigms: an object oriented one and a functional one. What does it mean? It means that every value in the program is an object. Objects are structures that contain data in the form of fields, often known as attributes. Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing-state and immutable data. You can feel disheartened while reading this explanation, but it is easier than it looks.

So, why is Scala getting so popular within last years?
 The answer is simple, it allows us to write better and faster applications than imperative languages like Ruby or Java. It is also portable, which means that you can run Scala applications on different devices from smartphones to servers.
“Talk is cheap. Show me the code.” - Linus Torvalds
So here it is:

case class Apple(isBad: Boolean)
val apples = List(Apple(true), Apple(false))
val goodApples = apples filter(!_.isBad)

This code contains a definition of an Apple class, and a list of Apples. Apple can be bad, so there is an isBad field in the Apple class. At the end we get a list of good apples by filtering all apples by the isBad field. It's really simple, isn't it?

Who uses Scala?
Twitter, LinkedIn, Walmart, HP and many more... For example, Twitter, which was famous for its use of Ruby on Rails, started to migrate its back-end message queue to Scala. It gave them better performance and a reliable message queue service.
 
Scala is a compiled language, it means that correctness of a program is checked at the compilation process which translates the source code into the machine language. On the other hand, the correctness of an interpreted language is checked at runtime, it means that if program is incorrect, the application will crash.

1. Have you ever heard about functional programming languages?
2. Would you like to get more familiar with Scala?


16 comments:

  1. 1. Yeah, I did, although I still find that concept a bit weird, probably because I never tried writing anything in functional languages. I should find some time on trying it out sooner or later, because concept is good and I can already find particular cases where Scala would be much better choice than my beloved C# or Java.
    2. Probably when I had particular project to do, or case to solve.

    ReplyDelete
  2. Well it's the interesting topic. Concept is interesting but a bit weird at the same time, but yeah it can be used in many various situations where Java, C# or Python have problems. As you said it's used to improve message queue - and in my previous job there was an idea of migrating RabbitMQ to Scala and from what I heard it is being implemented there.
    Yes, I would like to get familiar with it, because it's a common job requirement to fill or at least like "this will be an advantage if you know it" requirement. It's just good to know that things ;)

    ReplyDelete
  3. 1. Yes, interesting concept. I heard that programming in functional languages helps to better understand object oriented programming languages.

    2. 2 years ago I tried to get familiar with Scala, but i gave up because of lack of time. I noticed that it is interesting and powerful language.

    What books, webpages or other sources you recommend to learn that language?

    ReplyDelete
  4. Unfortunately I didn't have a contact with this language, it is hard for me to this subject to give its opinion.
    However, I would like to learn more about this language, because is interesting.

    ReplyDelete
  5. I never have contact with that language but I heard something about it. Maybe in the future I will give a chance to learn that language.

    ReplyDelete
  6. I have heard about functional programming languages, but I never learned any of them. Nowadays object oriented programming seems to be the most popular and common one, is there chance that in future functional programming would replace object oriented one? It looks like low level language, currently I am rather focused on high level programming languages, but if Scala becomes commonly used, then I will learn it.

    ReplyDelete
  7. 1.No, I didn't have any contact with Scala.

    2.From what I read more one the internet Scala is not a beginner's language. It's complicated, subtle and requires a significant investment of learning. It's awesome, but it's not easy.
    Scala is a language that has learned from the mistakes of history and strives not to repeat them. It attracts the sort of developers who have enough experience, in Java and other traditional languages, to appreciate this.

    ReplyDelete
    Replies
    1. If this language becomes more popular and companies will pay good money to scala developers I will definitely want to learn this language ;)

      Delete
  8. "Write faster applications than Java" - Scala is compiled to Java bytecode.

    "it means that correctness of a program is checked at the compilation process" - The correctenss of *syntax*. The program can be utter nonsense and still compile just fine.

    Honestly, if I were to learn a functional programming language, I'd go with haskell.

    ReplyDelete
  9. I've heard about this language but I've never used it. It is quite interesting and I think it will be a good idea to become more familliar with it. Maybe some day I will attempt to learn Scala.

    ReplyDelete
  10. 1. No
    2. If this would be necessary or well-paid why not. But I think for myself I wouldn't learn new language because I'm too lazy :)

    ReplyDelete
  11. 1. Off course i heard about, Java 8 added constructs to facilitate the functional style, Functional programing is good, very simple. but we cannot migrate all on this side. There are thing that need to be written in imperative languages :)
    2.Not now, maybe later. Now imperative languages are my priority :)

    ReplyDelete
  12. For now I do not need another programming language and the syntax scares me a little.
    Once I heard that twitter (which was written in my favorite framework) moves to nodejs, so thanks for that information – it is probably more true than what i heard once.
    On the other hand i found something.
    http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
    Scala takes 28th place in the most popular languages in 2015. One week ago I prepared presentation about Ruby which takes 9th position. So we will see whether this programming language will be more popular then java ;)

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. Once i try to use scala on one project . I think its good powerfull language but needs more time than 2-3 days to make something good in it.When i find more time , i think i try use it and swap with code which was written in other language .

    ReplyDelete