@OderWat I was looking for examples online, because I remember that one of the 
c++ talks mentioned that they completely forbid the usage of templates. But I 
can't find that specific talk anymore. I saw too many, and did made a protocol 
about talks I watched. But what I did find is first of all, The google style 
guide which discourages to use [template 
metaprogramming](https://google.github.io/styleguide/cppguide.html#Template_metaprogramming).
 But to be fair, they don't completely ban templates, and I am not sure if they 
distinguish between normal templates as a replacement for generics, or more 
complicated things that rely on template specialization (which is something 
that Nim does not support in its generics for a good reason).

Then I found is the live coding channel [Handmade 
Hero](https://handmadehero.org/) from Casey Muratori. His goal is to write an 
entire game with interesting game engine techniques completely on stream. He 
also says he won't use any third party libraries, he even refuses to use 
operating system abstractions like SDL. I don't know exactly where is says that 
he wouldn't use templates at all, but hiss 3D math library (vectors) with most 
people would implement with c++ templates is completely template free.

Then there is also Jonathan Blow the writer of _Braid_ and _the Witness_. When 
you watch his streams you also realizes that he has a very strong opinion 
againt c++ templates. but again I don't know exactly where in is videos you 
find it, and unlike Handmade Hero I do not have access to his sourcecode.

@_tulayang First of all, do you know the go programming language? 
[Here](https://gobyexample.com/interfaces) is an example of it's interface 
type. Do you understand it? To your _alternative solutions_, it is nice that 
you can prove to be able to program, but when you don't understand the point of 
the original version, and what it is supposed to show, or what its advantages 
are, then your solutions are not helpful at all, because they miss the point.

  * **functional solution**, first of all it's not more functional than my 
solution, just because it uses a lambda expression. But most importantly you 
degraded `foobar` to nothing more than an apply function and copy pasted it's 
logic into each call of foobar.
  * **Another solution**, I see three problems in this line alone: `type 
MyImplementationA = ref object of MyInterface`.
    
    1. MyImplementationA now needs to be a referenced type, no stack allocation 
possible anymore.
    2. Usage of MyImplementationA now forces garbage collection, and therefore 
also garbage collection overhead.
    3. It uses direct inheritance from the interface type, which is a 
dependency that Go interfaces do not have.



So please ask questions before you write another "solution".

Reply via email to