r/learnlisp • • May 06 '19

20 new episodes of 'little bits of lisp'

28 Upvotes

EDIT: Sorry I forgot to add the [Common Lisp] tag

It's been a while since the last batch of videos to this set.

This update is mainly focused on small standalone things. I'm planning videos on compilation and symbols/packages but, whilst being simple enough to use, I'm still not happy my explanations are both thorough and simple enough. Given that it's probably going to be a while before those land.

I'm seeing a lot of views on the macro episode even though I thought it was a bit long and rambly. Because of this I'm thinking of making some more bite-sized episodes on macros. Is there anything in particular that confuses you that you would like covered?


r/learnlisp • • May 24 '19

On Lisp in 15 minutes

Thumbnail
medium.com
21 Upvotes

r/learnlisp • • Apr 10 '21

Guides on Learning to Use Lisp Instead of Shell Script?

17 Upvotes

This may seem like an odd question, but it is one that I have been meaning to ask recently. I recently discovered common lisp when trying to find a programming language that I liked enough to really use and work on projects in. I had learned basic Python and C in the past, but just could not get into them enough to want to really use them. The one language I have had extensive use of until finding common lisp was POSIX shell script, which I learned by forcing myself into the shell for everything. Doing research into different programming languages I looked at Fortran, COBOL, Golang, Rust, and a few other languages before falling in love with common lisp, for a variety of reasons.

I have been going through work books on common lisp for a little bit now, mainly struggling with strings and lists which I intend to learn about. To learn more about common lisp I installed emacs and started coding some projects using SLIME. I won't lie, I have not gotten far due in part to me being lazy and playing video games all the time. Projects are indeed fun, but the way I really really learned to not just write shell script, but troubleshoot and research it was through daily use for everything. Researching old lisp machines and lisp operating systems I was able to find that common lisp itself used to not just implement everything from OSes to userland tools, but was also intended to be used in the same way a UNIX shell is. I have read different blog posts about people replacing their linux shell with a REPL and while those are interesting I don't know enough about how to do common tasks within lisp (listing directories, rebooting the computer, etc) to jump into using sbcl or any other REPL over my linux shell. In effort to learn more about lisp and get a good feel for it I do want to start using a REPL instead of my shell, but can't seem to find information on how to do what are basic tasks I do everyday. Does anyone here have any information that could help me? I have found how to do things like executing userland programs, deleting files and directories (way nicer than how you do it in C lol), but not things like rebooting, powering off, suspending, etc a computer.

Sorry if this is written poorly, finals are killing my sleep and I wanted to ask this before I forgot again. Thank you for your time.


r/learnlisp • • Aug 24 '20

Looking for Good Examples of Common Lisp Code

16 Upvotes

I am learning to program. I want to eventually get a job in software but I am not in a hurry and I really look up to Paul Graham and Patrick Collision so I stumbled upon Lisp. After reading the borderline fanatical accounts of people here, I began working through Gentle Introduction to Common Lisp, which I really enjoy.

Now, I am trying to build things and play around and I was wondering if anyone had any good places to find simple programs written in Lisp. I'm open to books, repos, YouTube videos etc.

Thanks!


r/learnlisp • • Feb 12 '15

Lisp as the Maxwell Equations of Software (2012)

Thumbnail
michaelnielsen.org
15 Upvotes

r/learnlisp • • Apr 20 '25

New Learning Common Lisp! Resources?

14 Upvotes

Hi everyone!

I'm a junior dev—if I can even call myself that—and aside from what I'm learning at school, I'd really like to start learning to code and think in Lisp.

I've been reading Paul Graham's ANSI Common Lisp and David S. Touretzky's A Gentle Introduction to Symbolic Computation. Both are truly engaging and quite good in my opinion, but I was wondering if any of you could recommend more didactic material—maybe a course (free or paid), a video series, or any other resources you found helpful when learning.

Thanks in advance! :)


r/learnlisp • • Oct 26 '19

Couple of Lisp questions coming from Clojure

14 Upvotes

