Live data from Hacker News

Elixir web development 101: collaborative todolist with realtime updates

blog.openbloc.fr

11–20 of 97 posts

Re: Elixir web development 101: collaborative todolist with realtime updates

#11
post #10

Non-representative anecdote : i've recently heard of two teams that started using elixir, they both came from a ruby background, and in both case they weren't using OTP. They both justified using elixir because it was "closer to ruby" (???), and they both seemed to live a pretty difficult time with that language. Which makes me wonder : why would you ever want to use such a special language (purely functional isn't f…

People usually dive into Elixir expecting Ruby, but it’s a very different language. Most of this confusion comes from not wanting to sit down and read a good book about it. The only thing it takes from Ruby is variable and namespace naming (since José Valim was a ruby syntax enthusiast). Ruby syntax is good IMHO, but that’s not the only reason to go for Elixir (far from it).

I recommend the book “Programming Elixir”. Even if you end up not picking the language, it makes a good point about how OOP is a natural enemy to concurrency (because of state) and about how transforming data (I.e functional) is a better match. The language runs atop the Erlang VM, which successfully navigated the troubles of concurrency in ISP nodes a long time ago.

Again, worth a read.

Re: Elixir web development 101: collaborative todolist with realtime updates

#12
post #10

Non-representative anecdote : i've recently heard of two teams that started using elixir, they both came from a ruby background, and in both case they weren't using OTP. They both justified using elixir because it was "closer to ruby" (???), and they both seemed to live a pretty difficult time with that language. Which makes me wonder : why would you ever want to use such a special language (purely functional isn't f…

There is a significant learning curve, but anyone can learn it. It is not much like Ruby, yet it captures much of the joy of programming in Ruby and is far better for structuring large programs. There is optional typing support through Dialyzer, but even without that the compiler will catch many mistakes that annoy me and slow down development in Ruby.

Also - the performance can really make a perceptible difference in user experience even if you don't "need" the scalability.

Re: Elixir web development 101: collaborative todolist with realtime updates

#13
post #10

Non-representative anecdote : i've recently heard of two teams that started using elixir, they both came from a ruby background, and in both case they weren't using OTP. They both justified using elixir because it was "closer to ruby" (???), and they both seemed to live a pretty difficult time with that language. Which makes me wonder : why would you ever want to use such a special language (purely functional isn't f…

I'm guessing what they really meant is "it's close to rails" since the same people made both rails and phoenix AFAIK.

Re: Elixir web development 101: collaborative todolist with realtime updates

#14
post #9
post #8

Earlier quoted context omitted.

Apart from the obvious push capabilities, yes, websocket has much less overhead and is faster than HTTPS. Once the connection is established, you can send requests starting at 1 byte size, whereas HTTP needs the full headers on every request. HTTPS also has a lot of handshake overhead, where you need 2-3 round trips per request instead of a single one with websocket. This can make a world of difference in a 150+ ping…

actually, both HTTPS and WebSocket over TLS (wss://) require a TLS handshake, so it's not like you're constantly doing that after you've loaded the page, but HTTP request/response header sizes could def be a concern.

No, there is not a handshake for every message you send over websocket. You do the handshake only when you open the connection.

Re: Elixir web development 101: collaborative todolist with realtime updates

#15
post #10

Non-representative anecdote : i've recently heard of two teams that started using elixir, they both came from a ruby background, and in both case they weren't using OTP. They both justified using elixir because it was "closer to ruby" (???), and they both seemed to live a pretty difficult time with that language. Which makes me wonder : why would you ever want to use such a special language (purely functional isn't f…

Are those web applications? If they're using Phoenix, they are also using OTP under the hood, but they don't have to use it directly.

Re: Elixir web development 101: collaborative todolist with realtime updates

#16
post #5

OT, but what software did you use to make those gifs on Ubuntu?

Hi, I used gtk-recordmydesktop (beware it will freeze your desktop under Ubuntu 17.10 Gnome but works fine under Unity). It gives you an .ogv file and then there's some editing to get a gif. I described the process at the end of: https://blog.openbloc.fr/javascript-es2015-starter-kit/ Mainly convert the .ogv to .mp4 with ffmpeg (don't have the command here), create a png palette from the video so your gif colors are…

Why make a gif from this rather than a webm (seeing as you obviously know what you're doing with ffmpeg)?

Re: Elixir web development 101: collaborative todolist with realtime updates

#17
post #9

Earlier quoted context omitted.

actually, both HTTPS and WebSocket over TLS (wss://) require a TLS handshake, so it's not like you're constantly doing that after you've loaded the page, but HTTP request/response header sizes could def be a concern.

No, there is not a handshake for every message you send over websocket. You do the handshake only when you open the connection.

HTTP keepalive should get you much of the same benefit, though? The major improvement comes from fewer headers sent over websockets?

Re: Elixir web development 101: collaborative todolist with realtime updates

#18
post #16
post #5

Earlier quoted context omitted.

Hi, I used gtk-recordmydesktop (beware it will freeze your desktop under Ubuntu 17.10 Gnome but works fine under Unity). It gives you an .ogv file and then there's some editing to get a gif. I described the process at the end of: https://blog.openbloc.fr/javascript-es2015-starter-kit/ Mainly convert the .ogv to .mp4 with ffmpeg (don't have the command here), create a png palette from the video so your gif colors are…

Why make a gif from this rather than a webm (seeing as you obviously know what you're doing with ffmpeg)?

What does webm support look like these days? Last I checked neither Safari nor IE had webm support.

Re: Elixir web development 101: collaborative todolist with realtime updates

#19
post #16
post #5

Earlier quoted context omitted.

Hi, I used gtk-recordmydesktop (beware it will freeze your desktop under Ubuntu 17.10 Gnome but works fine under Unity). It gives you an .ogv file and then there's some editing to get a gif. I described the process at the end of: https://blog.openbloc.fr/javascript-es2015-starter-kit/ Mainly convert the .ogv to .mp4 with ffmpeg (don't have the command here), create a png palette from the video so your gif colors are…

Why make a gif from this rather than a webm (seeing as you obviously know what you're doing with ffmpeg)?

The ghost blog allow me to directly upload images to my cdn, it's a little more work to publish a video and I was too tired when finishing this article yesterday to think of better options anyway :)

Re: Elixir web development 101: collaborative todolist with realtime updates

#20
post #3

> channel.on('update:todo' ... > channel.push('delete:todo' ... > Have a CRUD interface over websocket REST over websockets. What's the advantage over HTTP? I know websockets allow for pushing data to clients, but this is pull so apparently there should be no advantage, only more code to write. Edit: maybe you're sharing updates among all the users connected to the server. Still, for sending requests HTTP is enough.…

Performance advantage is pushing messages from the server instead of having the client poll.

The tradeoff is dealing with half-open TCP connections (need an in-process ping to ensure the connection is still alive) and designing the app for state recovery in the case of missed messages.

Post reply on HN