• person rss_feed

    Michał "phoe" Herda’s feed

    Blog

    • chevron_right

      Answers from 2017 Common Lisp experts - Functional programming

      Michał "phoe" Herda · Sunday, 23 December, 2018 - 11:37 · 2 minutes

    (This is a repost of an old blog post of mine from Teknik. This blog post was split into multiple parts to accomodate for Movim's size limitations; use hypelinks in the table of contents to navigate.)


    Why aren’t there more libraries using a functional, immutable paradigm? Most seem to use many dynamic variables and large functions spanning multiple screens, with variables mutating throughout

    defaultxr

    CL is a multi-paradigm programming language. It existed long before purely functional programming a la Haskell became the hip and cool thing to do. CL is not about forcing a specific paradigm on you. If you want that, no one is stopping you from using Clojure, or writing your own CL libraries in a more purely functional style.

    Aidenn0

    Because the fraction of people writing pure immutable code in Common Lisp isn't much higher than for any other general purpose language, so the absolute number of people to work on such libraries is much smaller.

    alcahd

    Common Lisp has always been a multi-paradigm language, there are other Lisps such as Scheme if you want to go down the FP road. It's fair to say that the syntax errs towards a functional style, but the language itself is flexible enough to accommodate whatever the user thinks is best. The OO system, CLOS, is worth looking into, it's very powerful and somewhat unique, using neither message passing nor the imperative systems seen in Java/C++.

    phoe

    Has functional programming been found ultimately better than anything else, or is it just trendy nowadays?

    Common Lisp allows the programmer to mutate if they consider it to be proper. Common Lisp also allows the programmer not to mutate if they consider it proper. This language does not enforce a particular paradigm on you. If you want it to enforce a particular style on you, nothing prevents you from creating such limitations yourself.

    Common Lisp is a multi-paradigm programming language that does not limit the programmer to using only paradigm X or Y. You can write imperative code, you can write object-oriented code, you can write functional code, you can write declarative code, you can write actor-based code, you can write contract-based code, hell, you can go back to 1964 and write (TAGBODY 10 (PRINT "HELLO WORLD") 20 (SLEEP 1) 30 (GO 10)) because linear programming is supported as well and all iterating constructs I know actually compile into GOTO-like structures such as that.


    Are there any functional programming advocates in the Common Lisp open source community?

    phoe

    Betcha there are, but as I said before, Common Lisp is not a functional language. The style commonly advocated is "mostly functional" and tends to be a mix of imperative functionalities like LOOP, the Common Lisp Object System (CLOS), and functional capabilities like higher-order functions.

    • wifi_tethering open_in_new

      This post is public

      nl.movim.eu