Variables in Declarative Programming

Can Mingir
Jun 23 · 2 min read
Image for post
Image for post

Variables carry value or reference to object, but what they represent in imperative (procedural) and declarative programming is different. Before diving into details, the one of main differences of two programming styles: declarative programming is strict to provide logical integrity, often in formal logic, but imperative programming doesn’t have to be because its control flow is managed by its programmers.

Let’s start with a simple example:

x = 1;
y = x + 1;

JavaScript engine creates a value in memory and links to variables, but when x is changed like x = 2, value of y stays as is because only memory location of x has changed. So, logical integrity is broken. However, if we apply the same example in declarative programming:

> x = 1
> y = x + 1
> x = 2
> y

So y has changed along with the x. When y = x + 1 is defined, declarative runtime is now responsible for providing logical integrity, means correcting y.

Declarative runtime doesn’t care technical representation (In this case, memory location) rather interested in logical meaning.

The same concept is applicable to object and its properties:

class User {}
user1 = new User()
user1.domain = ""
user1.username = "first-user" = user1.username + "@" + user1.domain is initialized as "", but changing user1.username doesn’t affect same as above because it is pointed to different memory block.

In declarative programming, it is not the case, in fact, the declaration can be initialized at the beginning, even before defining properties.

> class User {}
> user1 = new User()
> = user1.username + "@" + user1.domain
> user1.domain = ""
> user1.username = "first-user" stays undefined until all properties are defined.


Image for post
Image for post

While the declarative runtime provides logical integrity, it stores each statement as received so it doesn’t require external database.

Learn more at

Image for post
Image for post

Nucleoid is open source (Apache 2.0), a runtime environment that allows declarative programming written in ES6 (JavaScript) syntax. Since statements are declarative, the runtime provides logical integrity and persistency as hiding technical details.

Join project at


Declarative Runtime System

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store