DevOps is all about bringing software development and operations together under a single functional team to increase quality, communication, collaboration, and efficiency.  Developers already have a background in development (duh), but a question I get asked frequently by operations engineers is "What are the top programming languages to learn for DevOps?" or "What are the best programming languages to learn for DevOps?"

Everyone could use a little bit of development in their life.  It could be something as simple as a bash script to take care of a simple task, or writing Infrastructure as Code, all the way up to running a blog like this one.  Learning about the logical flow that a computer takes to compute everything is an empowering door to open when growing as a technology specialist in whatever field you specialize in.

When practicing DevOps, a variety of different skill sets will be utilized to accomplish smooth and streamlined delivery. Frequently DevOps engineers will be utilizing different programming languages to accomplish their tasks. This is a move away from one-time-scripts that are thrown away after use to scripts or full blown applications that are integrated directly into the delivery pipeline for persistent reuse.

There are numerous programming and scripting languages to choose from so it can be a bit daunting to narrow it down when doing research. Luckily, I have done some narrowing down for you!  Below are a few of my favorite DevOps languages but this is by no means a definitive list.  These are coding languages that I have used in my workflows and found some great success.

Let's discuss some of the best programming languages for DevOps that can learn as someone with little to no experience so you can level up your DevOps game!

Related Articles

DevOps with Python

Python is an interpreted coding language and was created in the 1980s by Guido van Rossum in the Netherlands.  It is widely adopted and widely used across the industry.  You can find Python pre-installed on most modern Linux distributions today, though there is still a bit of fracturing between Python 2.x and 3.x communities. Aside from Javascript, you will find that Python is easily one of the most popular programming languages out there today.

Below is an example of a python script that someone utilizing the language for DevOps might write:


import os
import subprocess

def deploy_app():
    # Pull the latest code from the repository
    subprocess.run(['git', 'pull'])

    # Install any required dependencies
    subprocess.run(['pip', 'install', '-r', 'requirements.txt'])

    # Restart the app server
    subprocess.run(['systemctl', 'restart', 'myapp'])

if __name__ == '__main__':
    deploy_app()

How Big is the Python Community?

Python has a strong community backing it.  At the time of writing this, PyPI has ~391,000 packages with nearly 660,000,000 package downloads per day.  PyPI is a package repository for Python where you can download community or vendor-developed code and add it directly to your project.  There are a lot of pre-solved problems out there like connecting to a database.  PyPI enables users to download packages like those database connectors automatically.

What is the Utility of Python?

Python has a lot of utility in the DevOps space.  Since it is born out of the Linux and Unix ecosystem, it has some very strong ties to the Linux operating system for performing common tasks.  It is so well suited for this task that Ansible-Core is written in Python.  Python is also runnable on Windows!

Python is clearly a good choice when it comes to writing automation code for DevOps, but it has a lot of other utilities as well.  Much of the Big-Data space is using python for number crunching and machine learning specifically because the language lends itself well to that kind of computation.  Being a dynamically typed language instead of a statically typed one, data transformations can be done quickly without a lot of overhead by the end user.

Being an interpreted language gives it a lot of power as well when it comes to distributing and running the code.  Aside from activities like automated testing, packaging Python consists of compressing your directory structure, moving it to where you want, decompressing, and finally running the code.  If there is a bug, you can also fix it in place, though I would recommend ensuring that you have centralized code repositories and follow a good process of version control and pushing new versions out.

Python Learning Resources

DevOps with JavaScript

JavaScript is widely available on the web and has a huge footprint. If your work environments depend on Node.js, the ability to develop Javascript is an advantage. As with Python, JavaScript has an enormous user base. There are many Javascript projects that could benefit from this community.

Much like Python, is an interpreted language. Unlike Python, Javascript is easily multithreaded (async tasks on a single main thread) directly out of the box with no additional work required. Javascript creates immersive and interactive websites, can be used as a server-side scripting language, can be used for GUI development powering both mobile and desktop applications, and can be utilized to build fully functional server and client-side web-based applications. It really is the swiss army knife in this list of the best programming languages for DevOps.

If you start to work with Javascript in DevOps, you will find that it is an extremely versatile language and it could be the right programming language for your specific cases. There is a reason why the community is as large as it is!

