Live data from Hacker News

Lisp moving Forth moving Lisp

letoverlambda.com

31–37 of 37 posts

Re: Lisp moving Forth moving Lisp

#31
post #3

I finished Let Over Lambda recently. I'm not an experienced lisp programmer but it's strangely readable if you allow yourself to not understand every little detail of the Common Lisp code. For example I hadn't read On Lisp. I had read The Little Schemer. It's a wonderful tour of advanced macro concepts. With several of the macros presented I found myself saying "well that's just x language feature in y" but that's mi…

What are some genuinely useful things macros can do?

https://news.ycombinator.com/item?id=49097840

> Clojure is actually an interesting case here, because it is hosted. So, you can write a Clojurescript macro that runs at compile time on the JVM, but emits code that runs at runtime in Javascript, e.g. instead of blindly loading and executing some JS lib code, your macro can first parse it, analyze it, and conditionally emit Cljs that changes the runtime behavior. Use-cases for code that writes code across a host boundary are rare, yet enormously useful and really difficult to achieve without homoiconic nature of the language.

> Hyperfiddle/Electric is a nice project that effectively utilizes the idea.

... to do something absolutely mind-blowing.

Re: Lisp moving Forth moving Lisp

#32

I finished Let Over Lambda recently. I'm not an experienced lisp programmer but it's strangely readable if you allow yourself to not understand every little detail of the Common Lisp code. For example I hadn't read On Lisp. I had read The Little Schemer. It's a wonderful tour of advanced macro concepts. With several of the macros presented I found myself saying "well that's just x language feature in y" but that's mi…

As I like to say, Forth is the dual of Lisp. They reach the same goal (a programmable programming language) through completely different and complementary methods.

Re: Lisp moving Forth moving Lisp

#33

I'm not fluent enough in Common Lisp for that book, but the patterns in Let over Lambda translate cleanly to Julia. You can have "Let over Lambda", "Let over Lambda over Let over Lambda", "Anaphoric Macros" (though you have to break hygiene with esc(), and in practice should just use the native julia do block), "Reader Macros" (via String Macros), "Pandoric Macros", and so on.

> the patterns in Let over Lambda translate cleanly to Julia

I would be curious to see such a translation.

Re: Lisp moving Forth moving Lisp

#34
post #32

I finished Let Over Lambda recently. I'm not an experienced lisp programmer but it's strangely readable if you allow yourself to not understand every little detail of the Common Lisp code. For example I hadn't read On Lisp. I had read The Little Schemer. It's a wonderful tour of advanced macro concepts. With several of the macros presented I found myself saying "well that's just x language feature in y" but that's mi…

As I like to say, Forth is the dual of Lisp. They reach the same goal (a programmable programming language) through completely different and complementary methods.

What would it be called if we add Smalltalk there, as a third option? A "trial"? No wait, that can't be right.

Re: Lisp moving Forth moving Lisp

#35
post #9

I learned some Forth and played around right before the LLM trend began. It was a mind bending experience, although I quit after a while as the programs were kind of glass sheet quality brittle as they grew. Sometimes I feel I need to start again to keep my brain from losing thinking skills over time.

Similar here, though I didn't quite get as far. I started wondering about performance of all the things, when one has only 2 stacks to work with, and then discovered some library that implemented arrays somehow. I tried using GForth in Advent of Code and needed to read in lines from a file. Lines of different lengths and so on and that's where I failed. I think I would have had to learn a lot about how to use and manage the "pad" or some other surprising technique, that I didn't see anywhere. Since I couldn't manage to read in the lines and discard the old contents of a line, if the next line was shorter, remnants of the previous line persisted and I got wrong line readings. That's where I stopped.

I am sure someone more knowledgeable would have been able to breathe right past that issue somehow.

But I remember one moment that actually humbled me a little: There was a puzzle, where the input were some kind of "instructions" of how to move or for some device. Of course I built some logic that interprets those instructions and only then does something.... but then I saw on reddit, that people simply defined the words that literally are the instructions and took the input as Forth code, duh!!! So simple! Made me feel a little silly.

Re: Lisp moving Forth moving Lisp

#36

I'm not fluent enough in Common Lisp for that book, but the patterns in Let over Lambda translate cleanly to Julia. You can have "Let over Lambda", "Let over Lambda over Let over Lambda", "Anaphoric Macros" (though you have to break hygiene with esc(), and in practice should just use the native julia do block), "Reader Macros" (via String Macros), "Pandoric Macros", and so on.

> the patterns in Let over Lambda translate cleanly to Julia I would be curious to see such a translation.

Take for instance Pandoric Macros that allow you to peek inside the hidden state of a closure:

  # Traditional Let over Lambda
  counter = let x = 100
    () -> x += 1
  end
  counter() # 101
  
  # Pandoric Macro
  captured_x_ref = Core.getfield(counter, :x)
  println("The hidden state is: ", captured_x_ref.contents) # Outputs: 101

Re: Lisp moving Forth moving Lisp

#37
post #32

Earlier quoted context omitted.

As I like to say, Forth is the dual of Lisp. They reach the same goal (a programmable programming language) through completely different and complementary methods.

What would it be called if we add Smalltalk there, as a third option? A "trial"? No wait, that can't be right.

It'd be glib to say that Smalltalk is a Lisp, but Smalltalk's ideas are similar enough to Lisp's that I would put it squarely in the "Lisp camp". The same is true of things like Ruby, about which people have been glib enough to say it's an "acceptable Lisp".
Post reply on HN