What is a 'headless' program or application?
If you’re a backend programmer, you most likely have encountered the term of headless applications (like headless Java or headless Chromium) many times. But what does headless actually mean?
headless means it runs without a graphical user interface (GUI). In most cases, headless applications are command line applications or applications that are interfaced from a programming language.
When you open your browser on your Desktop or Laptop, you’ll see the browser window pop up. This window is a graphical user interface (GUI). Unless you are living under a rock, you have had your fair share of experience with GUIs and know how convenient they can be sometimes.
However, especially in the professional IT world, command line user interfaces are also common - mostly, because they can be used on servers and local PCs with a screen alike, and they are much easier to automate than GUIs.
If you have worked in application development for some time, you might know that GUI applications require a huge number of incredibly complex libraries to run. On Linux that includes the X11 server (X11 is the system that displays and arranges all the windows and other graphical features on your screen), some utility libraries for X11 and possibly some libraries to be able to create the high-level user interfaces in use in most applications today: While high-level GUIs consist of buttons and *text inputs,*low-level GUIs consist of pixel, colored areas and callback functions (from which the buttons and text inputs are built of).
As said before, headless applications run without a GUI. Under the right circumstances, this has two main advantages:
- You don’t have to spend as much time developing a complex graphical user interface
- You can easily run it on a server
Why can you run headless applications on a server but not normal GUI applications?
Firstly, as we said before, GUIs require a large number of complex libraries and software infrastructure to be present on a server. On many servers (like most Linux servers), this software is not installed by default - because installing it would eat up valuable resources like system memory (RAM), hard drive space and the system would be hard to maintain.
Contrary to common belief, running a GUI infrastructure on Linux (i.e. X server plus some utilities) does not require a screen or a dedicated graphics card. See our post onĀ How to run X server using xserver-xorg-video-dummy driver on Ubuntu for an example on how to accomplish this.
Secondly, GUIs are hard to monitor, maintain and automate:
Imagine you have 25 servers running the same application on each of them. If that were a GUI application, you would have to look at 25 windows displaying the state of the application - not to mention the time spent to make all the windows display on your local screen reliably - or the development time spent to make the GUI
Using headless applications you can instead easily automate the task of monitoring the applications and therefore just display a summary on your local screen. Since you don’t have to spend time writing and maintaining GUIs, you can also spend your time more wisely.