Sorry for beating a dead horse but...
What I was getting at when I invoked lisp is because I was thinking
of the ability to debug live processes as opposed analyzing dead
programs (core dumps). With lisps you can not only access a lot of
the dynamic state of the program at the language level but (in theory)
you may also be able to fix the problem and let the process continue.
Especially when a program crashes rather infrequently, having access
to only a core dump & stack trace can be quite frustrating. Why do we
continue to live in a virtual "batch processing" world when it comes
to dealing with such problems? [I once spent a month analyzing a problem
a customer reported. I had guessed what the problem might be but couldn't
reproduce it. In their live setup, it took 15 minutes to catch the bug
with a logic analyzer!]
The other thing both you and Rob pointed out is that even "well-tested"
programs can crash. While you can use more type annotations even in
dynamic languages to catch type errors, types are not sufficiently
expressive so you always have that potential problem (and we can't
*prove* large programs to be bug free). It is of course better to do
all the testing you can but that typically occurs in "lab conditions",
not in the real world. That is why many large services can run a small
subset of servers with newer version of s/w as a "canary" to catch
errors early (but that is usually a binary decision -- if the canary
dies, you don't do the software update). With a dynamic language you
can add situation specific tests on the fly if the program misbehaves.
Live debugging should be even easier now -- with the right setup one
should be attach a bot to do some initial checking etc. Instead we
have apps that use 100s of MB to GBs of space but die silently. Guess
we all suffer from Stockholm Syndrome!
On Aug 3, 2023, at 3:05 PM, Dan Cross
<crossd(a)gmail.com> wrote:
On Thu, Aug 3, 2023 at 11:21 AM will.senn(a)gmail.com <will.senn(a)gmail.com> wrote:
Nice. I've never appreciated type checking
at 'compile' time, but I understand why others might (ocd). C was my first
exposure to blending types, then Perl was fuzzier, then Python was even better at
pretending types didn't matter. Now, with Lisp, I am freed from type concerns...
until I'm not. Thankfully, it's my choice.
Types in programming languages vary across two axes: strong versus
weak, and static versus dynamic. Common Lisp is strongly typed: for
example, you cannot add an integer to a list, or `cons` something onto
a vector (Common Lisp vectors are not lists).
Indeed, exactly the former caused a production outage in a large Lisp
system I worked on for about a year: someone had needed to store a
pair of integers, so they used a CONS cell; after a while, the pair
needed to be expanded to a triple, so someone converted the single
CONS cell into a (proper) list. Consequently, the function for
accessing the second value went from being CDR to CADR (or `SECOND`),
but the programmer missed one place: the value of `(cdr foo)`, now a
list, was passed to some function that expected a fixnum and tried to
add something to it: this, of course, ran afoul of the type system and
raised a condition, which resulted as an ISE in prod. The fix was
trivial (change CDR to SECOND in the right place) but it really struck
me that if the system were statically typed, this would have been
trivially discovered at compile-time.
On the other axis, Lisps are usually dynamically typed, which in this
context, means that the type of a value associated with a symbol may
change over time and one matters when the value is actually used.
Common Lisp does allow you to declare types in some limited regards;
these are usually hints to the compiler for code generation.
Conversely, in statically typed languages, the type of every value is
known at all times (particularly at compile time).
Incidentally, this episode --- along with something similar in a
Python program --- really soured me on dynamically-typed languages.
The python failure was particularly maddening: it was heavily unit
tested (100% coverage) but as soon as we put it out, we immediately
got an error report: a type error with processing the arguments to
`main` (Google had some non-standard internal libraries for that that
were challenging to test). This was highly frustrating: like Rob, I
greatly prefer strong, static typing.
Incidentally, C is weakly (you can add a pointer to an integer: the
result is another pointer), but statically typed.
- Dan C.
> On August 3, 2023 9:56:22 AM CDT, Dan Halbert <halbert(a)halwitz.org> wrote:
>>
>> Python has optional type annotations. There are batch tools (e.g., MyPy) to do
type analysis and IDE's also provide help. Example:
>>
>> def greeting(name: str) -> str:
>> return 'Hello ' + name
>>
>> I found Python to be an enormous improvement over Perl for writing the kinds of
things I used to write in Perl, with the Perl book at my side. I currently make my living
working on Python for microcontrollers. Neverthless, I am fond of type checking too, and
if I were writing a large Python system, I would use type annotations.
>>
>> I have used BCPL too, in the 70's, and we achieved some measure of type
safety by careful naming.
>>
>> Dan H.
>>
>> On 8/3/23 10:19, Bakul Shah wrote:
>>
>> I have not heard such horror stories about Common Lisp (or may be I have
forgotten them!). My impression is that python doesn't quite have the kind of
{meta,}programming tools Common Lisp has. CL has been used for large critical programs.
Perhaps Von Rossum had more experience with statically typed languages than Lisp (because
-- pure speculation here -- if he had used CL enough, he would never have designed python
:-)
>>
>> On Aug 3, 2023, at 1:32 AM, Rob Pike <robpike(a)gmail.com> wrote:
>>
>> I once inherited maintenance of a critical piece of infrastructure written in
exquisitely well written, tested, and documented Python. I mean it, it was really really
good.
>>
>> It crashed about once a week and I had to fix it over and over because in those
exponentially vast combinations of paths through the code would arise yet another way to
turn a string into a list, or something analogous. It was hell.
>>
>> Critical code needs static typing.
>>
>> -rob
>>
>>
>> On Thu, Aug 3, 2023 at 1:56 PM Bakul Shah <bakul(a)iitbombay.org> wrote:
>>>
>>> python can certainly implement tail call optimization (TCO). Pretty much any
language can implement TCO but for some reason people think such programs are harder to
debug (and yet they don't similarly complain about loops!). The beauty of Scheme was
that it *mandated* tail recursion.
>>>
>>>> On Aug 2, 2023, at 8:24 PM, George Michaelson <ggm(a)algebras.org>
wrote:
>>>>
>>>> Tail recursion not lazy eval.
>>>>
>>>> I wish words meant what I meant "inside" when I think them,
not
>>>> "outside" what they mean when I write them.
>>>
>>
>>
> -- Sent from /e/OS Mail.