Below is an example script written in Javascript to perform a common application deployment:


const { execSync } = require('child_process');

async function deployApp() {
    // Pull the latest code from the repository
    execSync('git pull');

    // Install any required dependencies
    execSync('npm install');

    // Restart the app server
    execSync('systemctl restart myapp');
}

deployApp();

How Big is the Javascript Community?

Javascript could probably be considered the most popular programming language at this point. I would not argue that by code volume, but I would argue that just about every single developer that has touched the internet has either developed, debugged, or been confused by Javascript. The community then got bigger with the advent of Node.JS. This moved code from the front end to the backend where it could easily be run on a server. At the time of writing, there are over 1.3 million NPM packages available for consumption.

What is the Utility of Javascript?

When it comes to DevOps engineers, Javascript is widely used across numerous cloud computing platforms as a configuration management tool, scripting language, or as traffic routing or traffic modification runtime. AWS Cloudfront uses Javascript as its primary configuration language in its event-driven Origin or Response systems. Cloudflare pages utilizes Javascript as its Functions framework for performing request modifications in line with internet requests.

If you are going to be engaging with any kind of edge compute platform, there is a pretty good chance that you will be interacting with that system via Javascript. Additionally, most serverless platforms out there are going to support Javascript by default either in configuration or in technology implementation.

DevOps engineers are going to need a pile of scripting languages at their disposal as we. If you are working in a DevOps environment that already has Node.JS included, then Javascript can be a really good language to use. This Blog uses Node.JS as its delivery pipeline through Cloudflare Pages to do some content manipulation between WordPress and publishing static pages.

Additional Utility!

Javascript can be utilized as an interactive command language directly from the browser through the Developer tools. An ICL lets you input code into a running environment to get information back. Through Developer Tools consoles, you are able to run code, print variable states, etc.

Popular tools like VSCode are also written in Javascript (TypeScript) using a tool called Electron. Electron is a cross-platform application framework for running Javascript, HTML, and CSS on desktop.

Javascript Learning Resources

DevOps with Golang

Golang was originally designed at Google in 2007 as a replacement for C and C++.  GoLang foregoes some of the more tedious facets of C and C++ like header files for type definitions.  GoLang is also a compiled language instead of an interpreted language meaning that the result of something in Golang is going to be a binary.  Golant has quickly grown in popularity and is the core language behind the very popular container orchestration framework Kubernetes.

Below is an example of an app deployment in Golang:


package main

import (
    "os/exec"
)

func deployApp() {
    // Pull the latest code from the repository
    exec.Command("git", "pull").Run()

    // Install any required dependencies
    exec.Command("go", "get", "-u").Run()

    // Restart the app server
    exec.Command("systemctl", "restart", "myapp").Run()
}

func main() {
    deployApp()
}

How Big is the Golang Community

The size of the Golang community is tough to nail down because of the way that GoLang mod works.  GoLang mod can be any git URL that has a go.mod and go.sum file in its repository.  From there, go mod will check out the code, and check out the code's dependencies all while doing dependency resolution in the background.  Since git can be hosted anywhere, nailing down how many downloads a day without some kind of body providing central registration of packages like PyPI does, the best we can do is look at something like google trends for a baseline of activity.

As you can see by the graphic above, at the time of writing, Python is the dominant search in Google Trends compared to something like Golang.  I would consider Golang a strong and growing community with projects like Kubernetes and CockroachDB along with large technology groups moving into using the stack like GitHub and Uber.

What is the Utility of Golang

In my workflow, I am generally using Golang for 2 things; microservice apps and API middleware.

When I say microservice apps, I am generally not talking about something which is composed of a larger ecosystem.  My microservice-type apps are usually tied into a Kubernetes stack.  I had a particular challenge with Linkerd where I need to create a MutatingAdmissionWebhook to rewrite my HTTP(s) probes as in pod curl probes after setting my namespace to deny all.  This was a good workaround to wrapping and rewriting many different helm charts to use curl probes instead of using standard HTTP(s) probes.

You can find that code here.  

When doing API orchestration, I have written a few applications which will pull data from one API (or have data pushed via a webhook) into an application that may amend or transform the data before pushing it into another receiving API.  This is particularly useful when trying to normalize data from system A to system B.  This was particularly useful when moving from a Graphite-based metric TSDB system over to InfluxDB.  We did not need to rewrite all of our metric collectors, we just needed to tap into the metric stream, do an on-the-fly conversion, and then output metrics to InfluxDB.

