8
AleCx04
2y

!rant

For all of youse that ever wanted to try out Common Lisp and do not know where to start (but are interested in getting some knowledge of Common Lisp) I recommend two things:

As an introductory tutorial:
https://lisperati.com/casting.html/

And as your dev environment:
https://portacle.github.io/

Notice that the dev environment in question is Emacs, regardless of how you might feel about it as a text editor, i can recommend just going through the portacle help that gives you some basic starting points regarding editing. Learn about splitting buffers, evaluating the code you are typing in order for it to appear in the Common Lisp REPL (this one comes with an environment known as SLIME which is very popular in the Lisp world) as well as saving and editing your files.

Portacle is self contained inside of one single directory, so if you by any chance already have an Emacs environment then do not worry, Portacle will not touch any of that. I will admit that as far as I am concerned, Emacs will probably be the biggest hurdle for most people not used to it.
Can I use VS Code? Yes, yes you can, but I am not familiar with setting up a VSCode dev environment for Emacs, or any other environment hat comes close to the live environment that emacs provides for this?

Why the fuck should I try Common Lisp or any Lisp for that matter? You do not have to, I happen to like it a lot and have built applications at work with a different dialect of Lisp known as Clojure which runs in the JVM, do I recommend it? Yeah I do, I love functional programming, Clojure is pretty pure on that (not haskell level imo though, but I am not using Haskell for anything other than academic purposes) and with clojure you get the entire repertoire of Java libraries at your disposal. Moving to Clojure was cake coming from Common Lisp.

Why Common Lisp then if you used Clojure in prod? Mostly historical reasons, I want to just let people know that ANSI Common Lisp has a lot of good things going for it, I selected Clojure since I already knew what I needed from the JVM, and parallelism and concurrency are baked into Clojure, which was a priority. While I could have done the same thing in Common Lisp, I wanted to turn in a deliverable as quickly as possible rather than building the entire thing by myself which would have taken longer (had one week)

Am I getting something out of learning Common Lisp? Depends on you, I am not bringing about the whole "it opens your mind" deal with Lisp dialects as most other people do inside of the community, although I did experience new perspectives as to what programming and a programming language could do, and had fun doing it, maybe you will as well.

Does Lisp stands for Lots of Irritating Superfluous Parentheses or Los in stupid parentheses? Yes, also for Lost of Insidious Silly Parentheses and Lisp is Perfect, use paredit (comes with Portacle) also, Lisp stands for Lisp Is Perfect. None of that List Processing bs, any other definition will do.

Are there any other books? Yes, the famous online text Practical Common Lisp can be easily read online for free, I would recommend the Lisperati tutorial first to get a feel for it since PCL demands more tedious study. There is also Common Lisp a gentle introduction. If you want to go the Clojure route try Clojure for the brave and true.

What about Scheme and the Structure and Interpretation of Computer Programs? Too academic for my taste, and if in Common Lisp you have to do a lot of things on your own, Scheme is a whole other beast. Simple and beautiful really, but I go for practical in terms of Lisp, thus I prefer Common Lisp.

how did you start with Lisp?
I was stupid and thought I should start with it after a failed attempt at learning C++, then Java, and then Javascript when I started programming years ago. I was overwhelmed, but I continued. Then I moved to other things. But always kept Common Lisp close to heart. I am also heavy into A.I, Lisp has a history there and it is used in a lot of new and sort of unknown projects dealing with Knowledge Reasoning and representation. It is also Alien tech that contains many things that just seem super interesting to me such as treating code as data and data as code (back-quoting, macros etc)

I need some inspiration man......show me something? Sure, look for a game called Kandria in youtube, the creator, Shimera (Nicolas Hafner) is an absolute genius in the world of Lisp and a true inspiration. He coded the game in Common Lisp, he is also the person behind portacle. If that were not enough, he might very well also be Shirakumo, another prominent member of the Common Lisp Community.

