Math classes should be serializable

Anything libgdx related goes here!

Math classes should be serializable

Postby Muesli » Fri Dec 31, 2010 12:45 am

Hi! I played a bit with libgdx, it looks really nice! :P Just a minor thing (Google code seems to be down a lot these days, otherwise I'd file a bug there) - it seems that at least most math classes (Matrix/Vector/...) should implement Serializable (think of savegames/checkpoints etc.).
Muesli
 
Posts: 4
Joined: Fri Dec 31, 2010 12:39 am

Re: Math classes should be serializable

Postby mzechner » Fri Dec 31, 2010 5:12 am

good idea. adding it to the issue tracker. will fix asap.
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: Math classes should be serializable

Postby NateS » Fri Dec 31, 2010 9:16 am

I would disagree. Serializable sucks for a variety of reasons. It is slow, the output is large, and it is invasive (hence you needing to ask for the classes to be modified). Better to use a serialization framework that handles these things better. Like, oh I don't know... Kryo. :)
NateS
 
Posts: 1980
Joined: Fri Nov 12, 2010 11:08 am

Re: Math classes should be serializable

Postby Muesli » Fri Dec 31, 2010 4:56 pm

Sure other frameworks are better than default Java serialization but adding "implements Serializable" does not cost anything really, especially for people who can live with the default serialization's shortcomings but would not like another dependency.

Will have a look at Kryo though. Nates, do you know about Kryo performance on Android, especially compared with the serialization implementation there (which is probably different from Sun's implementation and might be faster already)?
Muesli
 
Posts: 4
Joined: Fri Dec 31, 2010 12:39 am

Re: Math classes should be serializable

Postby NateS » Sat Jan 01, 2011 2:28 am

Full disclosure: I'm the Kryo author. :)

Muesli wrote:Sure other frameworks are better than default Java serialization but adding "implements Serializable" does not cost anything really, especially for people who can live with the default serialization's shortcomings but would not like another dependency.


It propagates crappy tools. :?

Will have a look at Kryo though. Nates, do you know about Kryo performance on Android, especially compared with the serialization implementation there (which is probably different from Sun's implementation and might be faster already)?


The serialization spec requires it to do a lot more than what Kryo needs to do. I haven't run benchmarks on Android, but it is very unlikely it is faster than Kryo. Kryo basically does what you would do if you coded serialization by hand (eg, Externalizable), except it can do it via reflection without special serialization code for your objects. The schema is the class definitions. Kryo uses ByteBuffers while Java serialization uses (eg) ByteArrayOutputStream, but I would still bet Kryo is faster on Android.

Since the output for Java's built-in serialization must meet the spec, the size comparisons between Kryo and Java serialization on the desktop hold true for Android.
NateS
 
Posts: 1980
Joined: Fri Nov 12, 2010 11:08 am


Return to Libgdx

Who is online

Users browsing this forum: Google [Bot], MSN [Bot] and 1 guest