Hello, declarative world

A computer is an imperative machine. Its CPU reads a list of instructions and performs one operation after another, with each operation modifying the state of its registers and memory. But that doesn’t mean we always have to write our computer programs as imperative step-by-step recipes; imperative programs are often too low-level and overspecified, which is why we’re generally terrible at writing them.

One interesting alternative is declarative programming, where we focus on describing a problem instead of listing exactly what steps to take to solve it. That idea’s been around for a long time but has recently begun to reappear everywhere.

In this article I want to encourage you to think outside of your normal programming habits. I’ll present a more abstract and declarative style called relational programming, and show you how to implement a minimal relational language in Ruby.

This article is based on a talk I gave at Joy of Coding 2015 and the London Ruby User Group. The video of the talk is below, and the slides are also available. All the Ruby code is on GitHub, and James Coglan has ported it to ES6, Haskell and Python.

Read in full here:

https://tomstu.art/hello-declarative-world

This thread was posted by one of our members via one of our news source trackers.

1 Like

Corresponding tweet for this thread:

Share link for this tweet.

1 Like