Image for post
Image for post

Nucleoid is an open source (Apache 2.0), a runtime environment that provides logical integrity in declarative programming, and at the same time, it stores declarative statements so that it doesn’t require external database, in short it can be used as database.

Data Structure

Data structures are defined in declarative syntax. Let’s say is a variable, and by program requirements, must be:

  • less than 10 characters
  • first character is upper case
  • contains no underscore character

so, this can be 3 separate declarations:

> if( name.length > 10 ) {
throw "INVALID_SIZE"
}
> if( ! /[A-Z]/.test( name.charAt(0) …


Image for post
Image for post

In imperative (procedural) programming, it is common to have code files to compile and restart the programming runtime to get affected. So, in other words, adding new rules or learning new behaviors requires rewiring hard coded binaries. In addition, if it requires program to take different steps, it also has to go through the similar process with some configurations.

In declarative programming, the runtime works with declarative statements, which means statements don’t explain explicit steps, instead, it tells abstract logical intention. This important difference enables the declarative runtime to accept statements anytime without compiling or restarting, so that, it can build the context along with. …


Image for post
Image for post

The short and long answer is Graph.

This article explains mechanics inside of the runtime, for basic usage:

Nucleoid is a declarative runtime, which means instead of compiling code files, it accepts ES6 codes (JavaScript) in-flight and builds graph. The purpose of doing this is making connection between statements, so that, the runtime can draw its own control flow and provide logical conclusion. Let’s start with a simple example:

> a = 1
> b = a + 2
> c = b + 3


Yet, another article under this title, but this time it is a point of view from a programming runtime.

Image for post
Image for post

By dictionary definition, declarative programming is a style of building the structure and elements of computer programs that expresses the logic of a computation without describing its control flow¹. It is unfortunate that this kind definitions don’t explain how both approach impact developers to their daily routine.

Understanding behaviors of both runtime eases to solve the dilemma and gives concrete practices.

Let’s start with imperative runtime, which executes code lines as directed, and a developer is fully in charge of the flow. Some repetitive works might be automated within methods/tactics like OOP, AOP, etc., but at the end, it is a thing that developer have to manage and configure regardless. For example, you have an object, and every single time when its property is changed, you are to change update time when happened, so that, you have to call function. From an engineering stand point, it is not a best practice if hard coded everywhere because this increases number of code lines along with complexity, may end up with serious maintainability issues. However, if you defined , it automatically updates, so that, it shortcuts, but the theory stays the same as it requires developers to code and configure. …


Image for post
Image for post

Nucleoid is open source (Apache 2.0), a declarative runtime that learns from declarative statements and runs as building own control flow. This approach lower number of code lines required without need of compile, and at the same time, it stores statements so that it doesn’t require external database.

Reminder: There are no files in Nucleoid, just statements in JavaScript inserted in the system like SQL statements for database.

Let’s say we are targeting those features:

Question:

  • Question must be between 5 and 50 character long.
  • Question initializes its count and rate as 0.

Review:

  • Review must have a question assigned.
  • Review’a rate must be between 1 and…


Image for post
Image for post

Nucleoid is an open source (Apache 2.0), a declarative runtime that enables declarative programming in ES6 (JavaScript) syntax and runs as a runtime and database at the same time.

On Linux, Nucleoid runs a service with accepting HTTP request, and dependent on a configuration, it creates process tree with sub-processes as multiprocessing.

Install

First, it requires to add official PPA repository into local APT package list:

sudo apt-add-repository ppa:nucleoid/nucleoid

install as APT package:

sudo apt install nucleoid

This installs Nucleoid with its dependencies, and automatically starts at startup.

Terminal

Once the installation is complete, Nucleoid starts its terminal, which is available at IP address of the server on a browser. …


Image for post
Image for post

Well, you have to store somewhere.

Traditionally, a programming runtime processes functionalities, and as a result, it sends SQL statements to RDBMS. Even tough, there are alternative options arising in recent market such as NoSQL, Data Grid, in-memory database etc., they are still part of the same architecture of; programming runtime and persistence unit has to be separated.

Nucleoid is a declarative programming runtime with gathering both of processing and storing into the same runtime, so, it doesn’t require external database.

Nucleoid doesn’t require code files to compile, instead it receives ES6 (JavaScript) statements as declarative statements like databases receive SQL statements. …


Image for post
Image for post

It is better to start with agreeing on what declarative programming is because no argue that declarative programming is an abstract term with many definitions, and for this particular case, we are going to focus on the control flow.

We can easily roll out one, if the control flow is managed by programmers, it is imperative (procedural) programming. Here is the quick example for that:

account.balance = 1000;if( account.balance > 500 ) {
account.status = "OK"
} else {
account.status = "LOW"
}

It is typical if/else statement, but the problem is when


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 is changed like , value of stays as is because only memory location of has changed. So, logical integrity is broken. …


Hello World with Nucleoid
Hello World with Nucleoid

Nucleoid is a runtime environment that is designed for declarative programming so that it executes statements based on formal logic in syntax of ES6 (JavaScript). This enables the runtime to provide logical integrity and store statements so that it doesn’t require external database.

The runtime accepts statements any time without requiring compile or restart.

Here is the simplest form:

> a = 1
> b = a + 2
> a = 2
> b
4

Unlike in imperative language, when is defined, Nucleoid creates data graph with connections among statements, so when is changed, is updated by the runtime. …

About

Can Mingir

Contributor at Nucleoid

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