CLOG (Common Lisp Omnificent GUI)

repository·main·Indexed 23 days ago

https://github.com/rabbibotton/clog

A framework for building cross-platform desktop, mobile, and web applications using Common Lisp. CLOG uses web technologies and websockets to handle rendering via the browser while keeping logic on a local or remote server. It includes the clogframe CLI for creating native browser-controlled windows, a dedicated REPL for interactive UI prototyping, and the CLOG Builder for project management. Supports installation via QuickLisp (UltraLisp distribution) or OCICL.

Tokens
5.6K
Snippets
25
Records
43
Agent score
82%

What's inside CLOG

  1. Overview of CLOG tutorials

    main

    The CLOG tutorial series covers a wide range of topics from basic 'Hello World' to advanced web and graphics integration. Key learning areas include:

    • Basics: Closures, parallel events, event targets, and tasking.
    • UI Components: Containers, tabs, panels, forms, menus, and drag-and-drop.
    • Graphics: Canvas, 2D WebGL, and 3D WebGL.
    • Web Integration: Routing, Bootstrap 4, W3.CSS, and using existing HTML.
    • Advanced Web: CLOG WEB (local web apps, forms, and routing), database-driven websites (clog-web-dbi, clog-auth, clog-web-content), and instant websites (clog-web-site).
    • Extensibility: Creating new plugins from JavaScript components or in Common Lisp.
    • Data & State: Local/Session client-side storage and linking Lisp objects to CLOG objects via Presentations.
    • Syntax: Using with-clog-create for declarative GUI syntax.
  2. Understand CLOG Builder project templates

    main

    CLOG Builder uses a specific directory structure to provide templates for starting new application projects. When creating a new project, the builder utilizes files from the following locations:

    • www/*: Contains static-file directories common to all projects.
    • projects/*: Contains specific CLOG Builder templates.
    • common/*: Contains general build scripts and files used for initializing new projects.
  3. How to handle connectivity and reliability in CLOG

    main

    While CLOG is designed to be robust by leveraging web technologies, developers must design for potential failures.

    Connectivity Behavior:

    • CLOG can automatically re-establish moderate connectivity interrupts.
    • On a single machine, the connection can survive system sleep or suspension.
    • Full disconnects are not automatically recovered by the framework; your application design must account for them.

    State Management:

    • UI State: A snapshot of the current UI state can be taken easily.
    • Server State: The persistence of server-side state is dependent on your specific application design.

    To build a reliable application, ensure you have a strategy for handling full disconnections and managing state transitions during recovery.

  4. How CLOG establishes the initial UI state

    main

    CLOG provides three distinct patterns for initializing a user interface, allowing developers to balance performance, ease of development, and control:

    1. Initial Boot File (HTTP-based): Use a traditional HTML file served via HTTP to establish the initial UI. This approach is similar to standard web development and allows the use of any familiar web technologies. To enable server-side control within the CLOG framework, include or embed the boot.js script in your HTML file.

      • Requirement: The CLOG server and the web pages must reside on the same domain due to WebSocket security restrictions.
      • Performance: High (comparable to or better than Ajax).
    2. CLOG API Construction: Build the initial UI from scratch using CLOG's programmatic APIs. This is ideal for developers who want a completely non-HTML/non-JS code-based approach.

      • Performance: Slower than the other methods.
    3. Hybrid Approach (Composite Components): Used by CLOG Builder panels. This method delivers a base UI via a bulk write of HTML/JS to the browser, combining the benefits of pre-defined structures with dynamic control.

      • Performance: High.

    Choose between these methods based on whether you prioritize standard web workflows, pure Lisp-based construction, or the performance of bulk-loaded components.

  5. Understand CLOG's transport and communication model

    main

    CLOG operates on a client/server architecture using a two-stage communication process:

    1. Bootstrap: An initial connection is established via HTTP using an HTML boot page and a JavaScript script.
    2. Continuous Communication: Once bootstrapped, the application switches to WebSockets. All subsequent messages between the server and client are transmitted as JavaScript over WebSockets (JS over WS).

    This model allows for transparent UI changes, event communication, and DOM fragment updates. It enables CLOG to function as a highly responsive 'push UI', providing real-time information delivery that is not possible with standard stateless web requests.

  6. Install and run the hello-builder tutorial project

    main

    To use the hello-builder minimalist project, move the directory to your ~/common-lisp folder (or another directory in your QuickLisp search path). You can then load and run the application using QuickLisp and the provided entry point.

    1. Load the system via QuickLisp: (ql:quickload :hello-builder)
    2. Start the application: (hello-builder:start-app)
  7. Enter your SBCL world for CLOG development

    main

    After installing CLOG via OCICL, you must enter your SBCL (Steel Bank Common Lisp) environment using the specific initialization file created during setup. Use the --userinit flag pointing to the init file to ensure the environment is correctly configured.

    Once inside SBCL, load the CLOG tools system and start the CLOG builder using the following commands:

    1. Load the tools: (asdf:load-system :clog/tools)
    2. Start the builder: (clog-tools:clog-builder)
    sbcl --userinit init
    
    * (asdf:load-system :clog/tools)
    * (clog-tools:clog-builder)
  8. Quick Start: Launching the CLOG Builder

    main

    You can start CLOG and the CLOG Builder directly from your terminal using SBCL. This is the fastest way to get into the development environment.

    Run the following command in your shell:

    sbcl --eval "(ql:quickload :clog/tools)" --eval "(clog-tools:clog-builder)"

    If you are using Emacs with SLIME, you can run these commands within your SLIME/SLY REPL:

  9. Run the CLOG tutorial

    main

    To run the built-in tutorials, you must first ensure CLOG is loaded in your REPL. Depending on your environment, follow the appropriate steps below.

    If using the CLOG Builder

    Open a CLOG Builder REPL and execute:

    (clog:run-tutorial 1)

    If using another REPL

    First, load CLOG using Quicklisp:

    (ql:quickload :clog)

    Then, run the tutorial:

    (clog:run-tutorial 1)

    Upon running, the Hunchentoot server will start (typically listening on 0.0.0.0:8080). Most demos will attempt to start a browser automatically. If they do not, navigate to http://127.0.0.1:8080 in your web browser.

  10. Add non-standard project locations to ASDF

    main

    If you are using plugins or dependencies located in non-standard directories, you can add the project's location to the ASDF central registry. This should be done via a --eval to your Lisp implementation (SBCL, ECL, etc.) before loading your project or the builder.

    (pushnew #P"/path/to/a/project" asdf:*central-registry* :test #'equalp)