Developing a Lisp

avatar

Over the last thirty-odd years I have worked with many programming languages including BASIC, Pascal, C, C++, Python and Java. One I had heard about, but never had to deal with is Lisp. Recently I have been reading Metamagical Themas by Douglas R. Hofstadter, who also wrote Gödel, Escher, Bach. I found this book in a charity shop.

Book

This is a compendium of columns he wrote for Scientific American in the 80s. It ranges over subjects from Rubik's Cube to self-describing sentences. It also has a couple of chapters on Lisp and these inspired me to try coding with this old language that dates back to the 50s. I like that it is a very consistent language. Everything is a list and can contain further listed nested within it. This does result in lots of brackets/braces.

This is SBCL 2.0.1.debian, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
* (+ 2 4)
6
* (+ 3 5 7)
15
* (car (reverse (list 1 2 3 4 5)))        
5
* (defun rac (l) (car (reverse l)))
RAC
* (rac (list 4 5 6 7 8))
8
* 

As with languages like BASIC and Python you can enter lines or expressions and get immediate results as well as storing programs in files. I installed this version of Common Lisp on Ubuntu Linux. This seems to have some differences to the version in the book as to what functions are available. It is possible to create new functions that would recreate these, e.g. Common Lisp has the (+ a b) function, but the book uses (add a b). We can define that missing function:

0] (defun add (a b) (+ a b))
; No debug variables for current frame: using EVAL instead of EVAL-IN-FRAME.
ADD
0] (add 2 4)
; No debug variables for current frame: using EVAL instead of EVAL-IN-FRAME.
6
0] 

I am still working out what the messages you get mean. Some errors give lots of lines of error text that is not too readable. I expect there are ways to deal with that. The way functions and variables are defined is different to the book too.

I am looking at some other tutorials such as Lisp Koans and The CL Cookbook.

I am not sure when I would use Lisp, but understanding the different features of various languages can give you insights that can be applied elsewhere. Lisp is used as a scripting language for some applications. It has been used a lot in artificial intelligence, which I expect is where Hofstadter used it. Having extra tools in your toolbox is generally a good thing.

I am only playing with trivial examples for now. I need to find some real world use cases to work on.

Code hard!



0
0
0.000
14 comments
avatar

LISP is one of those things.
Its impossible to describe to people because its underlying premise is different.

Its like trying to describe a 2 wheeled motorcycle to a person who had only ever worked on 4 wheeled cars.
Its just different.

But, that difference make certain things really simple.
Like trying to describe thought processes, and thus AI.

Like the print command understands one and multiple, and thus will change syntax.

Our Hero had a sword
Our Hero had two swords

Nothing like the basic, blocky, error prone, printf() of C

I hope you enjoy your learning curve.

0
0
0.000
avatar

It's definitely different, but I like that as it makes me think. I like the elegance of it. Just need to learn more of the basics so I can exploit that.

0
0
0.000
avatar

I have worked with many programming languages including BASIC, Pascal, C, C++, Python and Java

But you never tried the Ada programming language? You should give it a try whenever you have time.

0
0
0.000
avatar

I've not used Ada, but I think a colleague has. There are a few of the classic languages I've not used, but not sure I need to mess with Fortran and Cobol. I've actually done a lot of BASIC for a living, but not for a while now.

0
0
0.000
avatar

cool. that looks like a gem of a book you found! hehe
Sadly my understanding of code is limited to a few tuts on codecademy and lego coding on scratch!

0
0
0.000
avatar

It is definitely an interesting book even if I don't get it all. It's thinking about thinking and that's a good exercise. I want to do more coding for fun. I am sure there are things I could do with Hive itself.

0
0
0.000
avatar

wow! yes that would be exciting!
a few of us are starting a discord channel to discuss the potential of my charity dApp concept and achimmerten's CHARY coin which he already utilises as a charitable concept. Im camping this week but I think we'll be organising a group chat,perhaps next week sometime.
Let me know if you might be interested.
Also I dont suppose you read the comments section on that initial concept post I did? Id love to have your opinion on some of the things grampo mentioned.... especially the use of the rewards pool and how it reduces the value from the big stakeholders. Would that be a major issue with my dApp concept?

0
0
0.000
avatar

I am not feeling up to developing a Hive dapp just yet, but we have a lot of smart people who could come up with something. I do struggle with the economics of Hive, but as I see it people can donate without reducing their stake if they use votes, plus they get something back from the curation rewards. That has to be an attractive model for charity donations as well as for Patreon type support schemes.

I don't see that the big stakeholders lose out as they can keep earning. If anything you could get people investing in Hive so they can give bigger donations to charities and that could push the price up. There needs to be incentives to invest and this is a good one.

@pennsif has been less active here lately, but he was giving 1 SBD per day to charities on Steem for a while. That relies on you having an income to top it up.

I saw some people were cynical about charities, but I think a lot of people still trust them, despite some spending too much on admin. The blockchain makes them more transparent. It would be easy to show how much they were making.

What we need is a conference about this. It could be on-line. Need a good mix of people to toss ideas around.

0
0
0.000
avatar

yes I agree. A good mix of people is what is needed to give this idea a bit of fleshing out and pre-emptive troubleshooting. I think we'll just start smallish to make sure theres a core group of us who can be vaguely on the same page, and then maybe we can offer the discussion up again in a more public forum

0
0
0.000
avatar

I studied Turbo Pascal at college and although I enjoyed it, I was rubbish. Would probably have been better if I spent more time studying it instead of sitting in the local pub with the Pascal book in my bag.

0
0
0.000
avatar

I really liked Turbo Pascal at the time. I did quite a lot with it. They added object oriented programming at some point and I thought that was cool.

0
0
0.000
avatar

Sorry for the late reply. Thanks for posting in the Programming community.

I tend to stick to the more "modern" languages, but I can see how the older languages still have a place. I still like my PHP Even if no-one else does 😂

0
0
0.000
avatar

I have been doing a programming course that is about the theory of things like recursion. This one uses ML, which I did not know at all. I would not use it generally, but it is really elegant and has a lot in common with Lisp. Principles you learn in one language can be applied to others.

0
0
0.000
avatar

Yeah, for sure. The first language is the hardest by a long shot. I'm going to be doing a class on AI soon, so that should be interesting for sure. I do believe it's going to be taught in python though!

0
0
0.000