Is there a full featured editor that's hosted in the SBCL image itself? I vaguely recall CMUCL had something of the sort. It used to be you had to actually specify GNU Emacs, but nowadays it's pretty much the only Emacs anyone means.
Ask HN: I want to start learning Lisp. Where do I begin?
141–150 of 211 posts
Re: Ask HN: I want to start learning Lisp. Where do I begin?
#142I only know Emacs well. Checked out VS code for Clojure a while ago and it wasn't even close. Clojure IDE "Cursive" is supposed to be good, but never tried and not sure if you want to invest time in an ad hoc IDE. It seems to me lispers don't want to discourage people by recommending Emacs, but at the end of the day, most people who stick with it tend to be Emacs users.
Re: Ask HN: I want to start learning Lisp. Where do I begin?
#143I remember wanting to learn lisp. I got stuck and reached out to the community for help. And found them to be very hostile. I decided I had better things to do with my time.
As a counter-anecdote (giving us anecdata), I did not have this issue when I got started. r/lisp and comp.lang.lisp were pretty welcoming. I don't do much on IRC, but my limited time there was productive and friendly. There were (probably still are) a few assholes and zealots on comp.lang.lisp, but they were easy enough to ignore (killfiles are your friends). I think some people also got a bit testy and short there b…
I tried learning CL back in 2006 and read a quickstart guide from the #lisp IRC channel. It had sentences in it like:
“ Using a plain text editor without any runtime connection to your Lisp implementation just because you think you prefer its keybindings is stupid and self-defeating.”
And
“Follow these directions or risk our wrath, or at least unsympathetic attitudes!”
The document, mercifully, doesn’t appear to exist any more. Maybe when I called them on it at the time they realized that maybe there’s a better way and changed it. But it definitely made a poor first impression.
Re: Ask HN: I want to start learning Lisp. Where do I begin?
#144Earlier quoted context omitted.
I tried Clojure a bit and, compared to CL, I find it bloated :S Installing a library takes ages, a lot of memory, and I can't do it from the REPL (so I must quit my development environment, and start it again). CL feels very snappy. I can even install a new library to a running web app. I know it's dangerous, but it works and it helped me already :)
yes but clojure can get you a job
Re: Ask HN: I want to start learning Lisp. Where do I begin?
#145If you install `clojure` you can start the interpreter with `clj` and also type in similar expressions, like:
(* 3 7)
There are a couple of differences to Common Lisp, though.The fun thing about Lisp is that you can pass any number of parameters to functions, like "+", so that expressions like this also works fine:
(* 1 2 3 4 5 6 7)
The next thing to know is that the first element within () is interpreted as the function, while the rest are interpreted as parameters. Then how do you represent a list like (1 2 3) without Lisp thinking that "1" is the function, you surely ask? You prefix it with ', like this: '(1 2 3). If you type '(1 2 3) into the `lispi` or `clj` prompt, they will print (1 2 3) right back at you.A fundamental concept in Lisp is to get the first element of a list (the head) or the rest of the elements (the tail). For historical reasons the head is called CAR and the tail is called CDR in lisp. Everyone has just accepted that this is the way of Common Lisp by now. In Clojure, "first" and "rest" are used instead of CAR and CDR, as the heathens they are.
Since regular for loops are for wimps and snowflakes, iterating in traditional Lisp mainly centers around how to do the same thing using CAR, CDR and recursion.
Before we can do that, let's define a function that adds 2 to the given number:
(defun addtwo (x) (+ x 2))
Note that "defun" is the function for creating functions that takes, roughly speaking, three parameters: the function name, the function parameters and the function expression.If you type it into "lispi" you can use the function afterwards, and get the result 42:
(addtwo 40)
Also, all lists in lisp are really just the head and the rest, so creating lists can be done by combining a head with the rest of a list, using cons, like this: (cons 1 ())
Which is equivalent to this (but signifies that quoting was intended): (cons 1 '())
And this: (cons 1 nil)
All three of the above expressions returns a list with one element (1), which means a head of 1 combined with an empty tail. Lists are constructed by appending heads to existing (or empty) tails.Creating a function that takes apart a list into a head and a tail and then combines them again can be done like this:
(defun combine (xs) (cons (car xs) (cdr xs)))
"xs" is the name of the function parameter, which is a list.The combine function can be called like this:
(combine '(1 2 3))
And will return: (1 2 3)
If you wish to edit code in a file instead of interactively, where the arrow keys may not always work, try putting this in a file named "main.lsp": (defun hello ()
(write-line "Hello, World!"))
Then run the desired function with:lisp main.lsp hello
Now to create a for-loop replacement in Common Lisp, for people with hair under their arms, using CAR and CDR and recursion. This program will print each number in the given list, with an axe emoji after each number (HN removed it, please insert an appropriate unicode emoji instead of the x):
(defun lumberprint (n)
(write n)
(write-line "x"))
(defun f (xs)
(unless (null xs)
(lumberprint (car xs))
(f (cdr xs))))
(defun main ()
(f '(1 2 3)))
Save as "main.lsp" and run with "lisp main.lsp"."unless" takes a condition and a list of statements. "null" checks if a list is empty. "write" outputs the given argument, but not a newline. "write-line" outputs the given argument and also a newline.
This should be enough to get you started. Then read SICP and draw the rest of the owl.
Best of luck!
Re: Ask HN: I want to start learning Lisp. Where do I begin?
#146I found it super helpful understanding everything there is about Lisp, and you can move from there.
Re: Ask HN: I want to start learning Lisp. Where do I begin?
#147This is a bit tangential but what helped me most in picking up Lisp was writing my own. Until I worked through Make A Lisp [0] I don't think I really "got" Lisp. You can work in whatever language you're familiar with. You build a Lisp similar to Clojure and learn a lot of important concepts by implementing them. [0] https://github.com/kanaka/mal
Re: Ask HN: I want to start learning Lisp. Where do I begin?
#148Earlier quoted context omitted.
As a counter-anecdote (giving us anecdata), I did not have this issue when I got started. r/lisp and comp.lang.lisp were pretty welcoming. I don't do much on IRC, but my limited time there was productive and friendly. There were (probably still are) a few assholes and zealots on comp.lang.lisp, but they were easy enough to ignore (killfiles are your friends). I think some people also got a bit testy and short there b…
I’m glad you had a better experience than I. I tried learning CL back in 2006 and read a quickstart guide from the #lisp IRC channel. It had sentences in it like: “ Using a plain text editor without any runtime connection to your Lisp implementation just because you think you prefer its keybindings is stupid and self-defeating.” And “Follow these directions or risk our wrath, or at least unsympathetic attitudes!” The…
Re: Ask HN: I want to start learning Lisp. Where do I begin?
#149Racket Scheme & SICP is a fun way to start playing, especially if you are into theoretical concepts of CS and programming, like higher order programming and abstraction. The documentation for Racket is excellent, see e.g. https://docs.racket-lang.org/quick/index.html ... and many people have created online resources to adapt SICP to Racket, as well as other learning texts. I like Beautiful Racket, e.g. https://beauti…
ClojureScript is great if you're drawn towards the "production use" side as pixelmonkey said and already have knowledge of the Javascript / Node ecosystem.
Re: Ask HN: I want to start learning Lisp. Where do I begin?
#150Earlier quoted context omitted.
As a counter-anecdote (giving us anecdata), I did not have this issue when I got started. r/lisp and comp.lang.lisp were pretty welcoming. I don't do much on IRC, but my limited time there was productive and friendly. There were (probably still are) a few assholes and zealots on comp.lang.lisp, but they were easy enough to ignore (killfiles are your friends). I think some people also got a bit testy and short there b…
I’m glad you had a better experience than I. I tried learning CL back in 2006 and read a quickstart guide from the #lisp IRC channel. It had sentences in it like: “ Using a plain text editor without any runtime connection to your Lisp implementation just because you think you prefer its keybindings is stupid and self-defeating.” And “Follow these directions or risk our wrath, or at least unsympathetic attitudes!” The…