▶ Real World Example

Golang is the language that powers this website, well... kind of. This website is generated with Hugo with the output being a static website. While I could host this in something like Wordpress, the very static nature of the content means that a static site generator is very well suited for this kind of thing. Golang is part of the toolchain, not the solution that is pushed to production. Running a static website is also part of my overall cloud security strategy.

It is really tough to steal all the data bits when there are NO data bits to steal 🤓.

Learning Resources

DevOps with Java

Java is a popular language that is commonly used for writing software in a variety of contexts, including DevOps automation. There are several reasons why Java might be a good choice for writing DevOps automation scripts:

  1. Java is a high-level, object-oriented language that is easy to read and write, making it well-suited for tasks that require complex logic.
  2. Java has a large standard library, as well as a wealth of third-party libraries, which can be leveraged to perform a wide range of tasks.
  3. Java is a compiled language, which means that it can be run on any platform that has a Java Virtual Machine (JVM) installed. This makes it easy to deploy Java-based automation scripts on a wide range of systems.
  4. Java has a large developer community, which means that there is a wealth of documentation, tutorials, and other resources available to help developers learn and use the language.

I would also consider Java to be one of the top programming languages in the world, especially in the realm of enterprise applications. There are also many languages that run on top of the JVM like Groovy scripting and Kotlin so you can live in the same runtime but utilize a syntax that is better suited for your use case.

Below is an example script to perform an application deployment written in Java:


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class DeployApp {
    public static void main(String[] args) {
      try {
          // Pull the latest code from the repository
          Process gitPull = Runtime.getRuntime().exec("git pull");
          BufferedReader gitOutput = new BufferedReader(new InputStreamReader(gitPull.getInputStream()));
          String line;
          while ((line = gitOutput.readLine()) != null) {
            System.out.println(line);
          }

          // Install any required dependencies
          Process mvnInstall = Runtime.getRuntime().exec("mvn clean install");
          BufferedReader mvnOutput = new BufferedReader(new InputStreamReader(mvnInstall.getInputStream()));
          while ((line = mvnOutput.readLine()) != null) {
            System.out.println(line);
          }

          // Restart the app server
          Process systemctlRestart = Runtime.getRuntime().exec("systemctl restart myapp");
          BufferedReader systemctlOutput = new BufferedReader(new InputStreamReader(systemctlRestart.getInputStream()));
          while ((line = systemctlOutput.readLine()) != null) {
            System.out.println(line);
          }
      } catch (Exception e) {
          e.printStackTrace();
      }
    }
}

How Big is the Java Community

Java is a popular programming language that has a large and active community of developers. According to Oracle, the company that owns and maintains Java, there are more than 9 million developers worldwide who use Java.

In addition to the large number of developers who use Java, the language also has a wide range of tools, libraries, and frameworks that are supported by a large community of developers and users. For example, the Apache Foundation, which is a non-profit organization that supports a number of open-source projects, maintains a number of Java-based projects such as Apache Tomcat and Apache Hadoop.

What is the Utility of Java

Java is a programming language that can be useful in a DevOps environment for automating tasks, integrating systems and technologies, and monitoring the performance and availability of systems and applications. Some specific ways in which Java can be useful in DevOps include:

  • Writing scripts and programs to automate processes such as code deployment, testing, and quality assurance.
  • Building libraries and tools that can be used to connect to and integrate different systems and technologies, such as cloud-based storage services or continuous integration servers.
  • Developing applications that monitor the status of servers, applications, and services, and send alerts or notifications when issues are detected.

Java is a powerful language that can be used to build a wide range of tools and applications that support the goals of a DevOps team.

Learning Resources

DevOps with Ruby

Because of its efficiency in DevOps, Ruby is a preferred scripting language for automating IT environments' repetitive tasks. In addition to web development, data science, and unit testing, this dynamic, interpreted programming language is used for DevOps. Ruby is also fairly simple to learn. As a result, the language has a fast-growing community of DevOps engineers. With no prior programming experience, beginners can get started with Ruby pretty quickly. 


