Exploring the Differences Between Imperative and Declarative Infrastructure Management

Alexa Vass
4 min readFeb 5, 2023

I recently had a conversation with a friend in the same field, which gave me the inspiration to write this blog post. We talked about how each of us approaches our work and the similarities and differences between our approaches. This discussion sparked my interest.

In summary, the key difference between our respective companies lies in their attitude and approach to infrastructure. While they adopt a declarative approach, my company tends to think in an imperative way. This has resulted in different approaches to managing and maintaining the infrastructure.

What’s the imperative way?

According to Webster’s dictionary, the word “imperative” means to issue a command or order.

An imperative approach is a type of programming in which instructions are given to a computer, step by step. This approach is often used when performing complex tasks, as it provides a detailed list of commands for the computer to execute. It is similar to following a recipe, in that each step must be done in order for the desired result to be achieved.

Image by picfoods from Pixabay

What’s the declarative way?

According to Webster’s dictionary, the word “declarative” is defined as making a statement or declaration, usually in order to provide information or instructions.

The declarative paradigm in programming is a method of providing instructions to the computer that describe the desired result, without prescribing how it should be achieved.

An analogy for this would be following a cake recipe where instead of specifying step-by-step how to make the cake, you simply provide the list of ingredients and the oven temperature. It would be more like saying “I want a cake with 2 cups of sugar, 1 cup of butter, 2 eggs, 3 cups of flour, and 1 teaspoon of vanilla extract, baked for 30 minutes at 350°F and then cooled.”

This type of programming enables the computer to use its own experience and knowledge to determine the best way to execute the instructions.

What we mean in our case

(After transitioning to new workplaces in the past, I sought out specific work experiences instead of a DevOps mindset. My current company has a system administration focus rather than an SRE (Site Reliability Engineering) focus, but I remain committed to SRE practices and am trying to help shape the company’s outlook. Although this is often a difficult and daunting task, I remain steadfast in my commitment to help effect change.)

In terms of infrastructure management, our companies are driven by different philosophies. We prefer to take a more hands-on approach, taking care to troubleshoot any issues that arise in our existing systems.

On the other hand, they rather start new clusters, copy the necessary data, perform a smoke test to verify functionality and switch over to them in the event of any problems or infrastructure-related updates.

The first approach I’ve described is referred to as the imperative approach, as it involves making changes to existing infrastructure. It is similar to writing a Python script, where each step is issued as an instruction. On the other hand, the second approach takes a declarative approach and simply requires a set of desired attributes for the infrastructure, similar to writing a script in Terraform.

This difference in approach has enabled us to develop unique strategies for how we manage our infrastructures.

Advantages and disadvantages

The imperative approach of infrastructure management provides a greater level of knowledge and understanding of the system. With this approach, you can be more proactive and have a better understanding of how to troubleshoot and fix issues. However, this method can take longer to execute, as each step must be carefully planned and thought out.

The declarative approach is a useful tool for those who need faster and more reliable updates or repairs. By using code to build the entire system, it can be tested more thoroughly and various scenarios can be simulated to ensure maximum reliability. Furthermore, changes can be deployed much faster since the code can be quickly adapted to different environments. Ultimately, taking advantage of both approaches ensures the highest level of reliability and efficiency in managing your infrastructure, ensuring that your system is up-to-date and running smoothly.

All in all,

The imperative approach to infrastructure management is an older method and may not be the most effective way of managing a system. However, it can still provide valuable insight if one is willing to learn and take the time to understand how it works. The declarative approach, on the other hand, is a more modern way of managing an infrastructure, as it allows for tested and maintained code to be used to build a system. Although both approaches have their own advantages and drawbacks, it is important to consider each and choose the approach best suited to your needs.

--

--

Alexa Vass

I am a girl in IT who talks about experiences and loves to learn new things every time, because IT is not my job, it’s my profession.