Re: java serialization alternative
Bob Lee <[email protected]> Wed, 9 Jul 2008 12:42:17 -0700
| Newsgroups | gmane.comp.windows.devel.java.advanced |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Jul 9, 2008 at 11:59 AM, Jeffrey Kesselman < [email protected]> wrote: > Bob Lee wrote: > >> You can't accuse me of not knowing serialization. I know the spec inside >> and >> out. >> > Alright, then justify your opinion with solid facts. What is it in > Serialization that you can point to that makes it such that ti has to be > either bloated or slow? While an approach like PBs is more efficient by default, I've never had performance problems with serialization. I've always found it to be one of the fastest approaches available; the implementation itself is very good. My problem with serialization is with the lack of tooling potential and all the problems you run into when it comes time to upgrade your code in a compatible way. The fact that serialization can serialize your objects transparently is deceptively seductive. The result is almost never what I want, so I end up writing the code manually anyway and the result is much messier than if I had used PBs or something else (though I suppose you could use PBs within your serialization logic!). I'm for more transparent approaches that encourage you to do the right thing by default and not tie your serialized state (part of your published API) too closely to your implementation. It's difficult to debate serialization unless you focus on specific use cases. I don't think you're interested in this case, but APIs are one area where serialization is heavily used, especially in the JDK. I've run into countless situations where I try to refactor some code but maintaining serialization compatibility limits what I can do (and I do understand serialization in and out and everything you can do to maintain compatibility). java.text.DateFormatSymbols and java.util.concurrent.ConcurrentHashMap are two cases I've run into recently. Like many, I used to think serialization was a good fit for more "transient" use cases like replicating HttpSessions, but I definitely don't think that anymore. What do you do when it comes time to upgrade your servers? I can give you lots of great answers, but none are as good as "don't use serialization in the first place." Bob =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com