Ok, you got me, what is the first thing in common lisp that I should try after I install the portacle environment? go to the repl and evaluate this:

(+ 0.1 0.2)

Watch in awe at what you get.

In the truest and original sense of the phrase (MIT based) "happy hacking!"

Comments
  • 2
    Thank you very much.

    What i still don't understand:

    Lisp is not like c, c++ or something like that right?

    Maybe this sounds fucking stupid:
    How does this compile to an executable?

    Like c, c++ have their compilers that do that stuff.

    Has common lisp also a compiler that does it or is common lisp only how code is written and then later you choose how you want to compile it and then for example use clojure?

    Please don't kill me my brain just can't handle all that information.

    Like if i want to learn c. I learn how to code is written and then use that magic compiler and bam an executable.

    But after reading some stuff for lisp and so on, there wasn't a clear answer.

    Sorry I think i'm a bit lost lol
  • 2
    @jonas-w you're good man! Lisp is strange, but not so much if you compare it with certain other things.

    1. Can Lisp be compiled into an executable? yes, most modern common lisp compilers (as a starting point I recommend SBCL) have a way to compile your entire project into an executable, supported in a lot of architectures (at least the top 4 ones) Is this common? depends on the project.

    So what is the way? Lisp had a REPL similar to Python, Ruby, JS etc before it was a thing really.

    Projects are generated and either evaluated by the interpreter/compiler such as SBCL or interacted with through the REPL as it is hooked to the files in question.

    To try something easy, you can put this into a file.

    (format T "Well, hello there!~%")

    save it as hello.lisp, and with sbcl installed you can run it a-la-python by typing in the terminal (inside of the directory in which you have the file of course)

    $ sbcl --script hello.lisp
  • 1
    @jonas-w

    2. Clojure and Common Lisp have different targets. Lisp is a family of language dialects. So while Clojure shares some similar attributes to Common Lisp, something like the SBCL Common Lisp compiler will not work with Clojure code, these have different language schematics and targets.

    Technically speaking, you can open up a folder with lisp code in VS code, write your code, and then use sbcl with the --script flag to run your code without much fuss. The thing is, by going that route you sort of lose the benefit of the live interactive environment that exists within Emacs.

    As I mentioned before, emacs is pretty much the biggest hurdle when starting with Lisp, and while it is not strictly necessary it does help a lot more when developing larger projects since you can type some code, evaluate it with the emacs chord C-c-C-c and experiment with the code on the repl. Do not worry too much about this though, if you want to type away in VS Code goforit
  • 1
    @jonas-w Fair warning though, much like one needs to learn multiple things in other languages (maven and builds in Java, makefiles for large projects and header files in C/C++, etc etc) one might need time adjusting to the tooling in Common Lisp, or most Lisp variants to be completely honest.

    Expect to be frustrated for a bit. Also, if the example for the book that I posted proves a bit too annoying at the beginning, there is a different version of the book (you can find it in the index of the page) which targets Emacs Lisp, the Lisp dialect that lives within the Emacs text editor. Do not feel scared from trying that one out if you wish, all you need for that one is Emacs itself (Emacs Lisp does not compile, it is just interpreted by the Emacs engine itself, it is a language that lives just inside of Emacs)
  • 1
    Based and Lisp pilled
  • 0
    So sorry. I stopped reading after "emacs".
  • 1
    @AleCx04 thanks for that detailed explanation and not slicing my head off
  • 0
  • 0
    @fruitfcker I tried very hard to find something on the Lisp spec or the Emacs documentation, but there is no form of key chord that could ever hope to help me give a fuck about that :(
  • 1
    @jonas-w I would never man, I am not the kind of person (or dev for that matter) that would just crap on people for trying to learn something new or asking questions :D

    If you got any additional questions or want more pointers then let me know. Lisp is pretty cool and there are lots of cool things to learn about it out there.
Add Comment