[HN Gopher] Modern, functional Common Lisp: myths and tips (2020)
       ___________________________________________________________________
        
       Modern, functional Common Lisp: myths and tips (2020)
        
       Author : dunefox
       Score  : 104 points
       Date   : 2021-11-08 19:52 UTC (1 days ago)
        
 (HTM) web link (ambrevar.xyz)
 (TXT) w3m dump (ambrevar.xyz)
        
       | jpe90 wrote:
       | I've been building a personal project in both Clojure and Common
       | Lisp to make a DSL for scraping web data, transforming it, and
       | outputting it to a few backend formats.
       | 
       | I would say it's been significantly harder to achieve the same
       | functionality in CL than Clojure, but there are major perks to
       | the ecosystem. I was surprised by how much I've valued conditions
       | and restarts, type inference from SBCL, stack traces, and tooling
       | in general.
       | 
       | Clojure OTOH feels like it takes much less effort to get up and
       | running, feels more intuitive to write, and has far better
       | documentation.
       | 
       | I'm probably going to continue writing my project in both
       | languages in parallel because I love learning and I spend my time
       | poorly. I want to stick with Clojure given that it sees more use
       | these days, but it's hard not to prefer CL once you invest the
       | time in learning its capabilities.
       | 
       | As a final note, was Practical Common Lisp challenging for anyone
       | else? I've read many glowing recommendations of the book, but at
       | times it feels DENSE, and it took a fair amount of staring at the
       | intermediate stages of the projects to understand what was going
       | on.
        
         | antonvs wrote:
         | > I love learning and I spend my time poorly.
         | 
         | You are not alone
        
         | taeric wrote:
         | I'm curious in the ways that clojure is faster to get going and
         | more intuitive. Sbcl and quicklisp seem like they are a bit
         | more straight forward/stable than figuring out how to do a jvm
         | nowadays.
        
           | jpe90 wrote:
           | Some examples of things that make Clojure click quickly are
           | being able to use seq operations on all core data structures
           | instead of learning how to work with list, vectors, hash
           | tables, and sets separately, documentation being great with
           | tons of code examples on clojuredocs.org, and the fact that
           | you know you need to "do everything the functional way" up
           | front means less decision making. And prolific overuse of
           | hash tables speeds things up too :)
        
             | taeric wrote:
             | Thanks, that makes sense.
             | 
             | I'd expect you could make the same heavy use of hashtables
             | in either, though I suspect it isn't obvious to lean on
             | setf so much if new to CL? That, or if you are insisting on
             | immutable structures?
             | 
             | I confess I assumed that alists are probably more
             | competitive in speed for many collections than makes sense.
        
               | jpe90 wrote:
               | Well, for my project I am using CLOS in CL where I used
               | hash tables in Clojure. But yeah, if I went for hash
               | tables, it would be getfs and setfs to mutate the table,
               | or I saw there are immutable operations for hash tables
               | in CL as well. It just takes a little more code and
               | cognitive load to work with.
        
         | guenthert wrote:
         | > ... and has far better documentation.
         | 
         | I suppose libraries to access the 'net (and WWW specifically)
         | etc. are meant. CL the language is very exhaustively
         | documented, even if much of that documentation is more than 20
         | years old (and a good share predates Google, so it might not be
         | as accessible).
        
           | jpe90 wrote:
           | That was specifically referring to the availability of code
           | examples for the core library on clojuredocs.org (I know
           | hyperspec has some code examples as well, but they haven't
           | been as comprehensive imo) and the ability to seamlessly jump
           | into library source code within Emacs.
        
             | [deleted]
        
         | hedgehog0 wrote:
         | I read PCL about seven or eight years ago when I didn't have a
         | lot of experience with programming. It's somewhat dense and
         | some of the topics/chapters may not be absolutely necessary for
         | a beginner to write Lisp programs. But in retrospect, I
         | sometimes find it good reference when I want to brush up
         | certain topics, like CLOS and macro stuffs.
        
       | hajile wrote:
       | I wish more languages had the interactive development
       | capabilities of Common Lisp. The language deserves more love than
       | it gets.
        
         | dunefox wrote:
         | Yeah, absolutely. I think CL the language should be modernised
         | (more coherent stdlib, naming scheme for destructive functions,
         | etc) but it's basically the only language that offers a handful
         | of _really cool_ features that I can 't get anywhere else.
        
           | rackjack wrote:
           | Any specific features that stand out to you?
        
             | dunefox wrote:
             | Compile time macros, interactivity, CLOS, having the
             | compiler readily available, ability to inspect any values,
             | conditions and restarts, ...
        
       | snappergrass wrote:
       | I read the article and checked out portacle, which fired up emacs
       | and greeted me with: "Lemonodor-fame is but a hack away!" Takes
       | me back a few years.
        
       | dunefox wrote:
       | I'm thinking about using CL for this years Advent of Code. I
       | think it lends itself well for this kind of programming.
        
       | [deleted]
        
       | podiki wrote:
       | Love Common Lisp and found this helpful even after using it for
       | several years (coincidentally I was just reading it before it
       | popped up here again). I'm intrigued by Sly, as a long time Slime
       | user, will have to try it out!
       | 
       | I was also just getting some of my environment set up on Guix and
       | the addition of Guix Shell [0] is great. Now I can set up an
       | environment and load a lisp file instantly (after the initial
       | caching) with `guix shell sbcl [sbcl-packages] -- sbcl --load
       | somefile.lisp [arguments]` Works across computers with Guix for
       | reproducible environments, very nice stuff. Even easier from a
       | blank slate than getting Roswell and/or quicklisp set up, just a
       | one liner with Guix.
       | 
       | [0] https://guix.gnu.org/en/blog/2021/from-guix-environment-
       | to-g...
        
       | aidenn0 wrote:
       | > Algebraic types are supported out of the box...
       | 
       | Pretty sure that's not true since you can't define recursive
       | types. For example, the following is invalid (in fact there is no
       | way in the CL type system to define a type that represents a
       | proper list of a given element type without using SATISFIES):
       | (deftype proper-list (&optional (element-type t))         `(or
       | null (cons ,element-type proper-list)))
       | 
       | More details about this issue from when it came up during the
       | standardization process:
       | 
       | https://www.cs.cmu.edu/Groups/AI/html/hyperspec/HyperSpec/Is...
        
       | dang wrote:
       | Discussed at the time:
       | 
       |  _Modern, functional Common Lisp: myths and best practices_ -
       | https://news.ycombinator.com/item?id=22412148 - Feb 2020 (155
       | comments)
        
       ___________________________________________________________________
       (page generated 2021-11-09 23:01 UTC)