3 ms·
I'm also a pretty die-hard type-system user, but I've been programming a lot of Lisp and FORTH lately. FORTH is just bad at safety period. Lisp, on the other ha
by packetlost 3y ago
I'm also a pretty die-hard type-system user, but I've been programming a lot of Lisp and FORTH lately. FORTH is just bad at safety period. Lisp, on the other hand, I can see why there really isn't a need for types. The macro system means you can create arbitrary "compile-time" safety checks which is, IMO, more powerful than just a type system. That being said, I would still love a strongly, statically typed Lisp, or at least one with a strong macro type system (before y'all mention it, I'm not a fan of typed Racket).
- Zambyte 3y ago> Lisp, on the other hand, I can see why there really isn't a need for types. What Lisp are you using that doesn't have types?
- packetlost 3y agoWell, every programming language must necessarily have types to some degree, but they aren't necessarily static or strong type systems. Most Lisps do not have a static type system and even fewer have a "strong" type system.
- Zambyte 3y ago> Well, every programming language must necessarily have types to some degree The vast majority yes, that's why I was a bit confused :D There some languages that have no types. The only thing I can think of though is a POSIX shell minus arrays. (Edit: Assembly and Forth are two better examples) > Most Lisps do not have a static type system True > and even fewer have a "strong" type system. Common Lisp, Emacs Lisp, Scheme, Hylang, Clojure, and Racket all feature strong typing. I'm curious where you have found this trove of weakly typed Lisp dialects
- packetlost 3y agoLisps are not statically typed typically and "strongly" typed is poorly defined. I would not consider most Lisp's type systems to be strong or particularly expressive, but they don't need to be because it would hurt the main benefit to the language: meta-programming. I don't think a "strong" vs "weak" type system argument is particularly valuable here, yes most prevent you from inadvertently changing how a particular series of bytes is interpreted, but their aggregates do not have any type identity besides their own typically. This means you cannot typically express and enforce an aggregate's covariance or contravariance properties. There may be ways to do so, but most do not provide utilities for it.
- gpderetta 3y agoWhy dynamic typing is required for metaprogramming? D (and rust and c++ to a significantly lesser extent) for example has extremely strong metaprogramming capabilities while being statically typed.
- packetlost 3y agoI didn't say it was required, I said it hurts it in Lisps case. One of Lisps strongest features is extreme flexibility and homoiconicity. Strict typing would make it clunkier, though maybe it's worth it for some scenarios.
- Zambyte 3y ago> I don't think a "strong" vs "weak" type system argument is particularly valuable here, yes most prevent you from inadvertently changing how a particular series of bytes is interpreted [...] I think that interpretation of the "strong" vs "weak" scale is a valuable one within the context of the blog post. The post is at least partially about how type systems can help the programmer by making them aware of certain kinds of errors (it is also about when: static vs dynamic). My understanding of the terms covariance and contravariance are a bit shaky. Could you provide an example in another language that you think cannot be expressed using the provided utilities of most Lisp's? You also mentioned that you don't think most Lisp's have "expressive" type systems. What do you mean by that? When I think of a type system as being expressive, I think of it as having explicit rather than implicit types, which is unrelated to the issue of strongly vs weakly typed and static vs dynamic types. Do you mean more like how you can describe / constrain the relationships between types in certain strongly typed languages?
- packetlost 3y ago> I think that interpretation of the "strong" vs "weak" scale is a valuable one within the context of the blog post. The post is at least partially about how type systems can help the programmer by making them aware of certain kinds of errors (it is also about when: static vs dynamic). Sure, agree. That's also the real point: type systems primarily exist to make semantically impossible computations unrepresentable in the language (at least, without some extra song and dance). To this end, Lisps have rather lackluster type systems, but they don't try to encode much of the languages semantics into a type system. > My understanding of the terms covariance and contravariance are a bit shaky. Could you provide an example in another language that you think cannot be expressed using the provided utilities of most Lisp's? The wikipedia article on the topic is a great source: https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science) https://en.wikipedia.org/wiki/Covariance_and_contravariance_... I'm actually mostly concerned with type invariants (ex. List[int]), which don't really have much for representation in Lisps from what I've seen. Further, see above about using types to make compile-time assertions/checks about the behavior at runtime. > You also mentioned that you don't think most Lisp's have "expressive" type systems. What do you mean by that? When I think of a type system as being expressive, I think of it as having explicit rather than implicit types, which is unrelated to the issue of strongly vs weakly typed and static vs dynamic types. Do you mean more like how you can describe / constrain the relationships between types in certain strongly typed languages? "Expressive" is a nothing word that doesn't have concrete meaning in-context, similar to "strong" type system. That being said, I would say Rust, OCaml, and TypeScript have expressive type systems: the behavior of the language is largely encoded as types. The implicit vs explicit nature of types is not super consequential IMO, it has more to do with how you primarily represent semantic meaning. In lisp, it's symbols. In Rust, it's traits, enums, and structs (+ the affine types, but that's not relevant here).
- qazwse_ 3y agoI haven't used it, but I know that Coalton adds static typing to Common Lisp, might be something you're interested in. https://github.com/coalton-lang/coalton https://github.com/coalton-lang/coalton
- packetlost 3y agoI'm more into Scheme than CL, but am aware of Coalton. My current lisp is Gerbil: https://cons.io https://cons.io which already has a type annotation system and will be enhancing it for the next major release (v19).
- gpderetta 3y agowait, are you saying that any sufficiently complicated lisp program contains an ad hoc, informally-specified, bug-ridden, slow implementation of a static type system?
- packetlost 3y agoNo. I'm saying you can build almost whatever static analysis tools you want right into the compiler