Howdy all, I've been playing around with CL for a bit and love it. There are a few silly, simple things I've grown used to using in Clojure and wondering what the CL equivalents are.

  1. comment blocks... I can do something like:

    (comment (+ 1 2) (call-this-fn)

    :end-comment)

...and nothing inside that block is eval'ed if compile the namespace.

2. Commenting out forms without commenting out their parens with #_

So if I have a form embedded in other forms and want to comment it out without losing those parens I can just do this

  (* 1 2 #_3)

and it comments out the 3 without commenting out the last ). Anything like this is CL?

3. A good documentation site with examples.. Clojure has the great clojuredocs.org site that contains examples for most of the core lib. What's a good site for CL beginners to access docs with examples. ...sometimes I need more than the original standard. (using emacs if there is any good packages for this).

thx!


r/learnlisp • • May 22 '19

page update: Functions – the Common Lisp Cookbook

Thumbnail
lispcookbook.github.io
14 Upvotes

r/learnlisp • • Aug 02 '18

Paul Graham Lisp, or "Avoiding the CLOS"

14 Upvotes

I have a question pertaining to common design patterns in LISP, or figuring out the LISP way to accomplish some things that I already understand well in a dozen "common" programming languages. Skip to the TL;DR if you wish to avoid the setup for the question.

http://www.lispforum.com/viewtopic.php?f=2&t=757

In this thread, the post by lispamour » Wed Jul 07, lispamour mentions an excerpt from an article or book of Paul Graham. Having read a number of Paul Graham articles (and part of my inspiration for trying to tack LISP... again) I have a few questions about how to accomplish some common coding patterns in a more LISPY way.

The excerpt I'm referring to specifically is the following:

In practical terms, object-oriented programming means organizing a program in terms of methods, classes, instances, and inheritance. Why would you want to organize programs this way? One of the claims of the object-oriented approach is that it makes programs easier to change...If the program was written carefully to begin with we can make all these types of modifications without even looking at the rest of the code. [Emphasis mine]

Further, Listening to "Uncle Bob" for any amount of time, it becomes clear that OO is not really about "polymorphism, encapsulation, abstraction" .

Getting to the question at hand:

I have been juggling a really simply program in lisp:A loop that sees a player and an enemy battling to the death.

There are character definitions, the player def prompts the player for a name

(defun make-ent (hp atk name)
   (list :name name :hp hp :atk atk))
(defun make-player (hp atk)
    (make-ent hp atk (prompt-read "What is your name")))

A game loop where in enemy and player attack to the death

