3 ms·
In the same way that objects are just tables in disguise. Sure it's true in some way, but the impedance mismatch is huge and horrible. There is a reason why th
by konjin 6y ago
In the same way that objects are just tables in disguise. Sure it's true in some way, but the impedance mismatch is huge and horrible.
There is a reason why the internals of all major cas systems use rewrite rules instead of objects with types.
As a toy test try and implement a system that simplifies an expressions of a given group to normal form for that group. Using rewrite rules you end up with a program that is dozen of lines long and even better is provably correct by hand. Using types and functions on types you end up with a monstrosity that is 10 times as long and just feels clunky. Worse even something as simple as adding a super group of which your example is a sub group requires a rewrite of the program. Using rewrite rules on the other hand merely adds a few more if/else clauses in the main program.
Types are a fetish of the programming community and are used in places where they are actively detrimental. This stems from the fact the majority of programmers do not understand the difference between types and constraint rules.
- ChrisRackauckas 6y agoThis is why we've ended up at a mixed approach. Types in Julia are used to "distinguish between things". Multiple dispatch then is a great system for defining rules that are specific to groups: `AbstractMatrix` types have non-commutative rulesets, and we then let them have different rules from `Real` and let subtyping control at a finer grain what rules apply to which pieces, and what rules apply when you combine them.