26
1
submitted 9 months ago by blawsybogsy@lemmy.ml to c/lisp@lemmy.ml

"We create a search form, display products with ready-to-use HTML templates, organize our Djula templates with inheritance. Common pitfalls. That's the basics every web developer should know!"

https://www.youtube.com/watch?v=EFRVHmOCE7Q

By Vindarel, of CL cookbook fame.

27
1
submitted 9 months ago by charje@lemmy.ml to c/lisp@lemmy.ml

There are many things to like about Common Lisp packages. In everyday programming, I really like being able to define one or more packages in one file then just have a (in-package package-name) at the top of other files opposed to having sometimes hundreds of lines of imports. Some programming languages are worse than others, but no other programming language that I know of allows one to keep imports in a totally different file.

The real point of this post is to talk about a specific scenario that reveals in interesting interaction between asdf systems (libraries), symbols, and macros. A conversation about packages almost always involves talking about symbols. Here is the situation: there is a library, A, that implements some very useful computations. The public interface for the library is a combination of macros and functions. It is rather verbose though, so you want to wrap it in a macro and create a new library: B. You want the users of your library to only have to use your library and not have to worry about depending directly on library A, so you want to re-export some of the symbols from library A so the users of your library can just use those symbols exported from your library.

If you don't see a problem with this then congratulations: you are sane. This relies on just a couple features:

  • feature of asdf: orthogonal to packages meaning that one can use a symbol from any package without having to explicitly load the system. If a package is loaded, it's symbols can be used.

  • feature of packages: symbols in a package can be referred to by their full name (package-name:symbol-name) anywhere in anyone's program. It does not matter if they have the symbol imported into their package. It does not matter if they have a package local nickname. It does not matter that they have a different symbol interned with the same symbol-name.

  • macros do not have any feature of their own that make this possible, but because of the previously mentioned features, using a symbol from another library in a macro expansion works just fine. As an added benefit, you cannot expand to symbol from a package that is not exported or from a non-existent package because the reader (which happens before macro expansion, even before macro definition) makes sure all the symbols are accounted for.

I witnessed someone in almost this exact situation. They were using Rust. The problem happened when someone tried to use the macro from library A that had been re-exported from library B. The macro expanded to use some symbols that were qualified assuming that the user had already imported them from library A. However, the user imported from library B. The work around ended up being to not re-export and just tell the user via documentation that they have to explicitly depend on library A, and use their macro.

That is the story. Let me know what you think, and tell me about a time that you were grateful for the way Common Lisp handles packages and symbols.

28
1
submitted 9 months ago by blawsybogsy@lemmy.ml to c/lisp@lemmy.ml
29
1
Calcit Language (calcit-lang.org)
submitted 9 months ago by yogthos@lemmy.ml to c/lisp@lemmy.ml
30
1
Common Lisp tips (github.com)
submitted 10 months ago by amoroso@lemmy.ml to c/lisp@lemmy.ml
31
1
submitted 10 months ago by yogthos@lemmy.ml to c/lisp@lemmy.ml
32
1
submitted 10 months ago by cadar@lemmy.ml to c/lisp@lemmy.ml

This is another Friday social topic. You are aimlessly wandering around a beautiful hilltop by a sea when an angel approaches you from the opposite direction. She is no ordinary angel. She is a Lisp angel! She will grant one Lisp wish to you. Before she can fulfill your wish, she needs this information from you:

  1. Your favorite Lisp dialect.
  2. Your favorite non-Lisp programming language.
  3. Your favorite standard library function/macro/feature from your favorite Lisp dialect that you want to see in your favorite non-Lisp programming language.

Once you tell these 3 things to the angel, she will magically add your chosen feature to your chosen non-Lisp programming language.

What are your answers going to be?

33
1
submitted 11 months ago by vi21@lemmy.ml to c/lisp@lemmy.ml

The advantages of using Common Lisp are numerous:

  1. The shape of tensors is not limited to numbers, but can also include symbols and even S-expressions!
  2. Automatic Generation of Iterators, ShapeError, etc.
  3. Works as a Domain Specific Language for Deep Learning embedded in Common Lisp
34
1
submitted 1 year ago by yogthos@lemmy.ml to c/lisp@lemmy.ml
35
1
submitted 1 year ago by santiagopim@lemmy.nz to c/lisp@lemmy.ml

Added a couple desktop backgrounds to the revisited #commonlisp logo in https://gitlab.com/santiagopim/common-lisp-logo

Happy hacking !!

36
2
submitted 1 year ago by Ramin_HAL9001@lemmy.ml to c/lisp@lemmy.ml

Another bit of gold from ICFP 2023 by Pjotr Prins of the University of Tennessee.

