Implementing serialisation with minmal boilerplate and template overhead using core.reflect

Alexandru Ermicioi alexandru.ermicioi at gmail.com
Tue Aug 17 20:50:45 UTC 2021


On Tuesday, 17 August 2021 at 20:23:48 UTC, 12345swordy wrote:
> On Tuesday, 17 August 2021 at 18:10:48 UTC, Alexandru Ermicioi 
> wrote:
>> On Tuesday, 17 August 2021 at 14:16:52 UTC, 12345swordy wrote:
>>> The reason that they use runtime reflection in java/c# is 
>>> because of the basic principles of OOP.
>>>
>>> -Alex
>>
>> How does basic principles of oop force java implementations 
>> use runtime reflection???
> https://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)
>
> You cannot obtain information such as "How many child classes 
> does this class currently has", without compiling every 
> code/library that you use, which isn't feasible as not every 
> library share their source code.
>
> - Alex

I still fail to see relation between oop and runtime info use. 
The part about source code sharing is also true for c and d libs, 
which both could share only header files and have pointer to 
struct declared without said struct declaration (i.e. Opaque 
struct type, not sure completely about D though).

The thing is, that runtime reflection in java is more or less 
usable compared to d (sigh), and can be used to design libs that 
are using that data to do their job, but this doesn't mean that 
there aren't any options on using compile time info to generate 
or alter compiled code. Take for example lombok project, jpa 
model generator from hibernate, or mapstruct library which is a 
mapper from one java type to another (kinda close to 
serializers), all of them are used at compile time to either 
generate new code, or alter existing one, based on annotation 
processor plugin feature offered by java compiler, not to mention 
byte code enhancement capabilities, and libs using them.

I'm pretty sure C# has similar possibilities, for code generation 
and alteration.

Regards,
Alexandru.


More information about the Digitalmars-d mailing list