Paolo Amoroso's Journal

lisp

Now that I'm back to Lisp I'm actively exploring Interlisp as a Common Lisp environment too.

But to code in Common Lisp also on my Crostini Linux system, the Linux container of chromeOS I use on a Chromebox, I'm setting up a suitable development environment. In addition to console programs I want to write GUI applications with McCLIM.

The Common Lisp implementation I chose, SBCL, is a no brainer given its features, performance, and active maintenance. As for the development environment I won't go with the default on Linux, Emacs. Although I used Emacs for years and loved it, now it feels overkill and I'd prefer not to re-learn its intricacies.

Instead I'm using Lem, a great Emacs-like IDE written in Common Lisp with a user interface and keybindings similar to those of Emacs and SLIME. Thus my familiarity with Emacs is enough to get me up to speed. A nice side effect of Lem's implementation language is the IDE can be configured and extended in Common Lisp, which I feel more at home with than Emacs Lisp.

Despite some initial installation issues Lem works well on Crostini, is fast, and has a nice SDL2 backend. I really like the IDE.

If I need to write or run some Common Lisp code on my Raspberry Pi 400 I can easily replicate this setup there.

#CommonLisp #Lisp

Discuss... Email | Reply @amoroso@fosstodon.org

A few days ago I blogged on why I cancelled my paid plan to Replit.

It was a short personal note to record my decision as I often do to document my experiences with tools and products, possibly of interest to the few dozen regulars per day who read my blog.

A day on the home page of Hacker News, over 170 votes, almost 150 comments, and nearly 20,000 views later, it became clear I underestimated the impact of the post. I should have expected mixing parting ways with a product by a red hot startup like Replit, and a red hot technology like AI, could generate some attention.

The discussion in the comments on Hacker News is pretty interesting and I can't do more than reply to a few. But I'd like to address a couple of issues raised in the comments.

Some readers wondered whether I feel entitled to great products at little or no cost, thus making it difficult for companies to survive and innovate. I'd actually be happy to pay for Replit at the new higher price. But my shift to Lisp, and the diverging direction of Replit's evolution, widen a gap between cost and benefits that reduces the value of Replit to me, possibly even at the old lower price.

Others pointed out I'm a niche user while Replit caters to an audience of mainstream developers with different needs. This is true. Replit's features make it a great value for those users such as web developers. For example, deploying a web app by just listening to a port is beyond magical. But this is not what I need.

Replit cofounder Faris Masad also read my post and invited me to a video call. He gave me the opportunity — thanks! — to elaborate on the issues raised in the post and share my feedback on what Replit is missing for Lisp. Faris listened carefully, as he said improving Lisp support can improve the experience also with other languages.

This conversation and the other feedback convinced me to follow more closely the evolution of Replit and reevaluate my decision.

#development #Lisp

Discuss... Email | Reply @amoroso@fosstodon.org

I cancelled my annual Replit Hacker plan and I'll let it lapse at the end of December of 2023.

Replit is a popular and growing multi language development environment in the cloud. I've been subscribing to the Hacker plan for the past few years and it worked well for my Python projects, as such an online environment is a good match for my chromeOS lifestyle. But two changes made me reconsider the value of the product.

The first is Replit changed its paid tiers by raising the price of my plan and removing some features. I actually saw it coming when Replit began receiving massive funding by major investors, who are likely pressuring the company to reduce costs and turn profits. Still, this left a sour taste as it felt like a bait and switch.

The other change is my shift of focus back to Lisp, the programming language I love most and know best.

Replit doesn't work well with a highly interactive language like Lisp. It doesn't directly support any Lisp dialects and its default code editor provides little or no integration with a running Lisp image. Moreover, the files created or uploaded outside of the editor are often not preserved across sessions. If I have to install and maintain a full Lisp system in the Linux shell of a Replit workspace, I might as well install it locally on my desktop computer.

Finally, like other development tool vendors, Replit is doubling down on AI coding features which affect the cost of paid plans. But I'm not interested in this as the whole point of my hobby programming is to write all the code myself and learn from the experience.

Update

This post was shared on Hacker News and I blogged about the reactions.

#development #Python #Lisp

Discuss... Email | Reply @amoroso@fosstodon.org

Although Medley's documentation and published material is scattered across several archives and sources, and doesn't cover all the system facilities, once I find the right document I get most of the information I need on a specific feature.

