Re: On the benefits of reflection
Marc Hernandez <[email protected]> Tue, 19 Mar 2013 11:09:47 -0700
| Newsgroups | gmane.games.devel.sweng |
|---|---|
| Message-ID | <CAL=mSHjbTemeWWLf8RrP-=e2CA4a4942rCR+5EZwkXKx66jpQQ@mail.gmail.com> |
--===============1366078881== Content-Type: multipart/alternative; boundary=f46d042ef66138568b04d84b05a9 --f46d042ef66138568b04d84b05a9 Content-Type: text/plain; charset=ISO-8859-1 Man, I love reflection. It allows me to just belt out working systems with ease. So, Im using it for: x) Trivial network system. All my network packets are just classes that I marked [Serializable]. If I have any special handling I use custom field attributes to mark it up. x) Config system. Uses all the same hardware as the networking system, now its just loading to and from disk. x) Save/Load. Same. x) Message passing system. This is essentially just the networking system. y) I have a friend that built a nice level editor in XNA in a month which heavily relied on reflection. With all of these I have 1 reflection handling class. Currently its a custom written XML reader/writer that slightly abuses the XML rules so files are small. I also have a binary reader and writer. The networking system can negotiate for which one to use. Making a viewer looks like: structure = Read( BinaryFormatter ); Print( XMLFormatter ); I then use reflection to automatically type safe handle the messages. So, you just put: void handl( msg.MoveTo move ) And higher level code calls down into it. If this shows up in profiling, ill special case the heavily called messages and leave the rest. On Tue, Mar 19, 2013 at 10:35 AM, Massimo Del Zotto <[email protected]>wrote: > Hello, > this question spawned from the recent discussion on reflection. I guessed > it was better to open an independent discussion instead of hijacking the > thread. > > 2013/3/19 Douglas Cox <[email protected]> > >> So if you do start wandering into the land of making your own language >> for just reflection, you might see what other benefits you can get from >> doing more in it than just that. >> > > I'd be interested in knowing more about doing the other thing around. > I have a small little language I've been using for a while and I've been > fairly happy with it. So far, the language itself does not have reflective > constructs (nor I plan to add them) but I use reflection internally mainly > to simulate duck typing. > So far, I haven't well understood the benefits of reflection. I had seen > some examples in ObjC but they didn't really appeared to be buying much > from me. I know reflection is there in a Java package, but I couldn't quite > figure out the whole picture. > > Could you please elaborate on the benefits of using reflection? Please be > specific on whatever you're talking about reflection from the native core > or reflection from the language. > > Thank you > Massimo > > > _______________________________________________ > Sweng-Gamedev mailing list > [email protected] > http://lists.midnightryder.com/listinfo.cgi/sweng-gamedev-midnightryder.com > > -- /// // --f46d042ef66138568b04d84b05a9 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Man, I love reflection. =A0It allows me to just belt out w= orking systems with ease. =A0<div><br></div><div style>So, Im using it for:= </div><div style>x) Trivial network system. =A0All my network packets are j= ust classes that I marked [Serializable]. =A0If I have any special handling= I use custom field attributes to mark it up. =A0</div> <div style>x) Config system. =A0Uses all the same hardware as the networkin= g system, now its just loading to and from disk. =A0</div><div style>x) Sav= e/Load. =A0Same. =A0</div><div style>x) Message passing system. =A0This is = essentially just the networking system.</div> <div style>y) I have a friend that built a nice level editor in XNA in a mo= nth which heavily relied on reflection. =A0</div><div style><br></div><div = style>=A0 With all of these I have 1 reflection handling class. =A0Currentl= y its a custom written XML reader/writer that slightly abuses the XML rules= so files are small. =A0I also have a binary reader and writer. =A0The netw= orking system can negotiate for which one to use. =A0Making a viewer looks = like:</div> <div style>structure =3D Read( BinaryFormatter );</div><div style>Print( XM= LFormatter ); =A0</div><div style><br></div><div style>=A0 I then use refle= ction to automatically type safe handle the messages. =A0So, you just put:<= /div> <div style>void handl( msg.MoveTo move )</div><div style><br></div><div sty= le>=A0 And higher level code calls down into it. =A0If this shows up in pro= filing, ill special case the heavily called messages and leave the rest. = =A0</div> <div style><br></div></div><div class=3D"gmail_extra"><br><br><div class=3D= "gmail_quote">On Tue, Mar 19, 2013 at 10:35 AM, Massimo Del Zotto <span dir= =3D"ltr"><<a href=3D"mailto:[email protected]" target=3D"_blank">mass= [email protected]</a>></span> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex">Hello,<div>this question spawned from the re= cent discussion on reflection. I guessed it was better to open an=A0indepen= dent=A0discussion instead of hijacking the thread.</div> <div><br></div><div>2013/3/19 Douglas Cox=A0<span dir=3D"ltr"><<a href= =3D"mailto:[email protected]" target=3D"_blank">[email protected]</a>></sp= an><br> <div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margi= n:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204= );border-left-style:solid;padding-left:1ex"><div dir=3D"ltr">So if you do s= tart wandering into the land of making your own language for just reflectio= n, you might see what other benefits you can get from doing more in it than= just that.</div> </blockquote><div><br></div><div>I'd be interested in knowing more abou= t doing the other thing around.</div><div>I have a small little language I&= #39;ve been using for a while and I've been fairly happy with it. So fa= r, the language itself does not have reflective constructs (nor I plan to a= dd them) but I use reflection internally mainly to simulate duck typing.</d= iv> <div>So far, I haven't well understood the benefits of reflection. I ha= d seen some examples in ObjC but they didn't really appeared to be buyi= ng much from me. I know reflection is there in a Java package, but I couldn= 't quite figure out the whole picture.</div> <div><br></div><div>Could you please elaborate on the benefits of using ref= lection? Please be specific on whatever you're talking about reflection= from the native core or reflection from the language.</div><div><br></div> <div>Thank you</div><span class=3D"HOEnZb"><font color=3D"#888888"><div>Mas= simo</div><div><br></div></font></span></div></div> <br>_______________________________________________<br> Sweng-Gamedev mailing list<br> <a href=3D"mailto:[email protected]">Sweng-Gamedev@list= s.midnightryder.com</a><br> <a href=3D"http://lists.midnightryder.com/listinfo.cgi/sweng-gamedev-midnig= htryder.com" target=3D"_blank">http://lists.midnightryder.com/listinfo.cgi/= sweng-gamedev-midnightryder.com</a><br> <br></blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>/// // </div> --f46d042ef66138568b04d84b05a9-- --===============1366078881== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Sweng-Gamedev mailing list [email protected] http://lists.midnightryder.com/listinfo.cgi/sweng-gamedev-midnightryder.com --===============1366078881==--