common lisp’s lack of gui
intro⌗
Lisp is by far the most powerful programming language there is. Its simple syntax allows for its program to generate other programs of that nature.
Contrast this to C++, C, or even Dart and they don’t compare at all to Lisp’s power. Sure, these languages are powerful but not as powerful as Lisp.
This is why I see Lisp as the contender that could potentially change the gui ecosystem.
verbosity⌗
Virtually all good languages, such as C or C++, are very verbose when it comes to GUI. Manual Memory Management, Function Calls, and array syntax makes it very verbose and overly complicated.
The solution to the problem of verbosity is creating Languages made specifically for declaring GUIs. HTML, CSS, and JavaScript are a perfect example of this.
HTML’s version of hello world:
Hello World
C++’s version of hello world(Hello Dear ImGUI):
#include "hello_imgui/hello_imgui.h"
int main(int , char *[])
{
HelloImGui::Run(
[]{ ImGui::Text("Hello, world!"); }, // Gui code
{ 200.f, 50.f }, // Window Size
"Hello!" ); // Window title
return 0;
}
See the difference? HTML is vastly better than c++ because it is not bloated. Text is simply text, and you could specify inline styles or external styles.
You could also separate your business logic from your UI. It is this modular design that makes web design so pleasant.
Lisp comes in handy in this aspect, because Lisp can be both transformed into markup languages like HTML or CSS, or used to do native calls like with Hello Dear ImGui.
; pseudo lisp code
(ql:quickload '(:helloimgui :imgui))
(helloimgui:run (imgui:text "hello world") (200 5) "Hello!")
transforming⌗
Technically, all languages can be transferred into markup languages. But, it still comes back to the issue of verbosity. Here is how it would look like in golang
// pseudo golang code
var html = []Element{
{
Tag: "html",
Children: []Element{
{
Tag: "body",
Children: []Element{
{
Tag: "p",
Text: "Hello world",
},
},
},
},
},
}
; actual lisp code
(cl-who:with-html-output-to-string (*standard-output*)
(:html (:body (:p "Hello World"))))
Lisp code is so dynamic and elegant compared to Golang.
lack of system libraries⌗
It is very strange to me that a language that came out virtually 20-30 years ago has very bad libraries.
You’d think a language that has virtually invented all of modern programming languages features such as garbage collection would have usable system libraries but no.
Even newer languages like Go(2009) has better system libraries and overall runtime than Common Lisp.
Which saddens me to say, because Lisp is one of the most joyful languages to use for me. I try to use it on any project I could put my hands on simply because I enjoy it. It genuinely boggles my mind that people don’t use it.
your gui choice(s)⌗
I’ve been searching for GUI Common Lisp Libraries for a while now, and you basically have one good GUI library: EQL5.
EQL5 is by far the best GUI library for Common Lisp there is. However, that is not to say that it passes the metric for a normal GUI Library, no, you have to lower your standards a bit.
EQL5 works, supports cross compilation, has tons of examples, but lacks documentation. Anything you’ll try outside of the box in EQL5 will always not have documentation. For example, setting a theme for Qt5 Quick Controls.
Qt5 Documentation will suffice most of the times, but when it doesn’t, you are basically left alone to discover how to achieve what you want.
Other Libraries that you could use:
- Nuklear: Bindings to the Nuklear Immediate Mode GUI library written in C
- Dear ImGUI: Bindings to the Dear ImGUI Immediate Mode GUI library written in C++
- LTK: Bindings to the Tk Native GUI Library.
conculsion⌗
There needs to be a better way to create GUIs in Common Lisp. We have a lot of C libraries that make creating windows, handling mouse events, and drawing on the screen a piece of cake. A great example of this is GLFW.
A Native Common Lisp GUI library would make creating GUIs a pleasant process.