def deploy_app
    # Pull the latest code from the repository
    `git pull`

    # Install any required dependencies
    `bundle install`

    # Restart the app server
    `systemctl restart myapp`
end

deploy_app

How Big is the Ruby Community

Ruby is a difficult community to quantify fully simply because of how spread out it is.  Ruby Gem can be a good baseline metric with roughly ~174,000 gems available from RubyGems.org and 111B+ (yeah, billion) downloads.  If you look past ruby gems, the second most popular place that ruby is being utilized is with Chef.  The marketplace has roughly 4,000 cookbooks with roughly ~80,0000 maintainers

What is the Utility of Ruby

Ruby has some great utility when it comes to DevOps automation.  When building out an early DevOps-focused monitoring stack, we chose Sensu Core due to its configuration-driven and scalable design.  Most of the community-produced checks at that point were written in ruby which lent itself very well to building reusable consistent libraries that were well-tested.

Much like the Golang example above, I have also utilized ruby as an API middleware for doing data payload manipulations.  Prior to Docker supporting JSON File Logging, there were very long debates about what separation between log entries means between different programming languages.  Ruby was used in an environment where I was working into tail log output from containers and based on its configuration, properly parse and package logs to be sent to centralized logging systems upstream with additional metadata.

Learning Resources

DevOps with PHP

PHP has a soft spot in my heart as it was the first programming language that I ever picked up. This may color my analysis, but I feel that it deserves to be on the list.

I have utilized PHP as a preprocessor for data related to DevOps and automated provisioning. Abstracting business logic out of automation and utilizing the power of PHP and its dynamically typed variables makes it a perfect language to quickly munge a lot of data into something usable.

The big downside of PHP with DevOps is that it is an interpreted scripting language. This means; if your environment does not already run PHP everywhere, you will need to install PHP on all of the nodes you want to run code on. The general drawback here is security. You now have more patching and maintenance to perform just to run some automation.

If you already have PHP distributed throughout your environment, then PHP is a great option for building and running automation.

Here is an example of how you could use PHP to set the IP address of a CentOS server:


<?php

// Set the IP address of the server
$ip_address = "10.0.0.1";

// Set the network interface to use (e.g. eth0, eth1, etc.)
$interface = "eth0";

// Write the IP address to the network interface configuration file
$config_file = "/etc/sysconfig/network-scripts/ifcfg-$interface";
$config = "IPADDR=$ip_address\n";
file_put_contents($config_file, $config, FILE_APPEND);

// Restart the network service to apply the changes
exec("systemctl restart network");

echo "IP address successfully set to $ip_address on interface $interface.";

While an extremely basic example, it shows off how quickly you can not only setup this script but also parameterize it out to an entire fleet of servers.

How Big is the PHP Community

With WordPress being the dominant CMS powering the internet today, the community for PHP is very large. The enterprise space has not adopted PHP as broadly as languages like Java, you are sure to find PHP just about everywhere you look with frameworks like Laravel gaining traction.

At the time of writing, Packagist has around 370,000 packages available for download with 3.7M versions of those packages. PHP is also under active development with its main goals centered around getting rid of some of its past sins along with making PHP far more worthy of enterprise development.

What is the Utility of PHP

PHP (Hypertext Preprocessor) is a popular, general-purpose programming language that is commonly used for building web applications and dynamic websites. In the context of DevOps, PHP can be useful for a number of different tasks, including:

  • Web development: PHP is commonly used for building server-side scripts and web applications, and can be integrated with a range of frameworks and libraries to facilitate web development. DevOps teams can use PHP to build and maintain web-based systems and applications that are critical to the operation of a business or organization.
  • Automating tasks: PHP can be used to write scripts and automate tasks, such as interacting with APIs, processing data, and automating deployments. DevOps teams can use PHP to automate routine tasks and processes, freeing up time and resources for more complex or value-added tasks.
  • Monitoring and alerting: PHP can be used to build custom monitoring and alerting solutions, by integrating with monitoring and alerting tools or by interacting with system APIs. DevOps teams can use PHP to build custom monitoring and alerting systems that are tailored to the specific needs and requirements of their organization.
  • Integration: PHP can be used to integrate with other tools and systems within the DevOps ecosystem, such as version control systems, deployment tools, and configuration management tools. DevOps teams can use PHP to build custom integrations or plugins that enable them to more effectively and efficiently work with other tools and systems within their DevOps ecosystem.

