Webview frontend and deprecation of lem-sdl2
Currently, SDL2 is the de-facto default front end for GUI.
However, there are several problems with this.
key input problem
https://github.com/lem-project/lem/pull/1811#issuecomment-2867059186
HTML renderer not available
For example, we need a feature to render Markdown. To do this, you need to render HTML. This is very difficult to achieve with SDL2.
Lack of drawing capabilities
When drawing a rectangle in a window, I want to round the corners, but SDL2 does not provide such a function, so pixel-level manipulation is required.
I think there are other things that are difficult to achieve.
webview frontend
https://github.com/lem-project/lem/pull/1851
Alternative frontends
GTK4 / QT5 / TK
It was not easy to handle GTK4 from Common Lisp.
https://github.com/bohonghuang/cl-gtk4 https://codeberg.org/cage/nodgui I tried those library, but there were some parts that didn't work properly. Also, there are no CL bindings for qt5.
In addition, these libraries do not appear to be maintained, so I am reluctant to use them for long-term projects.
wayflan
https://sr.ht/~shunter/wayflan/ I tried it a little, but it's too low-level and difficult. It seems good for drawing shapes and text, but since I want to run it on Windows and Mac, Wayland seems difficult.
CAPI (LispWorks)
It runs on Windows, Linux, and Mac, and once written, it seems to run with almost no modifications even 10 years later. It is a very good GUI framework for Common Lisp, but only those who have purchased LispWorks can use it.
Electron / Tauri
These choices were very appealing. However, I feel that the overhead is too large for what I want to do. One webview is sufficient.
I am in favor of the Webview frontend.
FWIW, I checked out the feature branch and have been using it for work with ruby-lsp (MacOS M1) and messing with it in my off-time for Lisp work (Linux AMD64). I have not run into any notable differences from the SDL2 frontend.
Looks great, @cxxxr
What about https://github.com/rabbibotton/clog? That's not just a GUI though, but HTML basically.
A more radical idea would be to build the "graphical" variant of Lem into the Nyxt browser https://github.com/atlas-engineer/nyxt, as a "mode" so to say. As this is Lisp, it would be amazing to have such an "integrated (Lisp) computing environment" in the spirit of Emacs (the "almost Lisp machine" aspect), but with proper performance and contemporary (not to say "modern") architecture based on CL.
Well, the latter suggestion would certainly make some adaption necessary, and proponents of the "unix philosophy" might object – but anyhow, the "unix philosophy" is widely misunderstood and logically inconsistent anyway (it's a matter of perspective and granularity, mostly; and it's all just nested layers up and down).
For now, I will close the issues specific to SDL2.
@monkeyjunglejuice CLOG renders either in the browser either with webview (CLOG frame is webview).
Is there is a supported way to just launch the webview server on a unix domain socket and have another webview client app connect to it? I see the code but don't see it mentioned in docs.
to answer my question, on Guix I was able to run:
ASDF_OUTPUT_TRANSLATIONS="/:${HOME}/.cache/common-lisp/" sbcl --load scripts/build-server.lisp
./lem-server --mode websocket --port 50000
N.b. there's a Reddit discussion of this: https://www.reddit.com/r/lem/comments/1mwlg6y/i_dont_know_if_everyone_is_aware_but_lem_is/
Summary: Many people hate WebView / WebKit because of Javascript and browsers and will leave for Emacs.
Why not SDL3?
Just thinking about this:
Offloading the render engine to something like webkit is the right CEO / project management choice. Focus on what you do well, let other people do maintenance of something like that. It would also allow Lem to become an ide that can start charging money for services as it would fit into the rest of the ecosystem that vscode / mac people are used to.
Free software projects are what they are, but I would love to see more projects be able to attract a large client base and make money, including Lem. Even if that might not be the goal.
I support the devs decision regardless of the reasoning for their choice even if not for any of the above reasons.
But, yeah. I use Lem because full common lisp + SDL is really nice for my use case. I suppose a fork of Lem to SDL3 or something might be required for those that want to pursue that dream.
https://www.reddit.com/r/lem/comments/1mwlg6y/comment/na222qw/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
Hello. This post is very interesting to me, because I honestly did not expect so much attention and discussion around the frontend changes in Lem. First of all, thank you for caring about the project at this level.
I also need to admit that there has been a lack of clear communication on my side. I was sharing progress regularly on Discord, and thought that was enough, but it’s now obvious that it was not. That is something I need to improve.
A few clarifications about the WebView direction:
Performance Switching to WebView does not mean a slower or heavier editor. In practice, when used on a daily basis, there is no difference in perceived speed between the WebView frontend and the SDL2 frontend. Responsiveness, input latency, and general speed remain the same.
Code base Currently, some canvas/DOM operations are written in JavaScript. This is only temporary. The long-term plan is to rewrite these parts entirely in Common Lisp (using Valtan, the CL→JS compiler), so that Lem remains Lisp-first in every sense.
Why not SDL2 SDL2 served us well, but it has limitations. For example, creating modern UI features like rounded corners, shadows, or customizable themes requires pixel-level workarounds. There are also persistent issues with key input and IME support (I personally use Japanese). Addressing all of this in SDL2 would be extremely difficult. And no one is seriously maintaining a “permanent” SDL binding for Common Lisp.
Maintenance of SDL2 I mentioned “deprecated,” but that does not mean SDL2 will suddenly disappear. At the very least, it will remain until the current WebView implementation has been fully rewritten in Common Lisp and no longer relies on JavaScript. The code will stay in the repository. If community members wish to continue maintaining SDL2 as an alternative frontend, we are happy to support that effort.
But, yeah. I use Lem because full common lisp + SDL is really nice for my use case.
What's missing in the webview frontend for your use case?
I suppose a fork of Lem to SDL3 or something might be required for those that want to pursue that dream.
There's no need to fork, lem already supports multiple frontends/interfaces. There just needs to be people willing to maintain any frontend that is not maintained by @cxxxr, be it sdl2, sdl3 or anything else.
Just FYI, Nyxt is currently adding an electron based frontend. It would be super cool if we could get lem+nyxt someday.
Theoretically I suppose the new client/server/webview stuff that Lem is doing here could probably be embedded/used within nyxt, where a single nyxt buffer/tab contains lem
Also consider sciter: https://sciter.com/
A more radical idea would be to build the "graphical" variant of Lem into the Nyxt browser https://github.com/atlas-engineer/nyxt, as a "mode" so to say. As this is Lisp, it would be amazing to have such an "integrated (Lisp) computing environment" in the spirit of Emacs (the "almost Lisp machine" aspect), but with proper performance and contemporary (not to say "modern") architecture based on CL.
I don't think it is a radical idea at all, and it has been floating around for a long time. See https://github.com/lem-project/lem/issues/543.