@stack it seems CL is the one to learn but I don't want to "waste" time learning that when I can't use it here for CGI. been reading up on Janet unsure it's a good intro to Lisp. what do you think?

๐Ÿ€ gritty

Jan 20 ยท 6 months ago

20 Comments โ†“

๐Ÿš€ stack ยท Jan 20 at 01:41:

Probably not if you care about Lisp... But maybe ok as a little scripting language...

Since arrays are not as malleable as lists, I can guarantee that macros if they exist at all will not be anything like CL. But even without macros, the interactivity and flexibility of anything lisplike is a win.

I also like picolisp, and even made CGIs with it, but it is a quirky and opinionated Lisp, so I do not recommend it.

I would give GCL and ECL a close look, as both can compile reasonable executables, suitable for CGI use. And you will learn the Lisp, CL as you build little CGIs, which is the best way to learn!

I recommend Common Lisp Recipes and On Lisp to read.

I will happily answer questions, and you will have many if your curve is anything like mine.

๐Ÿš€ stack ยท Jan 20 at 01:45:

also trust me you will not waste your time learning CL. programming in CL made me much better coder in other languages. and it's a highly marketable skill if that's a consideration.

๐Ÿš€ stack ยท Jan 20 at 01:59:

Maybe I am too harsh with Janet, it's very lispish. It is a Lisp1, like Scheme, that is, variables and functions share a namespace, which makes macros more problematic. CL is a Lisp 2, with separate namespaces, built for macros.

As a beginner it probably won't make any difference really, as you will likely just write functions for a while.

Janet does have a REPL, so it is interactive.

So if you feel an affinity for it, give it a shot. Many things will map onto CL if you decide to upgrade later.

But I'd still try a real CL, like ECL or GCL if at all possible. There are so many resources and packages made since the 1984 standardization!

๐Ÿ€ gritty [OP] ยท Jan 20 at 03:05:

thank you! I've been reading through the intro guides and it feels like I've never programmed before. I picked up Go in my free time and in two months of nights and weekends, I made Fill. But, the more I read about Janet/Lisp, I keep thinking "this is going to take some effort". You mentioned a curve.

I'll check GCL like you mentioned before, and compare against Janet before I dive in to a mini project. thank you for the offer of help.

Side note, I like that Janet is named after the AI character in The Good Place. Made me laugh, because why not.

๐Ÿš€ stack ยท Jan 20 at 03:23:

learning Lisp was a magical experience. I envy you.

๐Ÿ€ gritty [OP] ยท Jan 20 at 16:27:

you're right, I already have questions. I'm going to try Lem since it seems to have matured over the last few years. I really dislike Emacs so I'm trying to avoid Slime if I can. I'll do the evil mode Vim bindings before full Emacs.

So that gets me to GCL - everywhere just says use SBCL, but I want GCL. Can I just swap out the compiler in Lem you think? Or is it integrated?

And do I really need Roswell

๐Ÿ€ gritty [OP] ยท Jan 20 at 17:20:

Udpate - Okay, so I found the GCLl manual in the .deb package. You'd think this would be easier to find.

๐Ÿš€ stack ยท Jan 20 at 17:53:

Ha, a few years back I wrote XCB bindings for CL and had a Lem backend working in the main codebase -- it was a hoot communicating with my Japanese friends (I was asked repeatedly to stop using Google Translate, as apparently what I was saying was offensive quite often!)

I am sure you can use any CL with Lem, just like with Emacs.

There is a package called SLIME which basically starts a secondary process to communicate with the editor and compile and debug, so if it crashes your main REPL does not break. There will be a small script that starts up the system, and you can change the editor.

There is also SLY, which is basically SLIME for Vim! Although, some people say that the Emacs Vim modes work even better than real Vim.

Personally, I had no problems with Emacs -- I only used maybe 5 keybindings. The main one is "recompile this function" -- the one the cursor is on, and "recompile this file". The rest of the time you are in REPL trying different things.

The best thing about Lisp is that you can just run any function from the command line, and even define new functions right there. So you can easily test as you go.

๐Ÿš€ stack ยท Jan 20 at 18:08:

โ€” https://lisp-lang.org/learn/getting-started/

Portacle is really the quickest way to start -- even if you want to switch to a different editor later. There is a lot of tooling connected with Emacs that every lisper uses, so it will probably be easier to follow tutorials and stuff.

Portacle sets up a separate instance of SBCL and Emacs in a separate directory, configured just right, so you can start it (it takes a minute the first time, but instant later), and it's all ready to go!

โ€” https://portacle.github.io/

All you need to know is basically, from emacs:

M-x slime -- opens a REPL (M is usuall ALT)

C-c C-c -- compile definition (C is usualy CTL)

C-c C-k -- compile file

Slime also integrates tightly with the debugger, so you can examine frames or back out and restart from slightly back in time, once you know what you are doing.

And you MUST switch caps-lock and ctrl keys! Otherwise you will get arthritus, do not repeat my mistakes!

๐Ÿš€ stack ยท Jan 20 at 18:16:

Sorry I am rambling. I am catching a flight in less than 24 hours, but I really want to get you started right.

Do This, in sequence:







๐Ÿš€ stack ยท Jan 20 at 18:28:

