5 ms·
Writing a type checker is conceptually much more specialised than just a scripting language. Certainly I have no idea how to write one!
by vitriol83 8y ago
Writing a type checker is conceptually much more specialised than just a scripting language. Certainly I have no idea how to write one!
- adwn 8y agoMoreover, designing the actual type system is at least as hard as implementing the type checker. Coming up with a static type system that is flexible/ergonomic, expressive/powerful, sound, easy to use, and also a good match for mutable state and imperative code is really, really difficult, as demonstrated by C, C++, and Java. A flexible/ergonomic dynamic type system is trivial in comparison. Soundness is handled at runtime when the exact value of each expression is known, and ease of use is almost a given.
- rurban 8y agoNot really. You just need to walk up both types until you find a match. It's similar to a simple eval matcher, which is about 10 lines in lisp. https://github.com/perl11/Bla https://github.com/perl11/Bla has typically the smallest and easiest to understand type inferencer and checker.
- PeCaN 8y agoIt's actually extremely easy, particularly if you're familiar with Prolog (the core algorithm is a couple lines in Prolog, so knowing how that works is useful for implementing it in other languages). I suspect the lack of statically typed scripting languages is more of a historical accident than anything.