Live data from Hacker News

Build a real-time Twitter clone with LiveView and Phoenix 1.5

phoenixframework.org

211–220 of 249 posts

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#211

I've been following this project for 5 years now, and I've really hoped it would take off. However, part of what made (and to some extent, still makes) the Rails framework so great is the surrounding ecosystem of well supported gems that makes building tedious things a breeze. I built a few things in Phoenix in the past, and while the core framework is very simple and elegant to use, I recall having to write my own f…

You are correct. Phoenix is better, but the community code is not there yet. Having said that... instead of using a big upload library we just do upload + signing for Azure in two very small modules. Sometimes you realize that you might need to write something yourself, true, but also that you don't need to make a full-featured Active/Action library out of it.

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#212
post #34

Question to the former Rails devs out there: We mostly see threads fawn over Elixir and Phoenix, have you experienced any downsides to switching? Anything you miss from Rails? I'm convinced to give it a try after that demo!

I have ~6 years experience working in rails and ~3 years working with Phoenix. The only downsides I can think of are lack of official clients for APIs, and some missing packages. For example, if I wanted to do some PDF work I would really miss the prawn library. I don't miss anything from rails, Phoenix IMO is a superior web framework.

I agree. Luckily, sometimes the fix is easy. For example, I packaged my invoice PDF library[0] as a Docker container and simply created a small Elixir module that calls it.

[0] https://github.com/strzibny/invoice_printer

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#213

Earlier quoted context omitted.

correct. I was just wondering if it also has inbuilt http server as well to process things like static files etc or is that completely on 3rd party tools like nginx (which I love btw). Kinda like in Golang where you could technically use the static file server but I always use nginx for those things.

Cowboy is Elixir's built-in HTTP server. You can configure things like Nginx or Haproxy as you would with most other frameworks.

Cowboy is not made in Elixir and it's not built-in. It's an HTTP server made in Erlang (which Elixir can call at no runtime cost): https://github.com/ninenines/cowboy

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#214
post #186

Earlier quoted context omitted.

I’ve invested a lot of time into both Go and Elixir. I like both languages a lot. My anecdotal view of the marketplace is that Elixir recruitment emails tend to come from startups looking for their 2nd or 3rd dev, usually full stack, and the salaries are nothing special. Go recruitment emails tend to come from bigger companies looking for backend devs, often hoping for kubernetes experience too, and the pay is higher…

what would you say are the benefits of using LiveView over react?

With LiveView, you've got one code base. There's no frontend/backend split, so you don't think about the API, you don't worry about going back and forth between JSON and all the associated error handling, you don't worry about versioning and keeping deployments in sync when/if you break APIs.

You shouldn't really compare it to React, you should compare it to your whole stack, and see how a lot of the code and the worries just kind of go away.

This is much like how it used to be with classic server-side rendered Rails/PHP/Phoenix... except with LiveView you can update part of the page running on the client, in response to events coming from the client without a page refresh.

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#215
post #125

Earlier quoted context omitted.

> When I say perfect, I mean, there has been never once in my career where I hit a roadblock due to the language's limitation or complexity or flawed assumption. I faced this with other languages, but not Elixir. That is interesting. I've gone from Geocities pages to ASP Classic, PHP, WP, Rails, Flask and have been dabbling with Elixir and Phoenix for a bit. So far LiveView (and some bits of Elixir in general) has be…

It sounds like you're mostly backend and struggle with the blending of backend/frontend with liveview?

I haven't had extensive front-end experience writing React code but I've been around the block with JS. I'm pretty familiar with the event model of "hey guys, I want to do something on click, so let me wire up this handler which executes X when Y happens".

The struggle is mainly around the nuisances of how certain things work with LV and what the implications are of using X vs Y with practical examples. I wrote a forum post asking for help about this the other day at https://elixirforum.com/t/concrete-examples-of-when-to-use-l....

Then there's other things like wanting to do authentication. I know in theory you'll need to create a controller action to create / delete the session and there's phx-trigger-action to submit a LV form to a controller but there's no code examples anywhere on how to pull this off and get a "current_user" like you normally would with a non-LV set up. But authentication is one of the most important things in any app.

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#216
post #125

Earlier quoted context omitted.

