Updating OpenSSL latest and greatest version in Ubuntu 20.04 and 18.04

A year has passed since I published this story. Since then Ubuntu 20.04 was released and OpenSSL newest version was published on August 6th 2020. Basically the only thing I changed in this story was…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Advantages and disadvantages of functional programming

I have already written about why you should learn functional programming and explored the fundamentals of functional programming. Before diving into more advanced topics I want to discuss advantages and disadvantages.

It’s important to know where FP shines and where it doesn’t before you fully embrace it. Hence, this blog post is supposed to help you decide whether FP would be a good fit for solving your problem at hand.

FP doesn’t guarantee that you write simple code, but pure functions and immutable variables provide a structure that helps with writing simple code. Side-effects and mutations create a mess in our software because we need to handle edge and error cases. In FP we isolate our data and pure functions (or calculations) from the side effects and mutations. This means we don’t need to deal with error handling and null checks, etc. in our actual algorithms. Because of that our algorithms are stripped down to the core of what they are about. Further, since we adhere to the immutability principle, we use declarative code to implement our algorithms. Declarative code describes its intent and is therefore also simple.

Have you ever spent hours just trying to get a mock to work? I have and it sucks. It’s frustrating because it feels like you’re wasting time that you could have spent implementing features. I’ve been on a project where colleagues skipped writing tests because mocking was too much of a hassle. Guess what, pure functions don’t need any mocks to be tested. This means that the entire core of your application can be tested without mocks in FP. What’s even better though, you can mathematically prove the correctness of pure functions. Unit tests without mocks are easier and faster (less code) to write and give high confidence in the correctness of your implementation.

Three properties of FP make its functions very reusable.

The next two are more advanced concepts that I haven’t explained yet. I will do that in a future blog post

Gone are the days where our CPU cores got (much) faster. Modern CPUs are made up of lots of cores. If you want to make use of those, your software needs to implement some way to deal with threads and concurrency. As I explained previously pure functions and immutable data make a program thread-safe. Hence your software becomes scalable.

Immutable variables come with the trade-off that as you’re not changing the existing variable you create a new one. This means double the memory usage. If we are talking about large, nested data structures, this can also impact performance because of the overhead of copying the data over instead of just changing the existing one. Functional languages usually have ways to make sure you don’t have this trade-off by using things like tail call optimisation, lazy evaluation, and smart linking instead of copying the actual data. However, multi-paradigm- or OOP languages might not have implemented these optimisations.

As functional programming languages are used less than other languages, more popular languages like Java or JavaScript have a bigger community and hence more frameworks, tools, and reusable packages. This can become a major issue if components of your architecture don’t support integration with the functional language of your choice. One would think that in the age of cloud and containers this wouldn’t be a problem anymore. However, different cloud services, databases, and other tools still have a lot of restrictions when it comes to language support.

If a company chooses to embrace a functional programming language, one crucial thing is to consider the availability of experts in that language. The language might be the perfect fit for the use case but if you can’t find the experts to support this over time, you may have to source it from a specialised vendor that is likely going to charge a premium due to the scarcity of said language.

The famous French philosopher Claude Lévi-Strauss would say of certain tools:

Functional Programming is an approach to dissect a problem in a certain way. Eric Normand describes this as actions, calculations, and data in his book Grokking Simplicity. Actions are interactions with the outside world. Actions are I/O operations or any operations that are impure. Calculations are pure functions that operate on (immutable) data.

Other paradigms take a different approach. In OOP we dissect problems differently. We separate data and operations that work on that data into classes that represent both. We also try to shape these according to what we find IRL and define the relationship between them.

The question is which approach do you find “good to think with?” I think the response here can differ from person to person and even for one person from problem to problem.

I am a big fan of functional programming and for me, it’s the most natural “tool to think with” that comes with some great advantages. However, it’s not suitable all the time. I hope that functional programming will continue to become more popular and therefore an even better alternative for businesses.

Add a comment

Related posts:

Deixa o menino ver o Ronaldinho

Naquela altura do campeonato, lógico, ninguém lembrava mais quem era Romário, e só o que os meninos queriam no futuro era ser o Ronaldinho — Na época, apelido dado ao Fenômeno — . Nesse dia o Brasil…

Quick Dip into Dwarf Fortress

So this week I finally decided to take the plunge into a game I’ve always been fascinated by: Dwarf Fortress. This is one of those games you’ve probably heard of before because it’s a game, much like…

what is importance of educational technology to a teacher

Instructive innovation is a precise utilization of applicable mechanical procedures and assets in educating, with an objective to improve understudies’ presentation. It includes a trained way to deal…