Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

JSON doesn't really fit very well into Erlang structures (at least in r16; I haven't played with r17 yet); so I don't think not using it is that crazy.


r17 does have maps, here is a jsx version with maps instead of proplists for example.

    jsx:decode(<<"{\"library\": \"jsxn\", \"awesome?\": true}">>).
    #{<<"awesome?">> => true,<<"library">> => <<"jsxn">>}
https://github.com/talentdeficit/jsxn

Speaking of json in general, this reminds me of a part of a talk by Joe Armstrong he gave at the React 2014 conf (K things I know about building Resilient Reactive Sytems)

https://www.youtube.com/watch?v=rQIE22e0cW8

Not related to Erlang necessarily, he talks about how at Ericsson they build these cell phone network-to-internet gateways and now they go to great lengths to pack data as tightly as possible on the communication channel, bit by bit, to conserve shared bandwidth and then "here come the users and shove json across the pipe, what a travesty!" -- it was a funny statement, and I never really thought of it that way. So I guess shoving binary across websockets like N2O is not totally insane.


I never understood that argument. The reason you can have nice text based formats is that it will all be compressed by the server anyway, or am I missing something?


No. The reason people use text based formats is so that they could be read by humans without additional tools. Compression reduces the size but it's not reasonable to claim it works better then a binary format designed for light footprint.


Joe also made a funny comment on that if you listen to his talk. He said how "People say ASCII is good because you can see what's on the wire. Well can they see electrons bouncing up and down the wire? They see what a program chooses to let them see"


Thats what I meant, sorry if the wording was poor.


But even then you're left with compressed text. If you're concerned about the amount of data you're sending on the bit level, then you're throwin all that out the second you start pumping out JSON.


Spoiler alert: servers don't do that, and even if they did, the clients would have to do it too to save bandwidth.


Content-encoding: gzip


This is not applicable to WebSockets.


Yeah, websockets have their own method: http://stackoverflow.com/questions/19298651/how-does-websock.... Cowboy already supports x-webkit-deflate-frame, will support more soon.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: