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.