Pros and Cons of PicoLisp Unfolded
...presented by the "Tractatus Pico-Blaesicus" Web App

Search for a command to run...
...presented by the "Tractatus Pico-Blaesicus" Web App

Thank you and keep up the good work.
I might have to relearn, reinstall and log into the irc channel.
I have an idea for a writing tool that starts with a boundaried box of a settable character line length, a text editor, a dictionary and thesaurus.
There appear, to my mind, to be several line lengths that carry very specific attributes in relation to tone and impact of writing. I want to explore this locally on my machine with restricted boundaries that draw from alternative and substituted wording based on a lookup which causes more mindful writing due to shading and nuance that doesn't just fall out of the mix in free wheeling and pantsing across a page.
The other part of this is your paradigm, the box you are in based on the abstraction you use to make the ones and zeroes run around on former rocks with captured lightning at your finger tips.
LISP, despite the fact I don't have the facility, immediately shone as the almost perfect abstraction tool. I watched a friend bootstrap his meagre scripting and rudimentary C skills onto a LISP scripting language also with an interpreter into an app for data base search in his company that took the well paid dev team six months to duplicate, mostly, for functionality.
This is for users who want to start with PicoLisp from scratch. This series will cover installation, basic concepts, syntax, how to use the REPL, create simple scripts, read the docs and debug.
Form follows Function
In our previous post, we introduced how to utilize Discrete Event Simulation (DES) in PicoLisp. Now, let's explore another application: a railroad model simulation that includes tracks and trains. The visualization is ASCII-based, so feel free to unl...

The Dining Philosophers

In this post, we will introduce the concept of co-routines and how they are handled in PicoLisp. This will be the foundation for the subsequent posts on Discrete Event Simulation and finally a couple of examples, including an ASCII model railway simu...

One of the many nice things of PicoLisp is that it comes with a built-in database. This makes it easy to collect and store our own data, for example via a mobile app. But not all data is best represented in tables and lists: sometimes a colorful litt...

In the last two posts, we have built a little app that shows the current location and displays the nearest ice cream shops: https://picolisp-explored.com/an-openstreetmap-app-written-in-picolisp-pt-1 https://picolisp-explored.com/an-openstreetmap-ap...

This article will present you the pros and cons of the programming language PicoLisp. It will be only a rough overview - we will come back to all of these points in more detail later.
Secondly, we will take a look at a very small PicoLisp web app to get a first impression how the language looks like.
The article is inspired by the famous "Tractatus Logico-Philosophicus" of the German philosopher Ludwig Wittgenstein.
In the original Tractatus, each proposition is a kind of declarative statement that is further elaborated on sub-levels. If you are interested in philosophy, you might know the first few sentences:
1 The world is all that is the case.
1.1 The world is the totality of facts, not of things.
1.11 The world is determined by the facts, and by their being all the facts.
And so on and so forth. Very interesting, and very hard to read - but this just as a side note, because we want to talk about PicoLisp.
There is a little fun web app inspired by the Tractatus, which lists the pros and cons of PicoLisp: The Tractatus Pico Blaesicus. (The Latin word "blaesus" means "lisping" 😀) Let's take a look at it - first at the content, then at the sources.
I recommend to open the link in another browser tab while reading this article.

Similarly to the Tractatus, it contains items that unfold the sublevels.
Let's start with the good news and click on "cons". PicoLisp is:
Well, anybody can say that, but what is meant by that? Let's open up the next level.

There are still more sublevels which elaborate the statements further. You get the principle - feel free to check out explore the sublayers on your own.
Nothing is perfect, here are the cons:
Or, to be more precise:

Again, feel free to explore the sublayers on your own. We will not go into detail about the content now, since each of these items is worth its own post.
The Tractatus Pico-Blaesicus is also a nice example about the strength of PicoLisp: to write a dynamically rendering HTML page with extremely few lines of code.
Let's download the code and look at it with the eyes of someone who doesn't know any PicoLisp at all.
To get the source code, type
$ wget https://gitlab.com/picolisp-blog/single-plage-scripts/-/raw/main/tractatus/tractatus.l
or open this link in the browser and download it manually.
In the folder where the script has downloaded, type
$ pil tractatus.l
and point your browser to http://localhost:8080. You should see the page rendering like this - it works!

(if you haven't installed PicoLisp yet, read this first).
The second purpose of this article is to give an impression how PicoLisp looks like. If you are only used to Python or JavaScript, it might look very foreign to you at first.
So here is a challenge for you: Try to take a look at the source code and figure out roughly what is going on! (no details!)
level functionLet's start with the most obvious: starting from line 67, we find the actual text.
# Text
Pro
Simple
Simple NOT in the sense of "small number of features"
...
Since the numbering is missing, there must be some algorithm that "counts" the spaces and converts it to numbering. We can guess that this is done using the level function, where we find the term sp? which could maybe represent the "space" characters:
# Content
(de level (Lst)
(for (I . C) Lst
(NIL (sp? C) I) ) )
menu FunctionThelevel-function gets called within a certain menu-function:
[<menu>
~(let (L (0) L1 (prog (skip "#") (line)) L2 (line))
(recur (L)
...
(let I (level L1)
(loop
...
We see two variables, L1 and L2 which might be two consecutive lines. The program loops over L1 and L2 and calls the level function on them. And we also know the result: there will be clickable items that can expand and show subitems. So this reminds us... of a navigation menu, right?
The code transforms the text items to a navigation menu, which are then rendered to an HTML page.
If you did some web programming before, you know that the browser usually expect a HTML and also a CSS file. However, we only have one single page of PicoLisp...?!
This is because PicoLisp creates everything from the source code. The browser "thinks" that it gets a css file, but in reality it is only a function.
# CSS
(de tractatus.css ()
(httpHead "text/css" 86400 "!tractatus.css")
(ht:Out *Chunked
(prinl "html {background-color: #eee}")
(prinl "body {margin: auto; max-width: 96ex; border: 1px solid #bbb; font: 20px serif; background-color: #ffd; padding: 2em 5% 4em 5%}")
...
In the end, everything get mapped to a HTML text stream that is displayed in the browser using the function httpEcho:
# Source
(de tractatus.l ()
(httpEcho `(pack (car (file)) (cadr (file))) "text/octet-stream" 3600 T) )
If there is a browser client, then there must also be a server. And right, at the very end of the script, we can also find the server, listening on port 8080:
(server (or (format (sys "PORT")) 8080) "!tractatus")
Now we also know why we can access the script through localhost:8080.
With this, we got a first impression of the pros and cons on a very rough level. We will keep it in mind for further posts.
Also, we have seen our first PicoLisp script: Without going too much in detail, we see that we can create the client, server and content in just a few lines of code.
If you are interested to understand how this works exactly, stay tuned for the "Getting Started" and "Web Application Basics"-Tutorials. Of course, you can also check out the documentation and tutorials on the PicoLisp-site by yourself.
https://picolisp.com/tractatus/!tractatus
https://en.wikipedia.org/wiki/Tractatus_Logico-Philosophicus