(defun game ()
    (setf player (make-player 10 10))
    (setf enemy (make-ent 10 10 "bad-guy")
    (loop
        do
            (attack enemy player)
            (attack player enemy)
        while (and (is-alive player) (is-alive enemy))))

Some Actions defined

(defun attack (attacker defender)
    (take-damage defender (getf attacker :atk)))

So Here's my quandry. What I would do next if I were in a language like C++ would be to extract the entity into a class, and create some subclasses for entity.

  • Entity

    • Attack(Entity* Target)

    • IsAlive()

    • TakeDamage()

    • etc.

  • Player<Entity>

    • overrides entity functions and adds own properties

    • vector<Items> Inventory

    • playerRole CharacterClass

    • GetPlayerInput(vector<option> Options)

  • Enemy<Entity>

    • Goblin

      • overrides entity functions and adds own properties...

    • Dragon

      • overrides entity functions and adds own properties...

    • etc...

Perhaps the take-damage method for the Goblin and Damage are different, as the Goblin might have a cowardice check and flee, whereas the dragon will become enraged. And clearly the Player->Attack() method will be different than the Dragon->Attack() method. So polymorphic is in order, either overriding abstract methods, or simply implementing from a blank Interface.

Herein lies the question. If Paul Graham dislikes the CLOS and thinks object oriented design of code is less effective than "careful design", then how would one achieve this kind of polymorphic behavior without using defgeneric or something else from the CLOS? How would you define an attack method which performs a kind of dispatch mechanism to call the correct form of the attack method without some kind of giant cond expression?

(cond
    ((eq attacker-type Player) (player-attack target))
    ((eq attacker-type Dragon) (dragon-attack target))
    ;;; etc

Please, put on your Paul Graham hat, and try to answer my question from his position, as I'm genuinely curious, and not dogmatic about code paradigms. I'm sincerely interested in learning how would one achieve this kind of polymorphic behavior in a natural LISP style without using the CLOS?

If you'd like more information about the code that I'm working on, simple game, can be run with CLISP.

https://github.com/carkat/game-lisp/blob/master/game.lisp

TL;DR

How exactly would you accomplish polymorphism without the CLOS? And what is a Natively LISP pattern to accomplish this?

Is there some kind of typed multiple dispatch (not attached to the CLOS) in LISP that would allow me to call the correct "attack" function based on the input types? Or is it really just a giant switch/cond expression?

EDIT:

I'm interested in the answer to the question, not your opinion of the sources. It is often a useful mental exercise to make an argument from a position you aren't fully inline with, or completely disagree with, if only to solidify your own opinions and beliefs. So please, stick to the subject.


r/learnlisp • • Oct 25 '21

Lux 0.6 is out! Lisp for JVM, JS, Python, Ruby and Lua + static types!

Thumbnail
github.com
13 Upvotes

r/learnlisp • • Feb 27 '19

TIL that CCL has advise and watch

Thumbnail
lispcookbook.github.io
13 Upvotes

r/learnlisp • • Jan 08 '19

Interfacing with your OS – the Common Lisp Cookbook (new sections 3.3 and 3.4, other improvements)

Thumbnail
lispcookbook.github.io
13 Upvotes

r/learnlisp • • Dec 10 '20

What is a symbol?

12 Upvotes

It seems to pretty much everything...


r/learnlisp • • Apr 24 '20

Where and how to learn

12 Upvotes

I'm just starting with LISP across the past few days (hurray for lockdown) and on the whole enjoying myself. I like to think I'm learning a real language, and all the syntax that I understand is really cool and versatile.
But as I work through "The Land of LISP" I find that I'm mostly copying code snippets and understanding maybe 1 line in 10. This is great to get the examples working, but if I want to change anything more complex than a text string or print function I rapidly get lost in the higher level logic steps.
Does anyone have any good recommendations of learning courses, preferably with homework so I can learn by doing rather than learn by copying?


r/learnlisp • • Mar 26 '20

Are there any Guides that Teach you How to Write a Programming Language in Lisp?

12 Upvotes

I've been looking around for them, but I have had little luck so far.


r/learnlisp • • Apr 15 '19

Lisp/Scheme books with compiler/compilation info

12 Upvotes

Hi :)

I've recently decided that I don't know enough (read: anything, really) about compilers, and so I'm making an effort to remedy that. I've always found that lisp/scheme, having deep pedagogical history, tends to have very approachable, from-the-ground-up treatise on various subjects. Furthermore, as it's lisp/scheme, these books are also enjoyable to read! Every book I've read (Friedman or otherwise) has a sense of wonderment which you rarely seem to get from other books. Even SICP has that "spirits in the machine" vein running through it. I figure if there's any compilers book that's going to make the subject engaging, it's going to be a lispy one. Note when I say lisp/scheme, it's to the exclusion of common-lisp, as I've never programmed in or read about it much at all.

Now, with that preamble out of the way, any suggestions on good books or papers relating to compilers and compiling? I already have ..in Small Pieces (steadily working through it), and I'm about to re-read the chapters about register machines in SICP. I remember PAIP having sections on compilers, but I think that was for a logic language? Compiling with Continuations is on the cards, but, see below...

My other question is: how applicable is this knowledge to other languages that aren't mostly-functional/parentheses-based? It seems like a lot of the transformations and intermediate-representations (CPS) wouldn't apply for, say, a language like C or Python. Do you reckon the reader can still get a decent general understanding of the process as a whole, rather than for just lisp in particular?

Thanks! Sorry if this is a bit rambling. I'm still very new to the subject so I feel like I'm wading through information trying to parse (pun intended) everything.


r/learnlisp • • Mar 09 '18

Lisp Style Tips for the Beginner

Thumbnail people.ace.ed.ac.uk
12 Upvotes

r/learnlisp • • Nov 26 '17

Pascal Costanza's Highly Opinionated Guide to Lisp

Thumbnail p-cos.net
12 Upvotes

r/learnlisp • • Feb 23 '14

[Free Book] Common Lisp: A Gentle Introduction to Symbolic Computation

Thumbnail
cs.cmu.edu
12 Upvotes

r/learnlisp • • Feb 29 '24

Learn Emacs Lisp in 30 minutes

Thumbnail
youtube.com
11 Upvotes

r/learnlisp • • Feb 25 '20

Equivalent of Node's http-server or Python's http.server

11 Upvotes

With Node you can start a web server in a directory by running http-server.

Python supports something similar, python -m http.server (it was called SimpleHTTPServer in Python 2).

How to achieve the same in Common Lisp? It seems there isn't anything as simple/quick.


r/learnlisp • • Oct 06 '19

Common Lisp workflow for C++ programmers

11 Upvotes

Can someone point me resources where I can learn about the Common Lisp development workflow? Preferably video resources, please. I've been a C++ programmer for 25 years, and CL seems to be the most foreign experience of all languages I've started to learn. Downloading and compiling ECL with MSVC is no problem, Emacs is running alright with Slime/Swank, QuickLisp works, the REPL is ok... But here I am, staring into the screen, having read a lot about the syntax and loving it, but without a clue on my first step to start a project... Or should I just start adding stuff to the Slime REPL then pull it to a file/buffer/project? My objective is to add functionality to a Windows C++ MFC application using ECL, but embedding, FFI, etc, I can figure out. What is beyond me is how to learn some Lisp project tricks as an old C++ doggo. (A couple years ago I created a TCP client to test a C++ server, it took an afternoon to do anything in SBCL, including stream encryption and decryption, error handling, and learning the libs. It only worked in the REPL but never failed, and everything was done in a stream of consciousness that felt like I've been possessed by an omniscient programming demon. That's what I crave)


r/learnlisp • • Jun 15 '19

Bit-wise operations – the Common Lisp Cookbook (thanks to Sheepduke)

Thumbnail
lispcookbook.github.io
11 Upvotes

r/learnlisp • • Sep 08 '18

Just wrote a brainfuck interpreter in CL. Would appreciate tips, comments, code review, and related. Thanks!

11 Upvotes

This is my first non-tutorial-ish CL program!

There's a pastebin here.

And I used this language specification.

Edit: Made a few small changes, updated pastebin.


r/learnlisp • • Jun 15 '14

Common Lisp: Gentle Introduction to Symbolic Computation - commented solutions

11 Upvotes

Hello.

I would like to share my little project, where I would make a bit more commented solutions to book mentioned in title (available here). While provided solutions are very good, I remember how much of a struggle some of the Lisp syntax was (and still is) for me. I'm quite new to Common Lisp and resulting code is an effect of what I remember from going through a book about a year ago, currently relearning by doing material all over again.

It is far from complete, but I hope it will provide some help. Even as an example of very poor code.

I would appreciate some feedback. Are explanations concise and correct? Are there easier ways of obtaining result? What do you think?

EDIT: I have added some more comments to solutions and I hope to add preliminary chapter 2 soon.

EDIT2: Ok, I think that outside of some minor points the chapter 1 was covered extensively and approaches it's final form. Since I had not received anything other but encouragement via PMs, that format I presented in chapter 1 will be conserved as basis for future explanations. Of course, all errors will be eliminated as fast I can after they will be pointed out to me.

EDIT3: Little state update. I'm terribly ill at the moment, so while I will work on chapter two, my speed and clarity of thought is drastically impaired by quite strong anti-inflammatory/anti-histamine medications. I hope to be better by the weekend.

EDIT4: Started chapter 2 and added a little treat. I feel slightly better, but code will be updated in little snippets. I will edit this posts when new chapter will be added.

EDIT5: Sorry for making you all wait, I have been more or less incapacitated by medications mentioned above. I have corrected some points and going to finish chapter 2 this week. Hope to start chapter 3 and edit all mistakes I have found after analysing code with my friend.