Disambiguating Jamstack and MACH

illustrations illustrations illustrations illustrations illustrations illustrations illustrations
post-thumb

Published on 4 August 2022 by Andrew Owen (4 minutes)

Earlier this year, I gave a lightning talk on API-first. I’ve been planning write an article on it ever since, but first I wanted to lay the groundwork. Last week I covered event-driven architectures. That was quite a lot to digest. Today’s article is a quick overview of what the cryptically-named Jamstack and MACH are really all about.

Jamstack

The J in Jamstack stands for JavaScript. If you try running modern applications on a 12-year-old computer, you’ll find most of them run just fine. The exception is the browser. Even with a wired connection, many web pages load at a crawl. The reason for this is twofold. Those web pages have become full-blown applications, and they are written in an interpreted language (JavaScript) that requires a lot of processing power to run at an acceptable speed.

Programmers of classical languages hate JavaScript because it’s prototype-based, dynamic and weakly typed (among other complaints). It’s also the number one most in-demand programming language in 2022 according to a number of independent surveys. JSLint can help you write better JavaScript and JSMin can minify your code before deployment. These tools were created by Douglas Crockford. I’d recommend his books “JavaScript: The Good Parts” for programmers coming to JavaScript for the first time, and “How JavaScript Works” for experienced JavaScript programmers.

The A in Jamstack stands for APIs, which in turn is short for web APIs. There are a variety of different web APIs but currently, RESTful APIs seem to be the most popular. REST is an acronym for REpresentational State Transfer, which in real terms typically means using HTTP methods to pass parameters in JSON (JavaScript Object Notation) format. Unsurprisingly, JSON was also created by Crockford.

The M in Jamstack stands for Markup: information included in an electronic document that’s distinct from its content. Traditionally, markup meant HTML and XML. But now it’s as likely to refer to YAML (Yet Another Markup Language) or Markdown. These are much simpler, and therefore easier for humans to read, than other markup languages.

Markdown is increasingly being used for software documentation, but you’ll also find it used in static site generators (SSGs) such as Hugo and Gatsby. SSGs combine Markdown with templates to make it easy to spin up a website with minimal effort. They integrate with headless content management system (CMS) providers such Forestry and automated deployment solutions such as Netlify that connect to cloud source repositories such as GitHub.

Those are the technologies I used to build this website. You can read about it in this articles. That covers the web presentation side. But that’s only one component of a software solution. The old way of doing things was to create monolithic software that customers would host on their own hardware, with gaps of months or even years between updates. In some respects, the new way of doing things is simply a return to distributed computing.

The MACH Alliance

Named for the acronym it created, the MACH Alliance exists to promote a particular way of doing things. MACH stands for Microservices, API-first, Cloud-native, Headless. I covered microservices in last week’s article on event driven architectures (which are a step beyond MACH). As stated in the introduction, I’ll cover API-first next week, but the APIs in question are typically the ones I described in relation to Jamstack.

Cloud-native means that software solutions are hosted by cloud providers such as Amazon, Google and Microsoft rather than on on-premises servers. Headless means that the content is separate from the presentation.

A note on Node.js

When I originally published this, I didn’t cover JavaScript engines. While JavaScript is technically an interpreted language, in practice modern JavaScript engines such as Google’s V8 Engine use just-in-time (JIT) compilation. This development led to Ryan Dahl creating Node.js to run JavaScript code outside the browser (for command line tools and server-side scripting). Node.js has an event-driven architecture (which you can read about in the linked article). Isaac Schlueter created a package manager (npm). Node.js apps are often paired with databases that support JSON, such as MongoDB. I’ll leave it there for now, but I may go into more detail on Node.js in a future article.

Image: Original by Benson Kua.