The actual title of the talk is "Why code in Python+C if you can code in Lisp+Zig?" but the "Lisp" in this case is actually Guile Scheme. I didn't know this, but Zig uses the C ABI so it binds to any language that can do FFI bindings to C, including most Scheme and Common Lisp implementations. But why don't I just post the abstract here:

"Most bioinformatics software today is written in Python and for performance C is used. Lisp has been around for over half a century and here I don’t have to tell how or why programming Lisp is great. I will talk about Zig as a minimalistic new language that is unapologetically focused on performance, tellingly with a blazingly fast compiler. It is advertised as a replacement for Thompson, Ritchie, and Kernighan’s C, but it may even replace C++ in places. Zig uses the C-ABI and does not do garbage collection, so it is ideal for binding against other languages. In this talk I will present combining GNU Guile Lisp with Zig. I’ll argue that everyone needs two languages: one for quick coding and one for performance. With Guile and Zig you get both at the same time and you won’t have to fight the Rust borrow checker either."

37
1
submitted 1 year ago by Ramin_HAL9001@lemmy.ml to c/lisp@lemmy.ml

Note: this was originally a comment I wrote on Lemmy in answer to the question “what type of problems do you solve using Lisp?”. The post got to be a bit too long, and I am re-publishing it here as a proper blog post. I am also including some of a post I wrote on Mastodon which touched on some of these same issues.

So to answer the question: I have known about Common Lisp and Scheme for years, but only recently started using them. This is the story of the 3 Lisp dialects that I use.

Emacs Lisp

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.

Scheme

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 Goblins, which is a distributed object-capability programming system is officially supported on the Guile platform, and I have been really wanting to write applications using this programming style ever since I first learned about it.

  • Also, there is 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 (my personal favorite) the Xfce desktop environments. This potentially 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. Guile is relatively large (not as big as Common Lisp), but other implementations are unbelievably small. for example the Chez Scheme “petite” interpreter is fully compliant with the R5RS standard, and the executable is like 308 kilobytes on a 64-bit Linux computer system.

  • Hygienic macros with syntax-case

  • Recursive functions over using the loop macro of Common Lisp. When writing algorithms, I personally find it easier to reason about recursive functions than loops. 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.

  • Pattern matching is well supported by most Scheme implementation.

  • It is a "Lisp-1" system, meaning there is only one namespaces for variables and functions, as opposed to Common Lisp (a "Lisp-2 system") which allows a name to be either a variable, a function, or both. I personally find it easier to reason about higher-order functions in Lisp-1 systems.

  • Support for Delimited Continuations, which is a fairly recent discovery of computer language theory (first being discussed back in the 1990s), but is available across a few Scheme implementations.

Common Lisp

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.

The modern software industry, especially in the realm of big data and machine learning, has mostly settled on a pattern of using C++ for creating performance critical libraries, and creating Python binding to the C++ libraries for scripting. I was hoping languages like Haskell and/or Rust might come along and change all this, but it will take decades (if ever) for the software industry to turn in that direction.

The problem with Python, in my experience (and I believe many other software engineers would agree) is that it does not scale well to larger applications at all, whereas Common Lisp does. This is for various reasons, but mostly due to how Lisp does strong dynamic typing, and also the CLOS implementation of the meta-object protocol. Yet too many companies waste time writing large applications in Python — applications that are much larger than the scripting use cases that Python was originally intended to be used. I believe this is time and money better spent on other things.

So I see Common Lisp, and the ECL compiler, as a potentially viable alternative to the sub-optimal status quo of Python as a scripting layer around C++ code libraries, at least perhaps for my day job, if not being more generally true industry-wide. 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 C++ libraries out there: Qt, OpenCV, Tensorflow, PyTorch, OpenSceneGraph, FreeCAD, Godot game engine, Blender. And it compiles easily on Linux/Unix (GCC), Windows (MSVC), and MacOS (via Clang++), so good for cross-platform development.

Conclusions

So in spite of Lisp being such an old family of languages (its earliest incarnations dating all the way back to 1958), and being superseded in popularity and widespread use by languages like Python and JavaScript across the software industry, Lisp is still a modern, relevant, evolving, and very useful family of programming languages. At the same time, a Lisp such as Scheme or Common Lisp would even be a better choice of programming language in many applications where Python is currently used.

I just hope I eventually find the time to try out all of these Common Lisp and Scheme related ideas I have. I especially hope ECL turns out to be a profitable technological choice for the professional work that I do. But only time will tell.

Please feel free to comment here, or on Mastodon

38
1
submitted 1 year ago by cadar@lemmy.ml to c/lisp@lemmy.ml

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.

