How Nucleoid Learns
Can Mingir
Posted on July 23, 2020
The short and long answer is Graph.
This article explains mechanics inside of the runtime, for basic usage:
Hello World with Nucleoid
Can Mingir for Nucleoid ・ Jun 22 '20
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
Each statement of a = 1
, b = a + 2
and c = b + 3
is received into system in separate times, since a
is part of b
's definition, the runtime draws dependency line between two, and when a
is changed, the runtime automatically updates value of b
, and rest of follows the same for c
so on and so forth.
We can expand the example with adding if
statement like:
> if ( c > 10 ) { d = true } else { d = false }
> a = 6
> d
true
In this case, Nucleoid runtime also considers if
statement as a data and includes in the graph along with its true
and false
blocks, and changing a
triggers chain event through all the way to variable d
by the runtime. As a result, the runtime respects declarative statements and conclude logical integrity.
In this paradigm, there is no segregation regarding what data is or not, instead approaches how data is related with others so that any type of data including business rules can be added without requiring any additional actions such as compiling, configuring, restarting as a result of plasticity.
The same concept can be applied to class/object relationships as well:
> class Student {}
> student1 = new Student()
> student1.firstName = "First"
> student2.LastName = "Last"
In this case, a relationship between Student
and student1
is class and instance as well as the graph carries properties of instance. In addition, the graph keeps all relationship among statements in order to provide logical integrity as receiving more statements. For example, if there is class-level declaration, it will be still part of the graph:
> Student.fullName = Student.firstName + " " + Student.lastName
Class-level declaration adds more edges in graph in order to fulfill logical integrity. So, student.fullName
is derivated to student1.fullName
since student1
is one instance of Student
, so that, the runtime calculates fullName
property using firstName
and lastName
properties.
DBless with Nucleoid runtime
Can Mingir for Nucleoid ・ Jun 29 '20
As conclusion, Nucleoid follows steps as:
- Receive ES6 (JavaScript) code without compile or restart
- Builds Graph based on relationship of statements
- Runs statement in the state
- Provide logical integrity based on information in graph
- Stores statements so that it doesn’t require external database
- or roll back transaction if any error occurs
Nucleoid is an 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.
Learn more at nucleoid.org/tutorial
Posted on July 23, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.