Hello! Let us have another Friday social topic.

What type of problems do you solve using Lisp? Please share these details while answering:

  • Which dialect of Lisp do you use?
  • What problems do you solve?
  • Why do you choose Lisp to solve these problems?

I have a feeling that this thread might get inundated with too many Emacs Lisp posts about solving personal productivity problems. That’s fine. But I suggest posting stuff about other dialects of Lisp too. The more dialects of Lisp (CL, Clojure, Racket, etc.) are discussed here, the better! We want to have a good variety of answers on this thread.

  • Ramin Honary@lemmy.ml
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    1 year ago

    (EDIT: this got to be a wall of text, so I wrote a proper blog post about it, but I'll take any comments on it here, or on this Lemmy post linking to my blog.)

    I have known about Common Lisp and Scheme for years, but only recently started using them.

    I use Emacs and Emacs Lisp to manage my tens of thousands of text files, I write Emacs Lisp scripts to automate simple tasks like searching for pieces of information, formatting it, and outputting it to a report that I might publish on my blog or send in an e-mail. I also use Emacs to help with data cleaning before running machine learning processes. Emacs helps with navigating CSV and JSON files, it also is a really good batch file renamer.

    I have recently started using Guile Scheme to do some personal projects. I went with Guile over the myriad other Scheme dialects because it is the implementation used for the Guix package manager and operating system. Also, there the G-Golf foreign interface layer allows Guile to automatically use an C library that implements the GObject Introspection interface. So through Guile, like with Python, you can use any C code library used to create of all native apps in the Gnome, MATE, Cinnamon, or Xfce desktop environments. This makes Guile a viable alternative to Python scripting across all of those Linux desktop environments.

    Of all the Lisp dialects, Scheme is my favorite, for a few reasons:

    • it is absolutely tiny. The Chibi Scheme interpreter is something like 300 kilobytes on a 64-bit computer system.
    • hygienic macros with syntax-case
    • I strongly prefer writing recursive functions over using the loop macro of Common Lisp. Scheme also provides me the ease-of-mind that comes with knowing the optimizing Scheme compiler will ensure recursive loops will never overflow the stack.
    • most implementation have good support for pattern matching
    • I personally find it easier to reason about higher-order functions when there is only one namespaces for variables and functions
    • More recently, there is now support for Delimited Continuations across a few Scheme implementations

    That said, I am also starting experimenting with Embedded Common Lisp (ECL) because it is a lightweight standards compliant Common Lisp implementation that compile your program into C++ code, and this is useful to my professional work.

    In modern software engineering, especially in the realm of big data and machine learning, all of the most commonly used frameworks are written in C++ for performance, and scripted in Python. But Python does not scale well at all to larger applications, where Common Lisp does (for various reasons, but mostly due to how Lisp does strong dynamic typing and the meta-object protocol). So I see Common Lisp, and the ECL compiler, as a viable alternative to the sub-optimal status quo of Python/C++ in my professional work. Mostly, ECL would allow me to write a program in Common Lisp instead of Python, but deliver to my clients the C++ code that ECL generates to be used in their machine learning projects. (I have not actually done this yet, I am still investigating whether this would be a viable solution to any of my projects).

    ECL makes it easy to use C++ libraries through Lisp instead of Python. And there are so many good, performant C++ libraries out there: Qt, OpenCV, OpenCL, Tensorflow, PyTorch, OpenSceneGraph, FreeCAD, Godot, Blender. And it compiles easily on Linux/Unix (GCC), Windows (MSVC), and MacOS (via Clang++), so good for cross-platform development.