39
1
submitted 1 year ago* (last edited 1 year ago) by bahmanm@lemmy.ml to c/lisp@lemmy.ml

cross-posted from: https://lemmy.ml/post/4591838

Suppose I need to find out if the intersection of an arbitrary number of lists or sequences is empty.

Instead of the obvious O(n^2^) approach I used a hash table to achieve an O(n) implementation.

Now, loop mini-language aside, is this idiomatic elisp code? Could it be improved w/o adding a lot of complexity?

You can view the same snippet w/ syntax highlighting on pastebin.

(defun seq-intersect-p (seq1 seq2 &rest sequences)
 "Determine if the intersection of SEQ1, SEQ2 and SEQUENCES is non-nil."
 (cl-do* ((sequences `(,seq1 ,seq2 ,@sequences) (cdr sequences))
          (seq (car sequences) (car sequences))
          (elements (make-hash-table :test #'equal))
          (intersect-p nil))
     ((or (seq-empty-p sequences)) intersect-p)
   (cl-do* ((seq seq (cdr seq))
            (element (car seq) (car seq)))
       ((or intersect-p (seq-empty-p seq)) intersect-p)
     (if (ht-get elements element)
         (setf intersect-p t)
       (ht-set elements element t)))))

(defun test-seq-intersect-p ()
 "Test cases."
 (cl-assert (null (seq-intersect-p '()
                                   '())))
 (cl-assert (null (seq-intersect-p '(1)
                                   '())))
 (cl-assert (null (seq-intersect-p '(1 2)
                                   '(3 4)
                                   '(5 6))))
 (cl-assert (seq-intersect-p '(1 2)
                             '(3 4)
                             '(5 6)
                             '(1)))
 t)

(test-seq-intersect-p)

Version 2

(defun seq-intersect-p (first second & sequences)
  "Determine if FIRST, SECOND and any of the sequences in SEQUENCES have
an intersection."
  (if (seq-empty-p sequences)
      (seq-intersection first second)
    (or (seq-intersection first second)
        (apply #'seq-intersect-p
               first
               (seq-first sequences)
               `,@(seq-rest sequences))
        (apply #'seq-intersect-p
               second
               (seq-first sequences)
               `,@(seq-rest sequences))
        (apply #'seq-intersect-p
               (seq-first sequences)
               (seq-elt sequences 2)
               `,@(seq-rest (seq-rest sequences))))))
40
1
submitted 1 year ago by yogthos@lemmy.ml to c/lisp@lemmy.ml
41
1
submitted 1 year ago by amoroso@fosstodon.org to c/lisp@lemmy.ml

In the Lisp community @lisp on Lemmy.ml there's a discussion on what your Lisp development environment looks like and how you got started with Lisp. Of course I'm the weirdo who uses Interlisp as his daily driver.

https://lemmy.ml/post/3860996

#lisp

42
1
submitted 1 year ago by cadar@lemmy.ml to c/lisp@lemmy.ml

It's Friday, so I though it would be nice to have a social topic here. So here's a bunch of questions to stir up some discussions:

  • Which Lisp do you most often program in?
  • What does your Lisp development environment or IDE look like?
  • How did you get started with Lisp? Did you follow any particular articles to set up your environment or begin learning Lisp?
43
1
submitted 1 year ago by charje@lemmy.ml to c/lisp@lemmy.ml
44
1
submitted 1 year ago by citytree@lemmy.ml to c/lisp@lemmy.ml

cross-posted from: https://lemmy.ml/post/3549323

John Cowan has resigned as chair of the R7RS-large project.

45
1
submitted 1 year ago by cadar@lemmy.ml to c/lisp@lemmy.ml
46
1
submitted 1 year ago by charje@lemmy.ml to c/lisp@lemmy.ml
47
1
submitted 1 year ago by amoroso@lemmy.ml to c/lisp@lemmy.ml

Feel free to comment here and/or on the linked Hacker News thread.

48
1
submitted 1 year ago by Leobm@feddit.de to c/lisp@lemmy.ml
49
1
submitted 1 year ago by cadar@lemmy.ml to c/lisp@lemmy.ml
50
1
submitted 1 year ago by amoroso@lemmy.ml to c/lisp@lemmy.ml
view more: ‹ prev next ›

Lisp Community

683 readers
1 users here now

A community for the Lisp family of programming languages.

Lisp (historically LISP) is a family of programming languages with a long history and a distinctive, fully parenthesized prefix notation. Originally specified in 1958, Lisp is the second-oldest high-level programming language. Only Fortran is older, by one year.

History

Associations and meetings

Resources - TODO

Related communities (dialects) - TODO

founded 5 years ago
MODERATORS