Web Application Programming in PicoLisp
Tags: webdev, picolisp, lisp, functional
Published: 2022-01-08 09:26:56

Up to now, all scripts we have discussed were fairly academic. They are nice to get solid PicoLisp skills, and to get the basics right. Nevertheless, in order to create something *practical* we need some things more in our toolbox.

This series will fill up some of these gaps by explaining the fundamentals of **Web Application Programming in PicoLisp**. We will cover how to write basic programs that can be viewed in the web browser.

*We will not talk about application programming for mobile devices (maybe at a later point). If you're curious about that, check out the PicoLisp [PilBox](https://picolisp.com/wiki/?pilbox).*

------------------------

### What is a Web Application?

There might be several definitions. In my understanding, the most basic requirement is that the user (client) can access it through the **browser**, typically via the internet.

The main advantage is that the user **does not need a local PicoLisp installation** to access the app.

------------------------------------------

Which components do we need? The typical technology stack of a web application consist of three parts:
1.  The **front-end** which typically handles the presentation of the application and the user interface,
2. The **web server (back-end)** which handles the required infrastructure, actual content, and the communication with the database,
3. And the **database** itself.

The front-end is the part of the program which is displayed in the web browser. Modern browser "speak" HTML, CSS and and also provide a JavaScript runtime-environment. The communication between client and server is handled by the HTTP-protocol or its encrypted counterpart HTTPS.

------------------------

### Front-end focused design: Pros and cons

There is a trend nowadays to **handle a lot of the application logic in the front-end**, with help of JavaScript frameworks like React, VueJS and so on. The advantage is that it is easier to create a full-responsive design (i. e. design that looks and feels good on smartphone, notebook, large-screen TV). A side-effect is that many of these web apps look kind of the same, because they all use more or less the same modules - which helps to make the user get used to even really weird stuff.

![app.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1632315155024/YrVMHDPxr.png)

The downside is that these kind of apps are really heavy, and usually useless in a text browser. Some even cannot be viewed properly on older smartphones or with weak internet connection. And since the abstraction level is quite high, the developer usually has no idea what is really happening behind the scenes.

------------------------

### Web Application in PicoLisp - What it is (and what not)

As you might know if you followed the blog up to now, the core of the PicoLisp philosophy is extremely minimalistic. This also applies to the web application. 

You can write **client, server and the database code purely in PicoLisp**. Obviously the browser doesn't understand any PicoLisp at all, therefore the code is rendered server-side and then sent to the client (similar to other scripting languages like for example PHP). Like any other website, you can style the page using custom CSS and use the standard HTML elements. **JavaScript is not needed**, which can be interesting in environments where JavaScript is disabled due to security reasons.

One of the nice things in PicoLisp is that **it is so small and minimalistic that you can understand what is happening** (if you want to). Since the whole codebase is free, you can also extend and develop it based on your own needs, and it can be a great opportunity to learn and try out new things.

On the other hand, if you want to create a fancy, fully responsive web app in the shortest time possible, and you don't have any custom requirements for the logic behind, and you're also not curious to work more in PicoLisp, I admit that it might not be the right choice for you. In this case, you might be better off with VueJS or other frameworks that are trending at the moment.

------------------------

### What you should know already

I recommend that you have covered the basics of PicoLisp - for example by reading the "[Beginner's Series](https://picolisp-blog.hashnode.dev/series/getting-started)" - and you should also know the basics of HTML and CSS .


------------------------

### Sources
- https://picolisp.com/wiki/?web  
- https://xkcd.com/1174/