Live data from Hacker News

Show HN: Full Stack Lisp – A book in progress about writing Common Lisp apps

fullstacklisp.com

101–110 of 110 posts

Re: Show HN: Full Stack Lisp – A book in progress about writing Common Lisp apps

#101
post #99

Earlier quoted context omitted.

Speaking as a longtime (nearly 30 years) Common Lisp programmer, I agree with what you've said here, but I would add one thing more. Common Lisp is one of a small number of languages that represent an approach to programming that is so out of fashion nowadays that it seems to be in danger of becoming extinct. The approach is one that treats programming as an exercise in interactively shaping a living thing in real ti…

Interesting comment. I suppose it is along roughly the same lines as Paul Graham's essay about top down vs. bottom up programming (?) Read it a while ago, not handy on mobile right now. What is it about CL / Lisp that makes people think it more suitable than other languages for using in such a style? It cannot be only the REPL, since others have them too. Or are CL REPLs more powerful? I've only explored one a bit, F…

You're asking for a list of functions that takes interactive programming into account, and I'll give you one, but first I want to make the point that it isn't all about lists of functions or features. It's about a language and system being designed from the start with interactive programming in mind. If we focus on language features in the sense of grammar, syntax, and functions, we're likely to miss the point. You don't for example, turn a programming system based on programming-as-construction into one based on programming-as-teaching by adding functions. You need to design the system from that start with the assumption that you will be building your application interactively while it runs.

Common Lisp isn't the only language designed that way. Older Lisps were, too. So was Smalltalk. But that view of programming is now so far out of the mainstream that even new Lisp dialects don't reflect it.

But you asked for examples of other Common Lisp functions that take interactive programming into account. Instead I'll offer a mixed list of functions, special forms and design features. Don't assume it's exhaustive; there are too many to reasonably expect that I can list them all.

- COMPILE doesn't mean compile a file; it means compile an arbitrarily chosen function that might not even be in a file anywhere

