Layering rulesets in a pico

Once we have created a pico, we can begin to add rulesets to it. Each ruleset we install adds another  layer of behavior and persistent state.

A stateful web app in a pico

In an earlier post, we showed a simple web application in a pico. Each time that application is requested, it produces a different page, but it doesn't maintain state from one request to the next.

Here we will discuss a simple application that allows a visitor to select their favorite color. Once the selection has been made, each time the page will show that color, and allow them to change it.

This demonstrates the way the Pico Stack persists state without needing an external database.

Picos as the database

Picos can be used as the database layer of a web application. In fact, the pico developer UI is such a web application. So is our Manifold project* at Pico Labs. Both of these feature a front end running in the browser (written using the ReactJS framework (and so are single page applications**)).

Typically when using databases, an application program retrieves the data from a row into memory, thus bringing the data to the code. With picos, we bring the code to the data, by installing rulesets in each entity pico.

Are picos object-oriented?

We've established that a pico is an object. So, is KRL (the programming language used in picos) an object-oriented language?

Object-oriented languages can be divided into two camps: class-based and prototype-based. Among the class-based languages are Smalltalk, Java, etc. On the other hand, Objective C, JavaScript, etc. are prototype based.

A first web application in a pico

In the previous post we showed an example of a web application program which has HTML inside of it.

And, we showed a web application program which looks like HTML but contains bits of program inside of it.

Here we compare the latter program with one written for a pico.

HTML inside or outside?

A classic web application is a program that runs on the server and generates a character string which is valid HTML. It is hard to imagine a programming language that could not generate a string of characters, so any programming language should be able to do this.

Let's look at some examples.

Application delivery then and now

Traditionally, software applications have been written in some arcane textual language and machine translated into a binary language, with that bit stream installed on the machine where the application must run.

By "arcane" is meant that while the textual language is human-readable, it is only comprehensible to trained software professionals. The remaining steps of translation into binary and delivery and installation in a machine are also professional topics.

Web applications, from the beginning, are different.