logo2022
PicoLisp
a pragmatic programming language

  # scroll past some code to get the vibe!

  (dm save> (Win)   # from the picolisp clone of vi
     (when (: file)
        (unless (=T (car (info @)))
           (if (sys "CCRYPT" (: key))
              (pipe
                 (out '("ccrypt" "-e" "-ECCRYPT")
                    (mapc prinl (: text)) )
                 (out (: file) (echo)) )
              (out (: file) (mapc prinl (: text))) ) )
        (=: dirt (: undo))
        (for (This *CmdWin (setq This (: next)))
           (status) )
        (when (: syms)
           (and (find ext? @) (pico~dbSync))
           (in (: file)
              (while (and (setq "*X" (read)) (atom @))
                 (unless (= (val "*X") (setq "*V" (read)))
                    (set "*X" "*V") )
                 (until (= '(=======) (setq "*K" (read)))
                    (unless (= (get "*X" "*K") (setq "*V" (read)))
                       (put "*X" "*K" "*V") ) ) ) )
           (when (find ext? (: syms))
              (commit 'pico~upd)
              (syms> This (: syms)) ) ) )
     (on *StatNm) )

Features

The following features make PicoLisp a pleasant language to work with: Besides, it's free (MIT/X11 License). The documentation is pretty great, too.

An Integrated Database

Database functionality is built into the core, making PicoLisp a language for querying and manipulating databases. For that, PicoLisp includes a built-in application framework and Prolog engine so you can create, organize, inspect and change (and even build a fancy UI for) your data - all with a uniform and concise syntax.

When it's time to scale, PicoLisp has you covered - create and query remote databases as needed with the standard library. It's simple and powerful, and makes few assumptions about your application architecture.

Awesome C / Java interop

Leverage any C library function, manipulate C data structures in memory, even call Lisp functions from C code.

  # call the 'MD5' function from 'libcrypto.so'

  (let Str "The quick brown fox jumped over the lazy dog's back"
     (pack
        (mapcar '((B) (pad 2 (hex B)))
           (native "libcrypto.so" "MD5"
             '(B . 16) Str (length Str) '(NIL (16)) ) ) ) )

  -> "E38CA1D920C4B8B8D3946B2C72F01680"

Interface directly to a running JVM for dynamic access to everything Java.

  # a simple Swing UI

  (let [Frame (java "javax.swing.JFrame" T "Bye-Frame")
        Button (java "javax.swing.JButton" T "OK") ]
     (java Frame 'add "South" Button)
     (java Button 'addActionListener
        (interface Button "java.awt.event.ActionListener"
           'actionPerformed '((Ev) (bye)) ) )
     (java Frame 'setSize 100 60)
     (java Frame 'setVisible T) )

Now that's swingin' harder than a Charlie Parker record!

Effortless Scripting

PicoLisp provides powerful primitives for many common tasks. Manage connections and streams, pipe data to and from external programs, run tasks in parallel - all with ease! Here's a script which extracts the name, date and size of the latest official PicoLisp release from the download page and prints it to standard output:

  #!/usr/bin/picolisp /usr/lib/picolisp/lib.l

  (load "@lib/misc.l" "@lib/http.l")

  (use (@Date @Name @Size)
     (when
        (match
           '(@Date ~(chop " - <a href=\"") @Name "\"" ">"
               @Name ~(chop "</a> (") @Size )
           (client "software-lab.de" 80 "down.html"
              (from "Release Archive")
              (from "<li>")
              (till ",") ) )
        (prinl @Name)
        (prinl @Date " -- " @Size) ) )

  (bye)

Expressiveness

PicoLisp programs are often much shorter than equivalent programs written in other languages. Examples of various programming tasks and their solutions can be found at rosettacode.org.

Efficiency

PicoLisp uses very little memory, on disk as well as in memory (heap space). The tarball size of the whole system - including the interpreter, database, HTTP server, HTML / JavaScript application framework, and the debugger - is just a few hundred kilobytes.

Flexibility

It's a Lisp, afterall - a language capable of reprogramming itself. Into functional programming? Rock on. OOP? PicoLisp has an elegant, unobtrusive, totally optional object system. Explore a syntax of nested function calls, bend the language to the task at hand, metaprogram yourself to the moon. We'll help you build a rocket.

Install PicoLisp

on Linux
The easiest way is to grab a (slightly outdated) package from your system, e.g.

  $ sudo apt install picolisp

The best way is to grab the latest version - [pil21.tgz] - unpack it, and follow the instructions from the INSTALL file.
on Windows Subsystem for Linux (WSL)
See here: Install PicoLisp on Windows 10
on macOS
Installing PicoLisp on MacOS is now possible too, as Pil21 is based on LLVM (and no longer on Gnu ASM).

An alternative repository provides code that can be built on macOS with the following instructions.

http://picolisp.com/wiki/?home

08apr22    abu