My reasoning: it will take you a bit of time learning Lisp before you can actually create useful executables. And you will need to ask questions and follow tutorials. So you may as well use the most common setup to start.

Once you figure out how things are connected, you will be able to connect a different compiler like GCL, and since CL has been standard since the 80s, you will likely hardly notice the difference. But at least you will start with a 'reference platform'.

You may want to keep a Portacle just for that, and have a different production setup.

BTW, Lem looks and feels just like Emacs, so unless you want to be a pure CL person, there is not much to gain. You also couldn't hack it live like Emacs, which I never did anyway.

๐Ÿš€ stack ยท Jan 20 at 19:22:

Roswell is kind of terrible. It has its place to install multiple versions of SBCL and large systems like Lem, I suppose, but I truly hate it and never figured out how to use it well.

It's kind of like those awful things that allow you to install multiple versions of Python (yuk, the worst language ever) and let you select the right version, because everything will crash otherwise.

Luckily, CL is a prime example of a standard actually working CLTL (common lisp the language) in 1984, and later CLTL2 in 1990, finally tweaked and officially blessed by ANSI in 1994. So all CL compilers are standard, and there are dozens of really good free ones like SBCL, which is truly the jet engine of CL. As well as a bunch of really expensive ones that do exactly the same thing, but with an IDE and debuggers that are supposedly better, as well as GUI libraries...

It is really sad to watch people knock CL because it's old and hasn't changed in 30+ years. It's not because it's abandoned, it's because it's that good. It's amazing, really.

And the parentheses -- you will learn to love them, because everything else is kind of stupid. Newbies keep coming up with 'ideas to get rid of parentheses', without realizing just how dumb doing that would be.

Lisp truly merges code and data, and you can operate on code with the same operations like other data. It is a truly programmable programming language, and you can expand it, insert DSLs, generate or mangle code, connect to live applications and peek at variables or recompile individual functions over SSH, or entirely change its syntax if you wish.

๐Ÿ€ gritty [OP] ยท Jan 21 at 03:53:

i was wrestling with gcl and slime most of the day. documentation on how to use gcl is lacking, from a tutorial standpoint. I understand its all ansi but they each have their own particulars. slime doesn't support gcl, which took me a bit to figure out why it wasn't working. lem wouldn't compile despite my best efforts.

I am primarily thinking how I would use sbcl in general, just to learn and application. I want to stick to gemini but lisp executables don't seem the best for that purpose, so I'm thinking maybe an scgi application. I don't know what I'd write outside of gemini tbh, I like the user base.

binaries for janet aren't that small either it seems.

I want to learn lisp, but I need a project to motivate me. thoughts?

๐Ÿ€ gritty [OP] ยท Jan 21 at 03:58:

sbcl has a script mode that I wonder how fast/slow it is. might be worth researching.

๐Ÿš€ stack ยท Jan 21 at 04:29:

Slime on Emacs or Lem needs the CL to run a Swank server, which should be available for gcl, but who knows. And yeah, I understand you don't like Emacs, but I am not sure Lem is the way to go to get started.

Like I said, if you download Portacle you will have everything running in seconds (I just did out of curiosity), with a slightly old SBCL but good enough for Australia, as they say.

BTW, if you are running your own server, I am pretty sure there is a CL gemini server, and you don't need 'cgi' -- you run all kinds of in-process stuff! You can even ssh into a running server and recompile functions or alter variables!

๐Ÿš€ stack ยท Jan 21 at 04:34:

The problem with scripting SBCL is that you will have something like 100MB reserved (a lot less used), and even compressed the app is going to be like 15MB. I suppose these days it may be ok, since JS backends routinely take 50MB for a 'hello world'...

Another way to do it if you don't control the server is to spin up SBCL with a server process that listens on a socket or something and stays up permanently, and your cgi is a simple connector that reads data and writes it to the lisp server (and reads from it). Your logic will be in Lisp, and CGI tiny.

๐Ÿ€ gritty [OP] ยท Jan 21 at 11:55:

ohh interesring! that may be an option. yeah slime wouldn't run with .emacs set to gcl. not sure why. sbcl worked fine.

๐Ÿš€ stack ยท Jan 21 at 13:57:

you have to run a few magic lines on the lisp side to install and start-up the swank server, even for SBCL... You can't just 'set' a chosen CL without it. However. you can manually start it on a socket from CL and connect Slime to it, I can help you with that if you can't find examples

But yeah, running a Lisp Gemini server is by far the best option, and a Lisp daemon with CGI requestors is second best if you have no permission to open outside sockets.

๐Ÿ€ gritty [OP] ยท Jan 21 at 20:14:

This blog post was very helpful and was in line with what you've been saying below. I'd recommend to others starting out.

โ€” A Road to Common Lisp

๐Ÿ€ gritty [OP] ยท Mar 07 at 02:30:

I'm getting ahead of myself but I want to make an scgi application since CL isn't good for scripting. there's CL-SCGI but what I really want is what it depends on, a unix socket library. I've tried a few and get both the gemini server(molly brown) and the cl scgi app to connect to a socket but I can't read or send data over that stream. I have a few more things to try, but that's where I'm at: molly sending a formatted scgi client request and literally printing the request stream to the console in cl.


Source