- EVAL-WHEN enables you to control whether forms are evaluated at compile time, load time, or toplevel-evaluation time, because you might have program text that is intended to be evaluated at any combination of those times. Again, its behavior is independent of whether the affected forms appear in files (though obviously that's the most common place for it to appear).

- namespaces are represented by packages, which are runtime objects that you can interactive inspect and modify. The namespaces represented by packages have a concept of public and private names, but you can't really hide private names, because if you could it would be impossible to change them at runtime. Common Lisp is allergic to features that are impossible to change at runtime. It has to be in order to support interactive programming.

- CLOS has a whole protocol for changing the definitions of classes and functions while a program runs. CHANGE-CLASS and UPDATE-INSTANCE-FOR-REDEFINED-CLASS are members of that protocol. SO are REINITIALIZE-INSTANCE and SHARED-INITIALIZE and UPDATE-INSTANCE-FOR-DIFFERENT-CLASS and ADD-METHOD and REMOVE-METHOD and DEFINE-METHOD-COMBINATION.

- introspection is pervasive in Common Lisp. It has to be. It's an interactive system in which you build programs while they are running. You have to be able to examine every part of the running program as it runs. So it has scads of functions for examining the structure and value of everything in the running program--and not just examining it, but changing it. There's BOUNDP and SLOT-BOUND-P and SLOT-EXISTS-P and FMAKUNBOUND and FIND-METHOD and TYPE-OF and CLASS-OF and SYMBOL-FUNCTION and so on and so forth. DISASSEMBLE, which decompiles compiled code so that you can interactively examine what the compiler produces, is part of the language standard.

- the assumption of interaction is also pervasive. TRACE and INSPET are part of the standard. So is BREAK--a function that causes the program to enter an interactive breakloop in which you can examine the dynamic state of the suspended computation, inspect and change the values of local variables, redefine functions and methods, and resume the interrupted computation when you think you've made the changes you wanted.

- you asked about the condition system. You could say that it's Common Lisp's implementation of exceptions, and that would be true as far as it goes, but it would also ignore important aspects of its design. Yes, you can raise a condition, just as you can raise an exception. However, the normal behavior of an unhandled condition is to drop you into an interactive breakloop from which you can modify the suspended computation and all of its accessible state.Conditions provide restarts -- a mechanism for offering a set of options for resuming control at a place of your choosing, or of selecting how to resume execution under program control. Conditions are also more generally useful as ways to manage nonlocal transfers of control.

- it's not explicitly part of the standard, presumably because it was such a fundamental assumption of Lisp programmers when Common Lisp was being defined, but nearly all Common Lisp implementations support saving a serialized form of the dynamic run-state of the system that can later be reloaded to reproduce that dynamic run-state exactly. It means that you can save the exact environment that you're working in right now, complete with interactive state like breakloops and so forth, and resume it later. You can, for example, discover a bogu, dig into what you can find out by inspecting the dynamic state of a breakloop triggered by the bug, and save off that whole dynamic state, then reload it on another machine so that you can show it to a colleague in all its glory.

There's more, of course. It's hard to reduce a design that is all of a piece to a list of discreet features.

Re: Show HN: Full Stack Lisp – A book in progress about writing Common Lisp apps

#102

or you realize Perl, Ruby, Python give you everything good from Lisp anyway with an environment and packages that can talk to the real world, and that macros and metaprogramming are massively overrated and a danger in almost any hands that touch those features. Ask me how long I spent banging my head against the wall trying to get OpenGL working in CMUCL with Alien. Jesus jumping-jack Christ. I can only hope things h…

We detached this subthread from https://news.ycombinator.com/item?id=11825955 and marked it off-topic.

We gave you the benefit of the doubt originally, despite the nasty embers burning in your comment, but then you went full flamewar downthread. We don't want that on HN, so please don't do it again.

Re: Show HN: Full Stack Lisp – A book in progress about writing Common Lisp apps

#103
post #67

Earlier quoted context omitted.

> Perl, Ruby, Python give you everything good from Lisp So where are the: - AOT compilers to native code - REPL environments with GUI debuggers, with fix-and-continue? - Ability to do systems programming without having to use an external language? - Macros

> Macros You obviously didn't read my post before listing your pet list of things that are irrelevant. Macros are bad. They are only a benefit to those that are delusional enough to think they are a rockstar. > Ability to do systems programming without having to use an external language? I have no idea what this even means today. "systems programming". Are you from 1980? Perl is vastly more connected to *ix than any…

Personal attacks are not allowed on Hacker News. We ban accounts that do this, so please don't do it again.

Usenet-style programming flamewars are particularly not wanted here. The founding idea of HN is to try to learn from the community-destroying experiences of the past, and not repeat them, or at least stave them off.

Re: Show HN: Full Stack Lisp – A book in progress about writing Common Lisp apps

#104

Very nice, I love seeing new Common Lisp books being written. (BTW, I also have a Common Lisp book on leanpub.com - a great company to work with if you are a writer). It is especially good to see a complete caveman2 application developed in the book.

I am in the middle of reading Adam Tornhill's 'Lisp for the Web', and I just stumbled on this book.

Yes, Lisp seems to me to be getting more exposure, but that may be my 'Lisp-colored sunglasses' ;)

Is caveman2 a lot easier, or what other advantages does it have over piecing stuff together?

I have always liked and programmed in Lisp, but not for the Web, so I need to get up to speed with Web frontend/backend programming again for personal use, not a job.

OT: Mark, I am on your 3 edition of 'Loving Common Lisp', and I really appreciate the Networking chapter update, and your smooth writing style!

Re: Show HN: Full Stack Lisp – A book in progress about writing Common Lisp apps

#105
post #35
post #25

Earlier quoted context omitted.

+1. Kenny Tilton's blog is also great for that kind of thing. "You know Lisp is the perfect language precisely because it lost its momentum (died) and lives on. Other languages need their Next Big Thing momentum." http://smuglispweeny.blogspot.com/2013/08/wow-even-lispers-h...

I think the journey of a Lisper inevitably ends up with realizing that Common Lisp is not an acceptable Lisp. Then you start searching for an acceptable Lisp. You look at Tcl, at Prolog, Io, Rebol, and Icon; you learn Shen, try Scheme and Racket, appreciate Smalltalk and Self and Slate, wrap your head around Forth and Joy and Factor… and the whole time you write Common Lisp. Because there is no acceptable Lisp.

.. and, finally, you realise that Common Lisp is an acceptable Lisp (because when you learn it well enough you start to understand how to tune it to make it acceptable for you personally ;)