Learning Resources

Frequently Asked Questions

What Languages do I Use Most Often?

When I am sitting down to take care of simple tasks or to write scripts for a problem I am trying to solve; I am most often looking at a language that can help me do data manipulation, develop operational automation, build infrastructure as code, or build a deployment pipeline for my projects.

What do I use for Data Manipulation?

For me, this is generally a quick and dirty task that I am not going to be releasing to production in any form. This website does a bunch of different data manipulation tasks under the covers as part of its pipeline. I will generally choose PHP (not on this list, but it is a majority of my pure software dev background) or Javascript.

Javascript is a fairly common language utilized in a multitude of DevOps environments that I would be able to quickly onboard someone with if needed. All of the tasks I am doing here are also fairly simple tasks in need of a simple language. I am not trying to do big data analytics, just mutate some links, move around some HTML, and soon do some automated testing.

What do I use for Infrastructure Management (or Infrastructure as Code)?

I have a Home Lab where the WYSIWG part of this website is hosted. I push all of my changes there as part of a continuous integration pipeline through Ansible. This means that I am living in the Python space.

It could be easy to argue that I am not really using Python here. I am for sure not a full-fledged Python programmer, but I have dug through a fair bit of the source code behind Kubespray to understand the real intentions of what it is trying to accomplish. This has also helped me utilize Ansible as a swiss army knife for any of my infrastructure management needs.

What do I use for Deployment Pipelines?

I currently utilize a mixture of Javascript and GitHub Actions and GitOps to build deployment pipelines. There are a variety of other languages I could be using, but these work well for me. As stated earlier, I will shift all of my data around with Javascript. From there, GitHub actions will run any builds that I need with any triggered deploys.

If the end result needs to go on the internet, I don't really need to deal with a full-weight object-oriented programming language, Linux servers/Linux systems, relational databases, business intelligence, or anything like that. It makes more sense for GitOps-style triggers to be in place to automagically move my code from the repo to the internet without manual intervention.

What is the Best General Purpose DevOps Programming Language?

I think you need to first ask, what is most native to my environment. If Node.JS is not installed on every single one of your servers, but you want to write all your scripts in Javascript, that is going to be tough.

If you are looking for a one-size fits all answer, then you are not going to find one. I would keep your mind open, try out new things, and see what fits the situation you are in.

What is the Best Language for DevOps?

In my opinion, the best general-purpose programming language (and the best language for DevOps) is going to be Python. While I am a fan of GoLang for numerous reasons, python has been battle-tested in this space since before DevOps was a coined methodology in the technology space. Other languages absolutely have some specific utility in the space, but I would consider Python to easily be the reigning champion of the best language for DevOps.

Should I use artificial intelligence to write my scripts?

I think AI is a great way to get through the more tedious parts of scriptwriting. I am not going to assert that AI will give you the most reliable software, but if you need to get something thrown out quickly or you need an example, AI is a great way to get something bootstrapped to continue to build on top of it.

Is there a set of "right programming languages" for DevOps?

No. The internal systems that you are working on should dictate whether you are building with compiled languages or interpreted languages.

Conclusion

As I stated at the beginning of this article, this is by no means a definitive list. I do not believe there is an answer to the question "Which Programming Language Should I Learn as a DevOps Engineer?". When moving into a DevOps position, you don't need to be a savant with any of the languages I have illustrated above, but be open to learning and evolving so you too can engage in some DevOps programming. Additionally, utilizing any of these languages for short lived DevOps style lifecycles doesn't mean you can skip best practices like continuous testing and code reviews.

This is a list of some of the tools that I utilized to build effective DevOps workflows and to enable the flow of delivery.  I utilize these tools at my job along with utilizing these tools in my home lab.  I believe that everyone could use a little bit of software development in their life.  Python, Javascript, Golang, or Ruby are really great places to start with languages because of their utility, communities, and ties to DevOps and DevOps tooling.

There are absolutely other programming languages that are not on this list. The most important thing to keep in mind is that writing code for manual actions matters more than the language. If you feel like I have left anything out that is very relevant to DevOps technologies and system administration, or are just common languages that are being utilized frequently, don't hesitate to contact me and I can update the list.