BooPickle 0.1.0 preview released - fast binary serialization for both Scala and Scala.js

542 views
Skip to first unread message

Otto Chrons

unread,
Apr 18, 2015, 7:20:45 AM4/18/15
to scal...@googlegroups.com

BooPickle is the fastest and most size efficient serialization (aka pickling) library for Scala and Scala.js. It encodes into a binary format instead of the more customary JSON. A binary format brings efficiency gains in both size and speed, at the cost of legibility of the encoded data. BooPickle borrows heavily from both uPickle and Prickle so special thanks to Li Haoyi and Ben Hutchison for those two great libraries!

Features

  • Supports both Scala and Scala.js (no reflection!)
  • Serialization support for all primitives, collections, options, tuples and case classes (including class hierarchies)
  • User-definable custom serializers
  • Handles references and deduplication of identical objects
  • Very fast
  • Very efficient coding
  • Special optimization for UUID and numeric strings
  • Low memory usage, no intermediate structures needed
  • Zero dependencies
  • Scala 2.11 (no Scala 2.10.x support at the moment)


This is a "preview" release, so it's not yet available in a repository.

All comments and PRs are welcome!

- Otto

Larry Melia

unread,
Apr 18, 2015, 1:56:59 PM4/18/15
to scal...@googlegroups.com
Very cool! I was just thinking about something similar, but using WebGL's typed array buffers. (I'm working on a WebGL graphics library in Scala.js.) See http://www.html5rocks.com/en/tutorials/webgl/typed_arrays/ and http://stackoverflow.com/questions/11752456/best-way-to-load-binary-webgl-model-through-ajax.

Otto Chrons

unread,
Apr 18, 2015, 2:26:37 PM4/18/15
to Larry Melia, scal...@googlegroups.com
Internally it is using TypedArrays on the browser, because Scala.js ByteBuffers are built on top of them. This is one of the main reasons for good performance in the browser :)

I suppose I should mention this in the docs, because the lib relies on TypedArrays in the JS environment and there might be some environments (like Node.js that has its own Buffers) where they are not available.

- Otto


--
You received this message because you are subscribed to a topic in the Google Groups "Scala.js" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scala-js/HjeMmFIrC-M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scala-js+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-js/981efe77-fc84-48e0-a765-36194fa49626%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Otto Chrons

unread,
Apr 20, 2015, 4:23:52 PM4/20/15
to scal...@googlegroups.com
It's now released to the Sonatype repository, so feel free to try it out in your own project!

- Otto

Otto Chrons

unread,
Apr 21, 2015, 1:56:50 PM4/21/15
to scal...@googlegroups.com
Published version 0.1.1 which fixes couple of critical bugs.
  • Functions in Un/PickleState were private, so macros did not work outside the boopickle package!
  • TextEncoder produces Uint8Array which needs to be cast to Int8Array for ByteBuffer to work
  • Added pickler for ByteBuffer (mainly to make BooPickle work easily with Autowire)
Also SPA tutorial has been updated to use BooPickle and demonstrates how to use BooPickle with Autowire.

- Otto

Otto Chrons

unread,
Apr 30, 2015, 5:59:23 PM4/30/15
to scal...@googlegroups.com
Published version 0.1.2 with performance enhancements:

- Support for heap and direct byte buffers (and custom ones, too)
- Support for returning a sequence of ByteBuffers instead of a combined one
- Changed to little endian, and updated integer encoding scheme for negative numbers
- Fixed a bug in unpickling a ByteBuffer
- Optimized string decoding in case of heap buffer

Enjoy!

Otto Chrons

unread,
May 26, 2015, 4:45:47 PM5/26/15
to scal...@googlegroups.com
Version 0.1.3 released:

- Fixed a bug in byte order when unpickling a ByteBuffer
- Enforce byte ordering before unpickling
- CompositePickler supports join method to pickle deeper type hierarchies
- Use heap ByteBuffers on JVM by default, direct on JS for optimal performance

Please upgrade to make sure byte ordering works ok!

Otto Chrons

unread,
Jun 12, 2015, 5:24:45 PM6/12/15
to scal...@googlegroups.com
Version 0.1.4 is out!

- Fixed a bug in decoding strings from a `ByteBuffer` with an array offset
- Added transformation picklers to help creating custom picklers
- Added special support for pickling Exceptions

Now you can easily create picklers for (simple) Java and Scala classes by transforming their representation to something that can be automatically pickled (like a Tuple). For example 

implicit val datePickler = TransformPickler[java.util.Date, Long](_.getTime, t => new java.util.Date(t))

CompositePickler adds special support for exceptions, by serializing exceptions with their message. A ready-made pickler with the most common exceptions is also provided.

Get it from Maven Central or check out the sources at https://github.com/ochrons/boopickle

- Otto

Otto Chrons

unread,
Jun 15, 2015, 5:49:03 AM6/15/15
to scal...@googlegroups.com
Aaaand BooPickle 1.0.0 is released!

- Support for auto-generation of `CompositePickler` for sealed trait class hierarchies
- When a `ByteBuffer` is pickled, it now retains its byte order when unpickled
- Refactored String coding in Scala.js

The support for sealed class hierarchies was surprisingly simple to implement, so now BooPickle matches uPickle functionality in that regard as well. You can still use CompositePickler manually in case you need to.

Documentation now elaborates a bit on the macro magic and some other internal details of the library.

Get it from Maven Central or check out the sources at https://github.com/ochrons/boopickle

- Otto

Otto Chrons

unread,
Jul 16, 2015, 4:03:12 PM7/16/15
to scal...@googlegroups.com
BooPickle 1.1.0 is out

This version has several backward-compatibility breaking changes. Most notably you should change your `import boopickle._` into 
`import boopickle.Default._`, which should be enough for most common cases. If you have written your own picklers, you must merge
the unpickling functionality into the pickler. There are also changes to how `CompositePickler`, `TransformPickler` and
`ExceptionPickler` are used.

- Moved all implicits into `boopickle.Default` to better control what implicits are imported
- Unpicklers merged into Picklers, so there are no separate Unpicklers anymore
- Added helper functions `compositePickler`, `transformPickler` and `exceptionPickler` in `Default`
- BooPickle generated macros are now compatible with *-Xstrict-inference* compiler option
- Trait hierarchies with type parameters can now be pickled automatically (by @FlorianKirmaier)
- Improved error messages
- Performance tests now use uPickle 0.3.4

Have fun!

- Otto
Reply all
Reply to author
Forward
0 new messages