

BinaryJS, Streaming realtime binary data to your web browser - ericz
http://binaryjs.com

======
steve8918
Very cool, I'll have to play around with this.

One request: could you also include an explicit LICENSE.TXT file stating that
you have licensed it under the MIT license as opposed to just putting it in
the comments? It would make it a lot easier for people to find if they might
have requirements in terms of various licensing.

~~~
ericz
My bad! Added to all the repos.

------
xxbondsxx
This is a huge step forward for the javascript community. Having _real_ binary
communication for WebGL games, media streaming, data analysis, etc etc is
going to be huge.

Can't wait to see what people do with this.

~~~
tlack
For now the problem is consuming it. For instance, it seems Google still
hasn't implemented a full API around the Audio object which could be used to
flow wave data through your program. See here:
[http://code.google.com/p/chromium/issues/detail?id=113676...](http://code.google.com/p/chromium/issues/detail?id=113676&can=5&colspec=ID%20Pri%20Mstone%20ReleaseBlock%20OS%20Area%20Feature%20Status%20Owner%20Summary)
(and many other similar issues exist within the more advanced parts of the V8
JS arch runtime)

~~~
magicalist
You can stream binary data through the Web Audio API to play it.

That bug is really for capturing audio, but the spec has substantially changed
since that bug was filed. If you want to get started with it, there are
several decent tutorials about WebRTC and getUserMedia out there...just keep
in mind that the spec is still being written, so problems are to be expected.

(also, minor nit: WebRTC and the like are implemented in the browser (for
Chrome, often at the Webkit level, but sometimes in Chrome itself), not in the
Javascript engine. V8 is pretty isolated from those APIs)

------
Xcelerate
Yes, perfect timing! I've been needing something like this for a video
streaming project I've been working on. I've been using Node for everything
and haven't wanted to resort to (and purchase) Adobe Flash.

Thanks for making this!

Are there are disadvantages to this in terms of optimization compared to
something like Flash?

~~~
novalis
You can build a streaming Flash app without having to pay a cent to Adobe, the
Haxe compiler or the Flex SDK are some of the solutions available. So I don't
really understand the "(and purchase)Adobe Flash" part.

~~~
Xcelerate
To explain what you don't understand, I didn't know about those. Thanks for
the information!

~~~
keyle
Yes Haxe(.org) would definitely be the way to go.

------
Joeri
They state that performance is untested. While this is interesting for
transporting binary data that needs no encoding or decoding, i suspect the use
cases will be minimal. JSON is actually highly efficient already. Ebay did
benchmarking of the various binary formats for server-to-server api's, and
while JSON wasn't the fastest, it was fast enough.
[http://www.infoq.com/presentations/Dealing-with-
Performance-...](http://www.infoq.com/presentations/Dealing-with-Performance-
Challenges-Optimized-Data-Formats)

------
azakai
I'm on Firefox 17 but <http://examples.binaryjs.com/hw.html> tells me

> Your browser doesn't support binary websockets and is not yet supported by
> BinaryJS. Fallbacks are in the works but not yet complete. Chrome 15+ and
> Firefox 11+ are known to work.

I do see a picture of a flower, so it looks like it did actually work despite
the message..?

~~~
ericz
It was a problem with feature detection method. Fixed, tested, committed,
tagged, pushed, deployed!

------
AjayTripathy
I can't wait to see a real, scalable game on the full javascript stack:
webgl/html5 graphics , node.js / binary.js backend, and a mongodb database.

------
MatthewPhillips
Very nice! Could you explain a bit about the choice to go with BinaryPack,
specifically what is wrong with sending ArrayBuffers over the wire?

~~~
ericz
I felt that it'd be helpful to allow people to send any JSON type rather than
just binary data. You can actually write Javascript objects, arrays, strings,
and numbers to any stream or stream metadata in addition to binary. By using
it as part of wire protocol it only adds exactly one byte to each message, so
why not.

~~~
dtf
First of all, this looks great. But is there a reason to use this custom
BinaryPack format, over another binary JSON-alike such as msgpack, which
already has a lot of bindings in other languages?

~~~
ericz
I'm glad you asked! BinaryPack is actually a extended version of msgpack.
Specifically msgpack doesn't differentiate between binary and string types.
This is fine for most dynamic languages as "strings" can hold both string and
binary data. However Javascript has very distinct binary types and thus we
need separate types within the serialization format.

------
makmanalp
Pure javascript p2p video streaming, here we come!

------
drivebyacct2
Video or audio chat? Why? You need the new media stream components to get a
usable stream for those anyway, and if you have that, you might as well use
PeerConnection.

~~~
JoshTriplett
Javascript can do real-time audio decoding in modern browsers, and can almost
do real-time video decoding as well. While in general a site should use the
standard components rather than reinventing them, the ability to do so allows
experimentation with creative ideas that browser vendors haven't thought of
yet. The more you can do without increasing the surface area of the browser-
to-site interface, the better.

~~~
minikomi
And browser-site-browser!

