News for hackers. Stuff that matters.
Re:Lisp Machine Manual (1984) by AnimalMuppet on Wednesday September 06, 2017 @07:12PM (#15187892)
> I don't think awareness of Lisp was evenly distributed among people developing on PCs in the time period when the network advantage was obtained.

My assertion is that you're looking at the wrong decade for C's network effects. You should be looking at the PDP-11 decade, not the PC decade. And in the PDP-11 decade, I believe there was much wider awareness of Lisp. (I was a kid then, so that's just my impression. I don't actually know.)

> It was probably a reach for me to say there wasn't anything to port. But what would someone have wanted to port? A graphical application that ran on a Lisp machine would have made assumptions about the display that aren't true about a PC. An academic AI program would have been too short on resources to be much use.

Fair point.

> And I don't have an explanation for why nobody developed a Lisp-like language that had explicit allocation.

Lisp allocates all the time. You have to work hard if you want it not to. So if you want explicit allocation, you'd have to invoke it all the time, and it would really get in the way - far more than it does in C. (Far more things are allocated in Lisp than in C.)

But you could mean "why didn't someone make a Lisp where you could explicitly allocate a block of memory if you chose to"? You wouldn't have to always use it in that case, so my objection in the previous paragraph doesn't apply. But if you did that, first, the garbage collector would have to know how to clean up those objects (or else you'd have to explicitly free them), and second, you'd have to be able to do something with it. Lisp, to my (very limited) knowledge, doesn't have a way to treat an allocated block of memory as anything other than a cons pair. You'd have to add that to the language. You could do it, but it would be something tacked on to the side of the language, not something you could use the same as the rest of the language.

Re:Lisp Machine Manual (1984) by sedachv on Thursday September 07, 2017 @02:34AM (#15189554)
> And in the PDP-11 decade, I believe there was much wider awareness of Lisp. (I was a kid then, so that's just my impression. I don't actually know.)

I was not around but from the literature it seems Lisp trolls existed even back then - for example Ted Nelson's Computer Lib / Dream Machines contains some very negative and very mistaken statements about Lisp, and it was published in 1974.

> Lisp allocates all the time. You have to work hard if you want it not to. So if you want explicit allocation, you'd have to invoke it all the time, and it would really get in the way - far more than it does in C. (Far more things are allocated in Lisp than in C... Lisp, to my (very limited) knowledge, doesn't have a way to treat an allocated block of memory as anything other than a cons pair.

Between this comment and your ignorance of the difference between a PDP-10 and a PDP-11 I get the impression that you do not know anything about computer history or about Lisp or about what constitutes memory allocation. Please stop trolling.

Re:Lisp Machine Manual (1984) by AnimalMuppet on Thursday September 07, 2017 @06:02PM (#15196173)
> Between this comment and your ignorance of the difference between a PDP-10 and a PDP-11 I get the impression that you do not know anything about computer history or about Lisp or about what constitutes memory allocation. Please stop trolling.

Thank you for your charitable assumptions. You might be even more charitable and state what's wrong with what I said.

My understanding is, 1, that every newly-created cons pair requires an allocation, 2, that every new list entry is a new cons pair, and 3, that you can avoid creating them but you have to keep a very careful eye on your code in order to do so - the normal way of writing code will cons frequently.

Which, of those statements, do you consider to be wrong, and why?

Re:Lisp Machine Manual (1984) by sedachv on Thursday September 07, 2017 @09:15PM (#15197207)
> Which, of those statements, do you consider to be wrong, and why?

Every one of them. You do not understand the difference between what the program code does and what the programming language implementation does, and your underlying assumption is that there is a difference in how a Lisp runtime without garbage collection would manage memory allocation and how the C standard library manages memory allocation.

I am going to assume you need a stdlib.h refresher:

    void *malloc(size_t size);

    void free(void *ptr);
How do you think free works? How would you write a linked list implementation in C?

I just happened to have done some software archaeology on a Lisp implementation without a garbage collector a while ago (https://github.com/vsedach/Thinlisp-1.1), and the memory allocation and lifetime management is exactly the same there as in C++ - manual management and dynamic extent regions (RAII).

Now I really want to get pedantic with each of your points, because individually each is wrong in interesting ways:

> 1, that every newly-created cons pair requires an allocation

This statement is a redundant tautology ("every new allocation requires an allocation"), but even the correctly phrased assertion that "CONS always allocates" is not always true:

https://en.wikipedia.org/wiki/Hash_consing

http://3e8.org/pub/scheme/doc/lisp-pointers/v1i3/p17-white.p...

> 2, that every new list entry is a new cons pair

Again, redundant, and again, not always true, because of hash consing and CDR coding:

https://en.wikipedia.org/wiki/CDR_coding

> 3, that you can avoid creating them but you have to keep a very careful eye on your code in order to do so - the normal way of writing code will cons frequently.

If you do not need to allocate lists, do not allocate lists. There is no "normal" way of writing code that exists outside of what your performance requirements are, what the language semantics are, and what the language implementation provides in terms of those semantics. The only situation where you cannot avoid frequent allocations is when all the data structures are immutable.

Re:Lisp Machine Manual (1984) by kazinator on Thursday September 07, 2017 @11:01PM (#15197607)
Hash consing will break if conses have to be mutated, or if their identity has to be attributed with data specific to the circumstances of their creation (such as attributing expressions read from files with file and line number information).

AnimalMuppet is basically right. Normal, everyday Lisp code does quite casually allocate memory: more or less of it depending on circumstances.

Implicit dynamic memory allocation occurs in places where in the analogous circumstances in C it wouldn't occur.

The abstract semantics of Lisp (such as ANSI CL) call for dynamic allocation of all lexical variable bindings, because in the abstract semantics, these have indefinite extent.

Each time a lexical scope with variables is entered, dynamic allocation takes place to create the fresh bindings, which enables continued access to these bindings after that scope's evaluation terminates.

Such allocation is only avoided as a matter of optimization: the Lisp compiler analyzes the scope to determine that no escaping closures are created in it and then the bindings can be allocated stackwise (dynamic extent) similarly to C's automatic storage.

Nothing in ANSI CL guarantees to you that (let (x)) will not allocate a piece of memory for x which endures after the form terminates, and has to be reclaimed.

Re:Lisp Machine Manual (1984) by AnimalMuppet on Thursday September 07, 2017 @10:18PM (#15197433)
Hold on there, cowboy. You're still assuming the worst about me, with no evidence, and that gets annoying by the second or third time.

> You do not understand the difference between what the program code does and what the programming language implementation does

False.

> I am going to assume you need a stdlib.h refresher

False, and even if I did, that wasn't much of one.

> How do you think free works?

I've seen an implementation.

> How would you write a linked list implementation in C?

I've had the pleasure (?) of doing so.

On to the meat of your reply: I was not aware of any non-garbage-collected Lisps. Still, isn't it fair to say that such Lisps are by far the exception?

I was under the impression that immutable was the normal way to write Lisp. ("Normal" here not meaning "the one right way" or "the way the language tries to make you write" - Lisp doesn't do that - but more "the way the majority of people write it".)

And even if you're going to not write it that way, if you really want to avoid allocations, don't you have to also be careful what library functions you call, since many of them cons?

Re:Lisp Machine Manual (1984) by sedachv on Friday September 08, 2017 @04:15AM (#15198668)
> Hold on there, cowboy. You're still assuming the worst about me, with no evidence, and that gets annoying by the second or third time.

The evidence is that you insist on posting a bunch of "I was under the impression" bullshit instead of spending a few minutes using a search engine. That is what is really annoying. Why do you think that your basic thesis that programs written under the assumption that there is garbage collection will not work well when there is no garbage collection is a novel or insightful contribution to the discussion about the original post?

Re:Lisp Machine Manual (1984) by PuercoPop on Thursday September 07, 2017 @03:23PM (#15194930)
> Lisp trolls existed even back the

Recently while reading, Appel's Compiling with Continuations, I read some mistaken claims about Lisp and scope, one doesn't have to be a troll, which requires intent, to make ignorant claims about Lisp, parsing or any subject. Although the amount of ridiculous arguments from people who clearly haven't used it (or at most used it very briefly) does make one's blood boil at times.

Re:Lisp Machine Manual (1984) by fusiongyro on Thursday September 07, 2017 @05:04PM (#15195694)
I agree, but just because I'm curious, what did Appel say? Different dialects of Lisp have had different scoping rules, but beyond that I don't know what is true or false. I believe earlier ones were dynamically scoped, because I vaguely recollect that lexical scoping was an important change in Common Lisp and Scheme. Of course Common Lisp has a special way to ask for dynamic scope.
Re:Lisp Machine Manual (1984) by PuercoPop on Thursday September 07, 2017 @09:57PM (#15197359)
Can't find the quote I was remembering, but it said that Lisp didn't had lexical scope. The book was published in '92, so Lisp already had lexical scope. (Which was introduced by Scheme IIRC)

Here is another one I found looking for the quote I was remembering.

> "It has higher-order functions, meaning that a function can be passed as an argument and return as the result of another function – as in Scheme, C and Haskell, but not Pascal and Lisp.

Re:Lisp Machine Manual (1984) by fusiongyro on Friday September 08, 2017 @12:14AM (#15197809)
Wow. Well, at one time, maybe Lisp did not have that? It certainly did by the time this book was written though.
Re:Lisp Machine Manual (1984) by kazinator on Friday September 08, 2017 @12:41AM (#15197887)
"Lisp" still hasn't; it is a family which comprises various dialects, many of which have lexical scoping, but some of which don't, like Emacs Lisp (which only had dynamic binding until recently and now supports lexical scoping, but not by default).
Re:Lisp Machine Manual (1984) by fusiongyro on Friday September 08, 2017 @01:51AM (#15198147)
My comment was directed at the quote about higher-order functions, which is a more legitimately surprising thing than something about scope. And of course we're talking about whatever would have been considered "Lisp" by Appel in 1992, even though you and I might know better and be more precise today.
Re:Lisp Machine Manual (1984) by fusiongyro on Thursday September 07, 2017 @12:26AM (#15189138)
> My assertion is that you're looking at the wrong decade for C's network effects. You should be looking at the PDP-11 decade, not the PC decade. And in the PDP-11 decade, I believe there was much wider awareness of Lisp.

This is the crux of it I think, and unfortunately my flashlight isn't bright enough to get much further. I was born in 1981, so this is all reconstruction for me. Unfortunately, the people who were there are getting scarce. Anyway, thanks for talking it through with me!