4 ms·
I don't dispute the effectiveness of Common Lisp, but > There is an automatic correspondence between objects and types is almost never what is meant by a "str
by thebooktocome 9y ago
I don't dispute the effectiveness of Common Lisp, but
> There is an automatic correspondence between objects and types
is almost never what is meant by a "strong type system" -- it more commonly means that types are checked at compile time, rather than run time. I don't doubt that any given lisp hacker could slap together a type inference system on top of CLOS, but as far as I can tell it's not built in.
So, on the strong-to-weak type system spectrum, I would say:
* Idris (lawful good, first-class dependent types)
* Haskell (very strong, some support for dependent types)
* Java (strong, some generics)
* Julia (hybrid, code is analyzed for type inference during JIT, invariant types)
* Common Lisp (weak by default, afaict)
* Python (very weak)
* Javascript (weakest)
* PHP5, Perl (chaotic evil)
- reikonomusha 9y agoCommon Lisp is strongly typed (type mismatches result in a sensible error), but is by default dynamically typed, unless you annotate. The type system is not capable of useful, extensible polymorphic types, though.
- kazinator 9y agoTypes checked at compile time is called "static". Strong has various meanings. Ada is "strong" versus C being "weak" though the basic Algol-like model is not so different, and if we don't count tagged types, neither language is dynamically typed in any way. (So if "strong" means "static", we would not be able to use the strong/weak terminology to contrast these languages!) "Strong" in this context mean various things, ranging from C having holes in the type system that allow punning and bad memory references, to C having automatic conversions that are unsafe: for instance assigning a floating-point value to an integer location without an explicit conversion operator which handles situations when the conversion is impossible. Or not having a character type distinguished from an integer type. C++ has more "strongly typed" enums than C; and what that means is that you can't assign an integer value to an enum object without a cast. ANSI Lisp is fairly strong, but allows some relaxations: car on an empty list, integers usable where floating-point values expected (a bit like C) and such.
- flavio81 9y agoYou are confusing "strong/weak" typing with "static/dynamic" typing. CL is for the most part strongly typed. Python too. In CL there are almost no automatic typecasts. Javascript and PHP and Perl are textbook examples of weakly typed systems. The interpreter (or compiler) can even allow things like 1 == "1". With implementations like SBCL, CL also allows for static type checking with the "declare" and "proclaim" keywords, this checks types before runtime, if they can be inferred before executing the code.