Resources Software Development

random programming articles videos and links

Is It Time to Get Over Design Patterns?– Interesting article pointing out some of the issues with the use of OOP Design patterns.

Category Theory  – This is what functional programming is based on.

Category Theory – Wikipedia entry covering category theory.

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.

Resources Software Development

Scala Threads, Futures and Promises, links and resources


Scala Futures – link to the api documentation

Concurrency vs Parallel computing – good article on the subject

Don’t use actors for concurrency – article about using actors and futures for concurrency

A journey into concurrent programming in Scala – this article explains the basics of using futures and an execution context for concurrency. This is very basic.

Throttling Instantiations of Scala Futures – a very good article pointing out some of the issues with using Scala futures and how to back pressure them.

Understanding play thread pools – this is from the documentation on how to create thread pools

Scala Futures and Promises – Article from the Scala lang website documenting how Futures and Promises work in Scala

Scala Future Execution Context API documentation

Link to Java Executor documentation – for working with execution contexts

Link to an article about Scala async/await on the scala-lang site

Asynchronous Programming and Scala – a really good article about async programming and how it works in Scala.


Scala futures

Future Calculations (in Scala)

Scala Programming – Introduction to Threads and Futures

Futures and Async: When to Use Which?

This video explains more of the theory of how Futures, Async and promises work than how to actually use them.

How to Write Controllable Futures in Scala | Rock the JVM

Awaiting Futures (in Scala)

Resources Software Development

Reactive web applications notes

These are my personal notes about Reactive Web Applications by Manuel Bernhardt – It was written in 2016 it is a bit dated already as it covers Play Framework 2.4 and it is currently at 2.8 some of the things in play have changed. Play and everything in Scala world is changing so quickly all books are outdated the day they are published but they are still useful.

This book contains a lot of good general information about how Play Framework works.

One problem is certain things have either been removed from play framework code API and no one bothered to leave a link in the API docs, or the code was wrong. In particular chapter 5

import play.api.libs.concurrent.Execution.Implicits._

The compiler complains Execution does not exist.

The book is still full of great information and examples that give you a good idea of why you should do things a certain way and even examples of things to avoid.

But these are my notes for me.

Good coverage of  how Plays ExecutionContext works in Chapter 5 starting on page 110 in particular. This chapter covers Futures, how to use them in Play and how the Execution context works. It covers how to create custom execution contexts for such things as DB access or for each service of a larger app.intensly

Chapter 5 page 11 covers Async Controller Actions, how to create them and why, lots of good info on pages 110 – 111.

Chapter 5 page 112 Covers Custom Error handlers, very useful information here, for handling errors when working with Futures.

Chapter 5 page 114 covers correctly configuring and using an ExecutionContext. It covers when and why you would want to do so.  Page 115 & 116 carries on and goes into deeper coverage with Specialized Execution contexts such as DB heavy code. Pages 117 & 118 continue to cover Execution context in depth  This is the best coverage of Play Frameworks Execution context I have found anywhere yet.

Page 119 & 120 covers testing futures a little

Page 120 section 5.2 talks about Designing Asynchronous business logic with Futures and identifying parallelizable elements.

Pages 121 through 128 continue to cover using Futures, the quirks associated with them and how to avoid them.

Page 123 mentions the reason Futures are better than callbacks is because futures can be composed or combined, this can make swapping things out quicker.

page 126 makes an interesting point about Futures and the order in which you declare them. This mentions a gotcha with a good example of something that wouldn’t work the way you expect it to with Futures.

Page 128 – 132 covers Handling errors when using futures.

Chapter 6 is a quick introduction to Akka Actors and how to use them in play apps.

Page 144 lists the actor methods such as tell, forward etc. and gives brief coverage.

Page 147 makes a point about using var over val for actors to make them immutable.

Pages 148 and 149 cover common beginner mistakes with actors and how to avoid them.

Page 149 quickly covers when to use an Actor vs Future, very good and useful insight here.

Page 154 Section 6.2.3 has good information about letting actors die and reviving them and other error/exception recovery information.

The rest of chapter 6 pages 155+ deal with monitoring and preventing actor service overload, circuit breakers and more on handing errors.

Page 157 – 158 address avoiding duplicate actions

Page 159 covers Actor Message priority as a way to keep an actor system from overlaoding.

Resources Software Development

Scala Option resources, links and info

When programming in Scala you will see Option used everywhere. What is Option? Basically Option is Scala’s version of Null. However using Option/Some/None is a way of handling errors it doesn’t tell you what went wrong. In order to know what went wrong you must use exception handling.

Option/Some/None is most useful when you have a function that needs to check for a value and tell you if it exists or not. It can’t tell you for example that something didn’t exist because an error occurred. This must be taken into consideration when programming.

Scala Option API documentation link – this is the actual API documentation showing all methods etc.

Tutorialspoint Scala Options – a great introduction to Scala Option
Using the Scala Option, Some, and None idiom (instead of Java null)

Using the Scala Option, Some, and None idiom (instead of Java null) – nice coverage of Option, Some, None syntax and how to use it and how it functions.

Scala best practice: How to use the Option/Some/None pattern – more coverage of Options in Scala

Resources Software Development

Scala things to avoid

Scala has some things you should be aware of in order to not write code that is slower than molasses in Winter in Siberia or eat up every last drop of RAM your machine has.  Most of these things revolve around Collections/Arrays and how you work with them.

When I started digging into for comprehensions they sounded very inefficient so I did some digging and my suspicions were

#1 thing to avoid For comprehensions. Unless the collection/array/data you are operating on is small then avoid for comprehensions and use other methods. Reason being is for comprehensions underneath the covers create maps and flatmaps and those create objects for each element in your collection/data. If you stop for a moment you can imagine what a collection of 1,000 elements would do or larger. So you should probably use for comprehensions on only small collections like 10 or less. Of course you should play with your code and find out for yourself what is more efficient.

Also map and flatmap are not very efficient with large collections for the same reason as above.

I will continue to add to this article as I have time. Below are some excellent resources describing the above in much deeper detail.

You might also want to see my listing of Scala Best practice resources.

Benchmarking Scala collections – article by lihaoyi about the inefficiencies of and memory usage of various Scala Collection methods such as map and flatmap very valuable and useful information here for people that like to understand languages inside and out.

Warts of the Scala Programming language – Excellent article about some of the bad parts of Scala

Scala: comprehending the for-comprehension – this is a great article that covers the for comprehension in depth. This will help you understand more about the inefficiencies I am talking about.

Scala Wart: Convoluted de-sugaring of for-comprehensions – link to a discussion about the language issues including the creator of Scala. This give super in depth information as to what I am referring to above.

Resources Web Development

SASS CSS resources and links

SASS makes CSS way easier. You don’t have to type the same things over and over. You don’t have to hunt down instances of colors to change the theme of your website. You don’t have to hunt down font definitions to change them. You get variables and functions right in your CSS to make everything easier, faster and cleaner. In the past CSS was actually way more time consuming than writing the backend code that handled the websites/apps requests. Times have changed.


Sass Basics – basic intro and documentation

Sass Documentation

Sass vs. SCSS: which syntax is better? – an article that discusses the history of SASS and the .scss vs .sass file extensions.


Learn Sass In 20 Minutes | Sass Crash Course