> When I say perfect, I mean, there has been never once in my career where I hit a roadblock due to the language's limitation or complexity or flawed assumption. I faced this with other languages, but not Elixir. That is interesting. I've gone from Geocities pages to ASP Classic, PHP, WP, Rails, Flask and have been dabbling with Elixir and Phoenix for a bit. So far LiveView (and some bits of Elixir in general) has be…

LiveView is much much easier to understand if you have a solid understanding of how Elixir works in a non-webdev setting, because Phoenix hides a lot of the process architecture that it's leveraging to serve pages, and it's front-and center in LiveView. And also, it's easy to find help for Flask and Rails by googling because... It's been around longer. LiveView has been GA for less than a year, and even some major sh…

Yeah, that's one of the main problems, almost every blog post is out of date because live components are new and there's introductions to many other new things as well.

But then I look at the Live View equiv. in other frameworks. All of which came well after Live View since they are modeled after it.

For example: https://laravel-livewire.com/docs/quickstart in Laravel. I'm not a Laravel developer but their documentation is next level amazing and the author of the library even has a screencast series going that is fully up to date where he builds a real app using Live Wire to demo how it works in practice.

I don't even know Laravel at all, but I can skim their docs and get a feel for how to solve real problems like validation, authorization, pagination, and everything else is focused on practical examples and explaining things very well in the process.

But with Live View, the docs are not anything like this. It reads more like a low level guide on the API itself, not how things work in practice and when you should use certain things or how to write common web dev features. After reading the docs, you're left wondering "ok, but how do I get started using Live View in practice?", IMO at least.

There's also the Rails equiv. which is https://expo.stimulusreflex.com/. Besides the docs there's a bunch of real practical examples, with a live demo of how they all work without having to install anything. With Live View, we have an example repo but it's very out dated at the moment to the point where you can't even follow it with the docs and it seems to not be based on best practices anymore since new things were released with LV.

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#217
post #156

Earlier quoted context omitted.

Any hope of getting this as a text article, or even a git repo? Blind user here who can't see code embedded in a video, but can read ascii-text with a screen-reader perfectly fine. People who don't enjoy videos for various reasons would probably like a text version too.

Hi miki123211, I wrote up a transcription for you. It details the code he's talking about, along with the context of what's going on, and why. https://pastebin.com/raw/WxH0uAsf If Pastebin doesn't work for you, let me know and I can get it hosted at a different location. My apologies if there are any mistakes in this. I'm not familiar with Phoenix, but found this video very interesting, so wanted to make sure it coul…

Thanks, that works. The raw link is perfect for accessibility, as there's no garbage on the page.

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#218
post #156

Earlier quoted context omitted.

Any hope of getting this as a text article, or even a git repo? Blind user here who can't see code embedded in a video, but can read ascii-text with a screen-reader perfectly fine. People who don't enjoy videos for various reasons would probably like a text version too.

Hi miki123211, I wrote up a transcription for you. It details the code he's talking about, along with the context of what's going on, and why. https://pastebin.com/raw/WxH0uAsf If Pastebin doesn't work for you, let me know and I can get it hosted at a different location. My apologies if there are any mistakes in this. I'm not familiar with Phoenix, but found this video very interesting, so wanted to make sure it coul…

Thank you for doing that, good job!

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#220
post #57
post #42

I wrote a little app recently to test out live-view. It was my first time really working with it, though I've been writing elixir for years. https://gif.energy Didn't really have any issues. There were maybe one or two gotchas but they were explained clearly by the docs (appending vs updating elements) and I was able to get it sorted easily. That whole app took a couple days, but more than half the time was wasted on…

> It doesn't make sense for certain types of apps, but it really adds a ton of value and saves a lot of time when the use case is right What are some of these use cases?

I'm not the person you asked this, but the BEAM (and phoenix by extension) excels in highly parallel contexts.

basically if you got an application which wants to connect everyone to each other in real time, thats a perfect usecase for the BEAM. so chat rooms, live-feeds, comments, video/audio conferencing, etc.

and thats also exactly where phoenix excels in my opinion as a occasional user. (never professionally though) quick and seamless communication between silly amounts of people with almost negligible amount of resources while being error tolerant to an extreme (functional, so almost no state)

just try it out on a weekend. its definitely worth it just to see how web-development couldve been. you'll probably go back to the old way, because thats just how you earn your money and where you already have your expertise... but its definitely amazing to see how easy it can be

Post reply on HN