Re: Show HN: Full Stack Lisp – A book in progress about writing Common Lisp apps

#106

Earlier quoted context omitted.

That's a very complicated question. Common Lisp has many implementations, with different strengths and weaknesses. For example SBCL and CCL are good general purpose implementations. They're fairly performant, especially SBCL, properly optimized code can compete for C-like performance. ABCL gives you Java integration, not as nice as clojures for example, but perfectly usable IMO. ECL has a fairly small footprint and i…

Speaking as a longtime (nearly 30 years) Common Lisp programmer, I agree with what you've said here, but I would add one thing more. Common Lisp is one of a small number of languages that represent an approach to programming that is so out of fashion nowadays that it seems to be in danger of becoming extinct. The approach is one that treats programming as an exercise in interactively shaping a living thing in real ti…

I wrote some similar thoughts here: http://lisperator.net/blog/why-lisp/ (in the "organic growth" section). Sadly I don't get to do much Lisp these days, but it remains my favorite programming language (CL, more exactly).

And yeah, it's sad that "programming-as-teaching" fades out of fashion. Now that I know what it's like, working in an environment that doesn't support it always leaves a bitter taste. Let's just hope more people try it, because it's addictive.

Re: Show HN: Full Stack Lisp – A book in progress about writing Common Lisp apps

#107
post #99

Earlier quoted context omitted.

Interesting comment. I suppose it is along roughly the same lines as Paul Graham's essay about top down vs. bottom up programming (?) Read it a while ago, not handy on mobile right now. What is it about CL / Lisp that makes people think it more suitable than other languages for using in such a style? It cannot be only the REPL, since others have them too. Or are CL REPLs more powerful? I've only explored one a bit, F…

You're asking for a list of functions that takes interactive programming into account, and I'll give you one, but first I want to make the point that it isn't all about lists of functions or features. It's about a language and system being designed from the start with interactive programming in mind. If we focus on language features in the sense of grammar, syntax, and functions, we're likely to miss the point. You d…

Thanks for the detailed answer; appreciated. Will reply again if any more comments after reading in detail.

Re: Show HN: Full Stack Lisp – A book in progress about writing Common Lisp apps

#108
post #95

Earlier quoted context omitted.

Some advice for Clojure that applies to all lisps: write code bottom up in small pieces making heavy use of the repl for development. Really understand what your small piece of code does, clean it up, put it in a separate small file, and once you have confidence in it think of it as a library that just works.

Isn't that the same as many other languages is you take a tdd approach?

no. You test by plugging it into the repl and running some stuff through it.

(Tdd is writing some tests then making some code that passes them. Which, imo is cart before the horsism)

Re: Show HN: Full Stack Lisp – A book in progress about writing Common Lisp apps

#109

Earlier quoted context omitted.

That's a very complicated question. Common Lisp has many implementations, with different strengths and weaknesses. For example SBCL and CCL are good general purpose implementations. They're fairly performant, especially SBCL, properly optimized code can compete for C-like performance. ABCL gives you Java integration, not as nice as clojures for example, but perfectly usable IMO. ECL has a fairly small footprint and i…

Speaking as a longtime (nearly 30 years) Common Lisp programmer, I agree with what you've said here, but I would add one thing more. Common Lisp is one of a small number of languages that represent an approach to programming that is so out of fashion nowadays that it seems to be in danger of becoming extinct. The approach is one that treats programming as an exercise in interactively shaping a living thing in real ti…

I barely disagree. In that that 'way' is not dying, it's just that other languages spread the fundamental layer away just enough so that what people have for free in lisp/st/forth/ml takes a whole new organ (IDE) to reinvent flatly, but it's constantly reinvented.

These systems are so coherent they solve themselves in and out, but if you mess a few things it's now compounded interests fueling your technological debt.

Re: Show HN: Full Stack Lisp – A book in progress about writing Common Lisp apps

#110
post #10

Can you include a good description of reading macros? I'm still looking for good explanation with examples of their power.

Read macros are great because you can use them to turn the Common Lisp parser into a parser for any language you want (no restrictions on the grammar), so you essentially get compilers for free. I wrote a one-pass C preprocessor and parser in just under a thousand lines of code: https://github.com/vsedach/Vacietis/blob/master/compiler/rea...
Post reply on HN