But sometimes the information is not up to date because Medley is still under development after so many decades.

I bumped into such a case when experimenting with TableBrowser, Medley's tabular data browser tool on which the system file browser is built. Other applications can access and control from Lisp TableBrowser, which is a reusable component with an API.

Before program development with the API, TableBrowser requires setting up a specific environment by loading a source file with some declarations, which are not needed when running compiled applications. The Lisp Library Packages manual explains how to set up the environment in section “Installation” of the “TABLEBROWSER” chapter on page 283 of the PDF. Here the manual provides the File Manager commands to add to the source file of an application that uses TableBrowser:

(FILES (SYSLOAD) TABLEBROWSER)
(DECLARE: EVAL@COMPILE DONTCOPY
     (FILES (SOURCE) TABLEBROWSERDECLS)

But in spite of following these instructions I got an error when calling TableBrowser functions.

It turns out that, as a result of the recent modernization work the Medley Interlisp Project is doing, some source files were rearranged and moved. So now all it takes to set up the Lisp environment for development with TableBrowser is the form (LOADCOMP 'TABLEBROWSER), for example in the coms of the program under development.

#Interlisp #Lisp

Discuss... Email | Reply @amoroso@fosstodon.org

Since encountering Medley I gained considerable experience with Interlisp. Medley Interlisp is a project for preserving, reviving, and modernizing the Interlisp-D software development environment of the Lisp Machines Xerox created at PARC.

Nine months later I know enough to find my way around and confidently use most of the major system tools and features.

I read all the available documentation, books, and publications, so I know where to look for information. And I undertook Interlisp programming projects such as Stringscope, Braincons, Sysrama, and Femtounit.

Now I'm ready to explore Medley as a Common Lisp development environment.

Although most of the system, facilities, and tools are written in and designed around Interlisp, the companies that maintained and marketed Medley over time partially implemented Common Lisp and integrated it with the environment. The completion level of the implementation is somewhere between CLtL1 and CLtL2, plus CLOS via Portable Common Loops (PCL).

Motivation

I want to widen this experience to Common Lisp.

I'll leverage the more advanced Lisp dialect and interface with Interlisp's facilities as an application platform that comprises a rich set of libraries and tools such a window system, graphics primitives, menu facilities, and GUI controls for building applications. Each world can interoperate with the other, so Common Lisp functions can call Interlisp ones and the other way around.

Developing Common Lisp programs with Medley is both my goal and a way of achieving it through practice. Medley is an ideal self-contained computing universe for my personal projects and Common Lisp greatly enchances its toolbox.

Tools

The main tools for developing Common Lisp code are the same as for Interlisp: the SEdit structure editor for writing code; the File Manager, a make-like tool for tracking changes to Lisp objects in the running image and saving them to files; and the Executive (or Exec), the Lisp listener.

However, the workflow is subtly different.

In some cases taking advantage of the integration with Medley involves different steps for Common Lisp code. For example, defining and changing packages so that the File Manager notices and tracks them needs to be done in a certain order. And there are Medley extensions to the package forms.

When working with Common Lisp I open at least two Execs, a Common Lisp and an Interlisp one. The former is for testing, running, and evaluating Common Lisp code.

The Interlisp Exec is for launching system tools and interacting with the File Manager. Since all the symbols of SEdit, the File Manager, and other system tools are in the IL Interlisp package, in an Interlisp Exec it's not necessary to add package qualifiers to symbols all the time.

Exec commands such as DIR and CD work the same in both Execs.

Documentation

Medley's Common Lisp features aren't documented in the Interlisp Reference Manual, the main information source about the system. The reason is the companies that distributed and maintained the product ceased operations before the work on implementing and documenting Common Lisp was completed.

I found only a couple of good sources on Common Lisp under Medley.

The implementation notes and the release notes of Lyric, the music-themed codename of one of Interlisp-D's versions, provide an overview of the integration between Common Lisp and Medley. The release notes of Medley 1.0, a later version, expand on this. Issue 5 of HOTLINE!, a newsletter Xerox published for its Lisp customers, has useful step by step examples of creating and managing Common Lisp packages the Medley way.

Some of the system code of Medley is written in Common Lisp and may be a source of usage examples and idioms. I'm also writing Common Lisp code snippets to test my understanding of the integration with Medley.

#CommonLisp #Interlisp #Lisp

Discuss... Email | Reply @amoroso@fosstodon.org

Planet Python carried out my request to remove my blog from the aggregator. Now their feed no longer syndicates my posts about Python, which I'll no longer write much about.

Planet Python is an aggregator of blogs, podcasts, and other resources of interest to the Python community. In late 2019 I submitted the feed of Python posts of my old blog, later updating it to point to my new blog.

I was learning the language and sharing on the blog my experience with coding projects and other experiences. But although I had great fun with Python and accomplished a lot I'm proud of, my interest waned as I rediscovered my old love Lisp.

I encountered Scheme in the early 1990s at an introductory computer science class based on Structure and Interpretation of Computer Programs, fell in love with the Lisp family of languages, and learned Common Lisp and Emacs Lisp. Lisp became my only language until the early 2010s when real life claimed my time and attention. Near the end of the decade, intrigued by Python and its massive ecosystem, I decided to learn it.

At the beginning of 2023 I discovered Medley Interlisp and got hooked.

Using Interlisp and its environment made me realize Lisp is the language that comes most natural to me, I'm most productive with, and gives me joy and not just fun. I never mastered and enjoyed other languages to the level of Lisp. And my projects turned out not to need Python's batteries.

I'll still maintain a reading knowledge of Python and keep up with its ecosystem. But this journey made me readjust my focus on Lisp, now my only language.

It's good to be back home.

#Interlisp #Python #Lisp #blogging

Discuss... Email | Reply @amoroso@fosstodon.org

I integrated Femtounit with the File Manager by defining the new type TESTS for Femtounit tests and redefining DEFTEST in terms of it.

It turns out it's not a good idea as the tests get duplicated. The DEFTEST macro expands into a DEFINEQ function definition and the File Manager notices both, the DEFTEST form of type TESTS and the function of type FNS.

The fix seemed simple, assigning tests to an existing type such as FNS. First I removed TESTS with (DELDEF 'TESTS 'DEFINE-TYPES), then replaced the type argument TESTS with FNS in the XCL:DEFDEFINER form. But when I tried to edit a sample test TEST.PLUS for the PLUS function with (ED 'TEST.PLUS :DONTWAIT), SEdit quit with the error:

Warning: Couldn't find a hash-table for FNS definitions.
One will be created.
Could not find fns definition for TEST.PLUS.
Could not find fns definition for
TEST.PLUS

Back to the drawing board.

#femtounit #Interlisp #Lisp

Discuss... Email | Reply @amoroso@fosstodon.org

I integrated Femtounit, my Interlisp unit test framework, with the File Manager and the SEdit structure editor.

To achieve this I defined the new File Manager type TESTS for Femtounit tests and redefined DEFTEST in terms of it, then tweaked the code formatting of tests in SEdit. Now the system notices and keeps track of new and modified tests.

Here's the File Manager type menu, which SEdit pops up when opening a test, with the DEFTEST option highlighted under TESTS:

Interlisp File Manager menu with the Femtounit types.

Also, now SEdit handles and properly formats test definitions like this of a function SQUARE to compute the square of its argument:

SEdit editing a Femtounit unit test definition on Interlisp.

Implementing the new features was much easier than expected.

The traditional way of adding types to the File Manager, described in the Interlisp Reference Manual, involves writing a dozen functions for most of which it's not clear how they're supposed to work. Medley 1.0 added support for two easy to use File Manager type defining forms that replace all that, XCL:DEF-DEFINE-TYPE and XCL:DEFDEFINER. This code is all it took for Femtounit's new TESTS type:

(XCL:DEF-DEFINE-TYPE TESTS "Femtounit unit tests")

(XCL:DEFDEFINER (DEFTEST (:PROTOTYPE
                            (LAMBDA (NAME)
                              (AND (LITATOM NAME)
                                   `(DEFTEST ,NAME ("Arg List")
                                      "Body")))))
                TESTS
                (NAME PARAMETERS &BODY BODY)
   `(DEFINEQ (,NAME ,PARAMETERS
      (LET ((FTU.TEST.NAME (APPEND FTU.TEST.NAME (LIST ',NAME]
        ,@BODY))))

This additional tweak makes SEdit format and indent DEFTEST unit test definitions the same way as DEFUN function definitions in Common Lisp:

(SEDIT:DEF-LIST-FORMAT DEFTEST CL:DEFUN)

The simplified process is not discussed in the Interlisp Reference Manual, where I'd have expected, but in a more obscure source, the Medley 1.0 release notes from page 52 of the PDF document. My proactive reading of all the documentation paid off as it let me spot such crucial information and save a lot of work.

#femtounit #Interlisp #Lisp

Discuss... Email | Reply @amoroso@fosstodon.org

I'm writing another Interlisp program, Sysrama, an Interlisp documentation tool for presenting information on the Lisp objects of a program. It produces reports that list the types and signatures of functions, the fields of records, global variables, property lists, Executive commands, and more.

The way I reference the details of Lisp objects when coding gave me the idea for Sysrama.

I often forget the names and signatures of the functions or the names of the record fields I need. Browsing or looking up the code for referencing them is a source of friction.

Interlisp comes with the powerful program analysys tool Masterscope that gives its best with answering specific questions on the internals of programs. But it has a steep learning curve and it doesn't provide the kind of big picture view I seek. Instead, I wanted a simple tool for producing an overview of the main Lisp objects in a program.

This is a sample report Sysrama prints on another of my Interlisp programs, Stringscope:

Sample output of the Sysrama documentation tool for Interlisp.

The main sections group objects under the same File Manager types, such as FNS or RECORDS. This is because Sysrama can extract information only from programs under File Manager control.

Suppose you want to analyze the Lisp program MYPROG. Once Sysrama is in memory, load MYPROG:

(LOAD 'MYPROG)

To have Sysrama print a report with information on MYPROG evaluate:

(SUMMARIZE 'MYPROG)

You can narrow down the information to specific File Manager types such as FNS and RECORDS:

(SUMMARIZE 'MYPROG '(FNS RECORDS))

or to specific objects like the function MYFUN:

(SUMMARIZE 'MYPROG 'FNS 'MYFUN)

More documentation is available at the project repo.

Sysrama already does most of what I had in mind but I'll implement a few more features.

I'll tweak the reports to show more information on some Lisp objects. And I'll add the ability to redirect the output to a scrollable window rather than to the primary output stream. By default Interlisp windows don't save the output history and can't be scrolled back, so such a feature will help review reports that don't fit in a window.

#sysrama #Interlisp #Lisp

Discuss... Email | Reply @amoroso@fosstodon.org

Medley is a rich development environment but it's missing a test framework. Or so I thought. To fill the supposed gap I wrote Femtounit, a tiny — hence femto — unit test framework for Interlisp.

I wanted a small framework simple to port to or write for Interlisp, yet useful in practice. At less than a couple dozen lines of code, Femtounit took very little effort to design and write as it's based on the PCL test framework Peter Seibel described in Chapter 9 of his book Practical Common Lisp.

I reused much of Peter's design and code, adapting it to Interlisp and tweaking the reporting of tests. Femtounit outputs a single period character for every passed test, unlike the full report his framework prints.

Using Femtounit looks like this:

Usage of the Femtounit unit test framework for Interlisp.

Suppose you want to test this function that returns the square of its argument:

(DEFINEQ (SQUARE (X) (TIMES X X)))

You may define a TEST.SQUARE test function like this:

(DEFTEST TEST.SQUARE ()
  (CHECK.EXPECT (EQP (SQUARE 1) 1)
                (EQP (SQUARE 2) 4)
                (EQP (SQUARE 3) 9)
                (EQP (SQUARE 4) 16)))

To run the tests, just call the function:

(TEST.SQUARE)

which will print a period character for every passed test:

....

Some documentation is at the project repo.

After I finished the initial code of Femtounit, Larry Masinter pointed out Medley does have a test framework, and quite an advanced one. This system, which the Medley documentation simply calls test system and is much more than a framework, was originally designed to test Interlisp and its environment. The code is now in one of the Medley repos.

I thought I explored every nook and cranny of Medley and its documentation, yet I missed the test system. The system is interesting in itself and I'll use it for most of my code.

But Femtounit is a fun little learning project I still want to proceed with. It'll teach me how to integrate the framework with Interlisp for editing unit test definitions with the SEdit structure editor, as well as saving the definitions to files and managing them with the make-like File Manager tool.

#femtounit #Interlisp #Lisp

Discuss... Email | Reply @amoroso@fosstodon.org