this post was submitted on 01 Nov 2023
112 points (91.2% liked)

Programmer Humor

19149 readers
1121 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] mikidep 1 points 7 months ago

Op here back from the dead. This is in fact not a stab at dynamically typed languages, or at least not only: statically typed languages such as Java also support this kind of construct. In fact, one could develop a technically type safe programming language where an instanceof construct has sound semantics.

What instanceof breaks is something called polymorphic parametricity, i.e. the fact that generic functions don't know anything specific about the types they are generic over. This is the fundamental condition for what in the community is dubbed "theorems for free", that is, naturality of generic functions between generic types.