Jargon: Polymorphism and Dispatch (2015)
The concept of polymorphism, and dispatch, are the most idiotic concepts.
- advanced computer science.
- the concept of polymorphism, and dispatch, are the most idiotic concepts.
- they are, a view from the perspective of implementors or compiler writers.
- they have no meaning in math or in a script that specify algorithm, aka programing language.
- the idea of polymorphism, or method dispatch, r side effects of computer engineering, by the early limitation and habitual thinking of bit diddlers, eg c cpp types of coders.
- instead, you should totally remove those concepts. we dont need them. i dont think u even need them in compiler science. its a redundant and misleading view.
- instead, when u have a function that handle diff type, eg 3 + 4 vs "ab" + "cd", you simply think of it as function with diff arg types and do what u have to do. you dont "dispatch" shit and its not some poly-fuck. like when u r walking, u dont call it dispatching legs.
- will expound later.
Polymorphism, Dispatch, and the Tale of Poly-Tinting
in programing, there's this polymorphism, dispatch, multi-dispatch. These, are by-product of computer engineering. Are idiotic concepts.
what polymorphism is, is that it's a function f, such that what it does depends on number of arguments (aka arity) fed to the function, and or depends on the data types of the argument.
as a silly ad-hoc polymorphism example to illustrate:
function ff(a, b) {
if (b == undefined) {
return a+a;
} else {
if ((typeof a === "number") && (typeof b === "number")) {
return a+b;
} else {
if ((typeof a === "string") && (typeof b === "string")) {
return stringJoin(a,b);
};
};
};
};
This is quite natural. But when it comes to implementation and language design, i assume due to difficulties, lots of issues comes up, and the language designer avoids it by creating by-products of work-around, spurious concepts, as did int long float double thing.
Now, in OOP, such as Java, for example, we have obj.f(a,b). There's a interesting thing going on. Namely, for some reason, in the implementation, what actually happens is that the function f has a implicit argument that is the object. Namely, it actually is like this: f(obj,a,b), and this is how most object oriented languages works. (and thus, such lang got mysterious spurious concept and keyword this.)
see:
[for full detail of this: Object Oriented Programing (OOP) Jargons and Complexities ]
So now, in Java, this calling a method of a object is in general sometimes called “dispatch”. Because, for perhaps implementation reasons, the language considered the call as calling a function named “f”, then identify the implicit first arg, then “dispatch” the call to the function that belongs to “obj”.
why the lang brought out “this” concept i never found out.
Now, there comes the idea of “multiple dispatch”, i first heard among Common Lisp idiots and they are fond of citing.
So, what's “multiple dispatch”?
apparently, in Common Lisp, since it's all parenthesis so it doesn't have the silly dot notation “obj.f”.
〔see OOP Dot Notation, className.method or objectName.method?〕
But, rather, the object is part of the function's argument, as in f(obj, a, b), or in lisp notation (f obj a b).
So, that is “multi-dispatch”. Because, the function f doesn't just “dispatch” to a fixed “obj” as in Java's obj.f(a,b), but rather, the function can behave differently depending on what is the first arg “obj”.
Now, can you see it's all very silly? From a non-idea becomes “polymorphism” and becomes “dispatch” and becomes “multi-dispatch”, all sounds so high-techy.
It is as if, in the land of object orientation, every time you drink a cup of water, you have to focus and distinguish whether the cup of water is in a tinted glass. Then, there's poly-color-tinted glass with red hue, and blue hue, then multi-hue…. What's the big deal? What about paper cup, plastic cup, tea cup, wine cup? Long time ago, in this country, their folks can conceive glass cups but are unable to make it, and when they finally figured out how, somehow it's always poly-tinted. Then, one day, a guy invented a color-tinted glass cup with a red hue, and that was big news, and somebody made a bluish one, and that's another advance of technology. Ever since, the culture of the country is to think of water always as a poly-tint. To not think of water by ways of the cup is, unnatural.
see also Comp Lang: C Cpp Java Coders Don't Know Scientific Programing Languages
- Object Oriented Programing (OOP) Jargons and Complexities
- Meaning of Object in Computer Languages
- Node.js Dot Notation as Namespace Mechanism
- OOP Dot Notation, className.method or objectName.method?
- JavaScript Dot Notation Multi-Semantics. Namespace vs Property Access
- Alan Kay on Object Oriented Programing
- Jargon: Polymorphism and Dispatch (2015)