Categories
Random Resources

Scala database access driver client links and resources.

Resources and links about accessing a database in Scala.

An async postgre mysql db access client 

Categories
Resources Software Development

Scala map and flatmap links and resources

Understanding map and flatmap can be a little hard at first if you have never encountered them. Below are some links to help you get a better understanding of these constructs.

Map, map and flatMap in Scala – good article explains the concepts well.

Maps Scala Documentation – basic coverage of maps from Scala documentation.

Categories
Random Software Development

Why are Scala val variables called values?

One of the oddest things I encountered when starting to learn Scala was seeing variables called values instead of variables.

When I first started reading the docs I saw a list of values of the classes, traits etc. I kept wondering WTF is a value why not call it a variable like every other language.

So for a while I just thought the Scala community just referred to all class variables as values.

Then I was reading the docs some more, I found this page. It has this one easy to miss line that answers the question why are vals called values instead of variables.

The second sentence below the difference between Val and Var

“Because val fields can’t vary, some people refer to them as values rather than variables.”

 

And that is the answer. In the Scala API documentation most classes/objects you see has a list of values defined with val.

I suppose the class variables are defined this way so that you don’t accidentally mutate them or change them.

I am still  not sure why methods are called members yet, when I figure that out maybe I’ll write about it.

Categories
Resources Software Development

How Scala Imports and Packages work

One of the most important first things to learn about Scala is how Packages and Imports work. Below is a great video that covers the subject well. Why spend hours writing an article when an excellent resource exists?

Also if you would like to know more about Scala package objects, which allow you to reuse functions/ objects etc. then see my article what are Scala package objects

Packages and Imports (in Scala)

Categories
Resources Software Development

What are Scala package objects?

Scala package objects are basically code, functions, variables, classes, objects that you want available to all of your other code/files/objects in a given package. Basically it is like a system to provide utility, helper or common code all in one place.

Instead or writing an article I’ll post links to helpful resources. No reason to waste all my time writing articles if good article exist.

A minimal coverage of Package Objects by the  Scala docs.

The following link is from alvin alexander – from Scala Cook Book if you don’t own it you should buy it, this is an excellent resource. This link goes into much deeper detail than the documentation.
How to put common code in Scala package objects

Scala Tutorial – Learn How To Use Package Objects – excellent tutorial on how to use Package Objects.

Categories
Resources Software Development

Scala self types links and resources.

The Scala documentation coverage of self types is not very good. Here are some links to further information and explanations of self types in Scala.

Articles

Self types in Scala – This is a decent article that explains self types pretty well.

Scala Self types annotation – more information about Scala self types with examples.

Inheritance vs self types – this article covers the differences between inheritance and self types. Some of the content is repetitive of the above links but said in a different way with different examples. This does a good job of explaining why you would self type instead of inherit, the main thing  I was looking for.

Categories
Resources Software Development

Scala concurrent programming links and resources

A journey into concurrent programming in Scala – a good article about concurrent programming in Scala

Java Executors documentation – Scala uses Javas future system with Executors etc.

Play uses Akka so you can also use Akka dispatchers for the ExecutionContext required in the Controllers.

Link to Hikaricp library that creates connection pools for database access on JVM

Ebooks

Concepts and Technologies for Distributed Systems and Big Data Processing
Philipp Haller
Scala Futures, Async, and Actors

Categories
Resources Software Development

Scala performance issues and tuning

Exploring Scala performance – Great article pointing out some of the small things you can do to improve performance or DESTROY it.

Reactive Audit – a program to help detect where an application is using blocking code. This audit tool aims to provide help to the use of Reactive architecture in project implementations

Categories
Resources Software Development

Scala case class resources links and information

Scala case classes are used heavily in Scala code. Understanding them is very important in order to be efficient in Scala. Instead of repeating everything in the below articles, I’ll post links instead.

Scala Case Class and Case Object In-Depth (Part-1)

Scala Case Class and Case Object In-Depth (Part-2) 

Using Case Classes to Structure Your Data

Categories
Resources Software Development

Scala Closure Functions resources, links and info

What is a Closure function in Scala? The simple answer is, it is a dirty function that uses variables declared outside the function inside the function, which are not passed as values to the function.

I call them dirty functions because it feels dirty to have some unknown variable outside of a function have power to influence the outcome of the operation in a function. This can be a class or object where the variable is defined or to have even more fun in Scala it can also be an implicit variable from an import.

So again a closure is a dirty function that takes values as parameters but also accesses variable values from outside of the function that are not passed to the function directly… dirty
Scala Tutorial 15 – How to use closures in Scala

This video demonstrates Scala Closures in detail.