4 ms·
This framework is really out there. It is well ... different and interesting. Here are some not so conventional things going on: * Write your page in Erlang.
by rdtsc 13y ago
This framework is really out there. It is well ... different and interesting.
Here are some not so conventional things going on:
* Write your page in Erlang.
* Even translates Erlang to JS as a parse transform.
* Websockets (with a fallback mechanism) is the default connection mechanism.
* Don't want to use JSON for some crazy reason? That's alright, user Bert (and ship binary encoded Erlang terms to the browser!).
* Can render stuff on the server and send the whole thing over the websocket connection.
https://github.com/5HT/n2o https://github.com/5HT/n2o
- toast0 13y agoJSON 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.
- rdtsc 13y agor17 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 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 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.
- MrBuddyCasino 13y agoI 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?
- felixgallo 13y agoSpoiler alert: servers don't do that, and even if they did, the clients would have to do it too to save bandwidth.
- pessimizer 13y agoContent-encoding: gzip
- 5HT 13y agoThis is not applicable to WebSockets.
- yetihehe 13y agoYeah, websockets have their own method: http://stackoverflow.com/questions/19298651/how-does-websocket-compress-messages http://stackoverflow.com/questions/19298651/how-does-websock.... Cowboy already supports x-webkit-deflate-frame, will support more soon.
- alco 13y agoNo. 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.
- MrBuddyCasino 13y agoThats what I meant, sorry if the wording was poor.
- rdtsc 13y agoJoe 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"
- hackerboos 13y ago>Websockets (with a fallback mechanism) Not enough frameworks make this as seamless as it should be. So it's refreshing to see it done here. I've been looking at Phoenix (Elixir not Erlang) but the problem is that I'll have to do logic to detect when WS are available and do the fallback myself which results in more code server side. I think this is something that should be handled by the framework itself.
- 5HT 13y agoIt is handled by N2O automatically. See how https://github.com/5HT/n2o/blob/master/priv/bullet.js https://github.com/5HT/n2o/blob/master/priv/bullet.js
- chrismccord 13y agoI'm the author of Phoenix. I'm glad to hear you're giving it a look! I spent a lot of time thinking about the WS layer and fallback support. Ultimately I settled for standard WS with a small multiplexing layer on top. For those that need fallback, they can drop in websocket-js (flash fallback, compatible with native WS api). Have you taken at look at this for your fallback support? https://github.com/gimite/web-socket-js https://github.com/gimite/web-socket-js Phoenix is still far from 1.0, so any and all feedback is welcome.
- hackerboos 13y agoAdmittedly no but I'll give it a look now thanks.
- findjashua 13y agoI'm new to Elixir (and FP in general), but I really like the language. I came across a couple of youtube videos on Phoenix , and it looks really nice (reminds me of Rails). I think something like Sinatra would be even nicer, for 2 reasons: 1. the standard these days is to have a rest api serving json to web/mobile clients, so a Rails-like framework seems overkill 2. Pretty much all my friends who are learning web dev on their own, find Sinatra/Flask way easier to get started with than Rails/Django. Regardless, Elixir (and Phoenix) is a great leap forward compared to the other options for building concurrent, reliable servers. I hope more people try it out before falling for hype/marketing (cough node.js cough mongodb cough cough)
- 5HT 13y agoSome mentions about the list: * You can use both Erlang DSL and/or DTL templates * You can use JSON, BERT, RAW BINARY messages. see http://synrc.com/apps/n2o/doc/web/protocol.htm http://synrc.com/apps/n2o/doc/web/protocol.htm * You can use N2O both as server-render and in SPA mode