13 ms·
Phoenix 1.7 is View-less
- drannex 4y agoThis definitely reduces some of the cognitive overhead of designing out a Pheonix service, thats for sure. A really welcome change in my eyes.
- Crazyontap 4y agoSpeaking as an amateur programmer, is this like Laravel's livewire or intertiajs with inline blade component? (but in Elixir). Or is this something else?
- thedangler 4y agolivewire was inspired by liveview. I think livewire 3 will be more like the newer version of liveview
- bnt 4y agoWell, unless it moves completely to Websockets, it will still remain a slow mess.
- jnsaff2 4y agoI think livewire was inspired by phoenix liveview. I remember there was even a podcast interview about it.
- freedomben 4y agoYes, there are a lot of similarities. As mentioned in siblings, Livewire was inspired by LiveView so they are directly related.
- cultofmetatron 4y agolive view is the original and best. imitators use long polling to periodically check for updates. liveview spins up a dedicated vm process for each active user and can push updates over websocket to update things. This process can do things like listen for serverside events as well.
- wstuartcl 4y agoIt may be redundant but I think its always important to note that processes as listed above are not like os processes here -- but an extremely lightweight internal VM thread like thing in the BEAM VM. In is not uncommon to have many millions running in the beam VM. Very much lighter than threads or OS processes.
- metaltyphoon 4y agoPig backing here… is this like Blazor server-side?
- ch4s3 4y agoYes, Blazor is inspired by LiveView.
- tiffanyh 4y agoElixir/Phoenix has hit full-stride. I feel like the next big unlock in user adoption is continued improvements to BeamAsm. Hopefully something on the order of 100-200% raw performance speed up. Note: I’m talking about raw perf, not concurrency. A few other additions to Phoenix 1.7 include: - verified routes - tailwind built in - additional web server support (bandit) https://www.phoenixframework.org/blog/phoenix-1.7-released https://www.phoenixframework.org/blog/phoenix-1.7-released
- enraged_camel 4y agoActually, I think the next big unlock in user adoption is static typing. Lack of it is frequently cited as the number one reason that makes people hesitate in switching to Elixir. I know it is an active research project right now, and I hope it bears fruit.
- tiffanyh 4y agoHas anyone figured out how to do static typing in Erlang yet? FB a few years ago announced they were going to work on it for WhatsApp but then it was indefinitely delayed. There’s also been a few other attempt, but I don’t believe anyone has succeeded. I know Gleam exists but haven’t dug into it. Anyone more in the know care to share?
- h0l0cube 4y agoJose has been working with some PhDs to attempt to implement static typing https://elixir-lang.org/blog/2022/10/05/my-future-with-elixir-set-theoretic-types/ https://elixir-lang.org/blog/2022/10/05/my-future-with-elixi... In the meantime I don’t know what people have against using @spec. It’s a far more powerful type specification than the majority of static-typed languages out there
- tiffanyh 4y ago> Actually, I think the next big unlock in user adoption is static typing. From reading that post, it sounds like Jose does not believe static typing is needed. But a nice to have to address a very narrow set of use cases that primarily would help for documentation, not bug mitigation.
- gnutrino 4y agoThis makes sense to me. Views always seemed a like unnecessary boilerplate to me. Better to keep all the code together in one module, and just import common functions. On the other hand, I don't typically like defining the template in a sigil, unless it's a really small one, so I probably won't do that much.
- freedomben 4y agoI agree in the case of HTML rendering, but I write a lot of JSON APIs and putting the JSON definition in the View has been very pleasant. It didn't say in OP, but how does this change an API? Maybe a `GreetJSON` instead of `GreetHTML`?
- a_bored_husky 4y agoYes, exactly like that.
- eclark 4y agoCorrect. You write a moduleJSON. So this is about what we have for one of our controller/views: defmodule MyWeb.SystemStateJSON do def index(%{summary: summary}) do %{data: summary} end end
- sergiotapia 4y agoI'm building a startup in my free hours using Phoenix Liveview. I can ship features in hours vs days thanks to the simplicity liveview gives me. ZERO react/JS nonsense. I back to writing server side rendered templates with for-free reactivity. Give it a try it's very productive
- password4321 4y agoThe downside as I understand it is the extra work to manage UX for connections with high latency and/or going offline, correct?
- freedomben 4y agoYes, the downside is basically offline. When offline the LiveView app doesn't work because it can't update it's DOM. A decent solution I've enjoyed is using Alpine.js. It fits very neatly into the LiveView philosophy and can do nearly all UI updating easily. It still minimizes the amount of JS you have to write but you get good client-side update behavior. High latency isn't an issue if you do it correctly by using the loading classes and what not so that the user knows they are waiting for some data to load. It's pretty much identical to a typical React SPA that has to show loading indicators while waiting for a JSON call to complete.
- a_bored_husky 4y agoYou aren't suppossed to use LiveView for every interaction, only the ones that require the server to be involved somehow just like a regular SPA. For pure client-side interactions LiveView has some utilities like LiveView.JS or you can use a lib like AlpineJS.
- sergiotapia 4y agoTo me that's a non-issue. How are you going to access a website without internet anyways? If you're talking about "slow" internet, then use Alpine JS to run truly client-side things in those very rare cases.
- 4y ago
- oDot 4y agoPeople using Phoenix Liveview -- how do you serve native apps relying on the same backend?
- sodapopcan 4y agoAs it stands you have to write a separate API, though there is work being done on native [0]. Otherwise, part of the initial value-prop of LiveView is that if you don't need multiple frontends and you don't need offline support--which a whole lot of apps don't--then LiveView drastically simplifies your stack while still delivering "SPA-like" speed. [0] https://native.live/ https://native.live/
- a_bored_husky 4y agoYou would need to write the REST/GraphQL API. Maybe with help from Ash Framework (https://ash-hq.org https://ash-hq.org) to make it easier to reuse logic.
- sergiotapia 4y agoI use Absinthe to expose a graphql API endpoint. The Absinthe resolvers just call the contexts/functions my liveviews call anyways.
- Alacart 4y agolike others have said, you'd probably write a JSON API separately. One thing I'll mention though, is that the conventional design of Phoenix to use context modules often makes that very easy, in that your liveviews and API can just call the same business logic functions to crud resources.
- di4na 4y agoThis. As long as you keep the API relatively simple, something like basic CRUD "restful", it is really low cost to transform your domain model modules (regularly called "Context" in the community) into whatever JSON you need. It is just two different presentation of the same data, so you do the work on the data model and the way to access it in elixir, then you just thinly wrap it in the API for it.
- freedomben 4y agoHex Docs for Phoenix.View mention the change: https://hexdocs.pm/phoenix_view/Phoenix.View.html#module-migrating-to-phoenix-component https://hexdocs.pm/phoenix_view/Phoenix.View.html#module-mig... Phoenix.View is replaced by Phoenix.Component: > With Phoenix.LiveView, Phoenix.View has been replaced by Phoenix.Component. Phoenix.Component is capable of embedding templates on disk as functions components, using the embed_templates function. More on hexdocs.
- andy_ppp 4y agoI was going to come here and link directly to this - the migration from previous versions is always covered in detail and seems to always work which is great. A lot of frameworks seem to struggle with this quality of documentation when upgrading versions.
- ealdent 4y agoSo can we refer to LiveView’s counterpart as DeadView, now?
- sodapopcan 4y agoWe actually already do! I have no links but click around https://elixirforum.com https://elixirforum.com and you'll see referencing "dead views" often enough.
- amalgamated_inc 4y agoCan confirm, I say/hear "dead view" at least once a day ;)
- eclark 4y agoWe're building a startup ( https://www.batteriesincl.com/ https://www.batteriesincl.com/ ) with Elixir and Phoenix 1.7rc (git master really). It's been amazing; I could not be happier. - We went hard on components and it's made building UI's easy. In fact I wrote a test library to make component testing easier. - Live view is so easy with a good component library. I'm not a designer, but with snappy interactions and easy to use components, it's not hard to get something that's exciting. - Elixir is a very nice language to write distributed systems in. Functional in all the right places plus it has OTP. - The community is full of very senior people who freely answer your noob questions. - On-boarding people has gone well. The syntax is friendly enough that experienced engineers grasp the basics, leaving functional programming and OTP left to discover.
- eddsh1994 4y agoWhat does your startup do? I'm not 100% sure based on the blurb, but keen to see product ideas where that tech stack shines :)
- eclark 4y agoWe haven't launched yet (Q1 Next year is the target), so the landing page isn't great yet. We're a platform as a service that you can install on any cloud via Kubernetes, or on your own self hosted Kubernetes. So distributed systems, automated remediations, machine learning ops, etc are the areas we're using elixir.
- tiffanyh 4y agoWhat’s been your experience with Live View? I ask because I’m under the impression that using it comes with some sizable scaling problems, which somewhat defeats the point of using Erlang in the first place. I could be wrong though. Would like to learn more.
- eclark 4y agoLiveView has been pretty great. Mostly it's just a couple of `handle_event` methods away and we have a fully reactive UI. I haven't seen any scaling issues for LiveView. Under the hood there's a websocket that push and pull events from a running GenServer for each session. Since each process is independent it's horizontally scalable as long as your able to route websockets to the same process in a cluster. While not the same, I do know that single machine has been able to scale to a couple of million connections ( https://www.phoenixframework.org/blog/the-road-to-2-million-websocket-connections https://www.phoenixframework.org/blog/the-road-to-2-million-... ) with phoenix channels. Which are harder to scale than independent live views. Also our use case is for smaller scale than that (Not too many companies have a million people looking at their ml deploy pipelines) so I haven't been too worried.
- dooven 4y agoThis has been awesome. I'm currently using the new Phoenix 1.7 generator to build https://locationsquared.com/ https://locationsquared.com/ and I used the view-less layout to have a small helper function to build the meta tags for each pages.
- lnxg33k1 4y agoMakes little difference to me, it has been few years now that I create API backends consumed by separated frontends, them being either CLI or JS etc. If anything for me this approach has done wonders for e2e tests using api mockservers But probably for simpler projects and new starters makes sense But I would really suggest anyone out there just to avoid backend-frameworks-based view/templating (guess json responses are view layers) layers
- thex10 4y ago> But I would really suggest anyone out there just to avoid backend-frameworks-based view/templating I personally struggle to let go of backend templating. It's so easy to translate your data into the right pieces of markup in the template, and just serve the fully-baked HTML to the user instantly. How should I be looking at this differently?
- lnxg33k1 4y agoI think few reasons that made me go with this new (for me, at the time) approach were: - Backend/API that can be consumed by anything, are frontend-agnostic - Frontend that depends on JSON/source-agnostic data so that can have functionality tested faster (no "proper"/"dynamic" backend involved, just give it some ApiBlueprint/swagger mock server - The frontend rendering isn't a concern of the backend removing some load
- Existenceblinks 4y agoBusiness-wise, I cut the JS only part as a free plan (local use only), so it's zero dollar cost. The paid plan has the Phoenix Channel integrated.
- gedy 4y agoAs company gets larger, it's so nice to have "important business logic" via API only, that way mobile apps, web apps, partners, etc can use same logic/data. Server side templating is a real drag on enabling this.
- 4y ago
- thriftwy 4y agoSo did the MVC model just got stripped down to just C, a.k.a. Servlet but with more amenities?
- h0l0cube 4y agoI feel like the title is a bit misleading. All 3 are still uncoupled, it's more that the V and C is now cohered in the directory structure, which seems a bit more ergonomic.
- rjh29 4y agoI love how web development has gone full circle. In 2006 I wrote a chatroom site that was server-side with Ruby on Rails-based javascript sprinkled in for realtime page updates. It was long polling of a single HTTP request (websockets didn't exist then) but it worked extremely well. Never liked SPAs and the npm bloat. Happy that stuff like Svelte and Phoenix is taking it back to the server-side with JS sprinkles place which seems optimal to me.
- davidatbu 4y agoCan someone _please_ get around to building a framework for Gleam[0] so that I can finally get over my hesitance to dive into a BEAM language over erlang's/elixir's dynamic typing? [0] https://gleam.run/cheatsheets/gleam-for-rust-users/ https://gleam.run/cheatsheets/gleam-for-rust-users/
- deleted 4y ago[deleted]
- ch4s3 4y agoYou can use gleam in an application that uses Phoenix for web plumbing pretty easily.
- davidatbu 4y agoGood to know!
- wstuartcl 4y agoI think if you actually try elixir you will find its lack of typing to be of little concern.
- davidatbu 4y agoGotcha. Appreciate the encouragement!
- amalgamated_inc 4y agoRemember, he who types statically types twice the amount and thus half as fast. There's honestly no need for static typing in Elixir.
- davidatbu 4y ago> he who types statically types twice the amount and thus half as fast. If you mean by this, "static typing is not worth the effort", the zeitgeist is definitely not with you on this one. > There's honestly no need for static typing in Elixir. I'd love for that to to be the case! Is the only way for me to find out for me to give it a try, or are there somethings you can say to help me believe?
- tobyhinloopen 4y agoSo many great changes! I can’t wait! I’ve been using Phoenix / Elixir since 2016 and i’ve been really happy with it
- rahimnathwani 4y agoWhat's the best way to get started with Phoenix 1.7, for someone with no Elixir experience? Should I learn some Elixir before diving into the Phoenix docs?
- pjm331 4y agoWith the caveat that I’ve only dabbled with elixir and Phoenix for side projects I really liked the approach taken in this book - https://pragprog.com/titles/lhelph/functional-web-development-with-elixir-otp-and-phoenix/ https://pragprog.com/titles/lhelph/functional-web-developmen... In which you first build out the functional core in just elixir and then hook up Phoenix as the web interface
- frellus 4y agoPersonally I'd highly suggest investing in time in both, but start with basic Elixir and understanding the concurrency model and functional programming if you're coming from an imperative or OOP world. If you like learning by watching videos, I cannot recommend this course highly enough, it's what accelerated me from zero to a lot of the key concepts: https://codestool.coding-gnome.com/courses/elixir-for-programmers-2 https://codestool.coding-gnome.com/courses/elixir-for-progra... The instructor speaks in a way that's easy to consume, for me. It assumes you already know how to program, and the way he talks about the various topics gives a lot of depth to the various concepts that's missing in a lot of material I've seen -- he explains the "why" of things, not just the "what" and "how". The course will have you implement a hangman game from a basic client/server model, eventually to a Phoenix non-Liveview page, then to LiveView, so you get a great understanding of how to architect an application the right way and how to make good design decisions. The whole thing costs just $35, which I think is perfectly reasonable and doesn't break the bank for anyone. The Pragmatic courses are good, but Phoenix is too out of date in them now and it'll cause a lot of pain if you're trying to follow along exactly. Phoenix has evolved quite a bit from 1.5 to 1.6 and now 1.7, and those changes can be a bit confusing to a first time person. Other place to start would be just the basic docs on the Elixir and then Phoenix site. They're really good. Elixir School is also good (and free).
- 4y ago
- rsrsrs86 4y agoJosé Valim is amazing
- blueblahvlah 4y agoView-less meaning Phoenix.View module is refactored/replaced. The amount of boilerplate code is still a challenge in Phoenix. Worked on a large project using live views. Pros: - can achieve interactivity without using client side js frameworks - less developers / man power needed compared to client side js frameworks - evolving in right direction - community / forums Cons: - still evolving and releases are breaking (no backward compatibility). - the amount of boilerplate code which is generated is too high. - forms are basic and need to evolve for handling challenges which come with Server side rendering and interactivity - there was leex, then heex, now components taking centre stage. - most of the books, tutorials, videos, articles are stale due to frequent changes / evolution Elixir/Phoenix Community is small and non toxic on forums. But sometimes the size of community is drawback. Some questions get fewer replies and will be a puzzle for the developer who is working on the project (this does not happen frequently). Anyone who wants to adopt Live View for production projects will have to overcome these challenges. (edits: formatting)
- preciz 4y agoI'm working on a medium sized LiveView project now. The leex to heex change was 1 day for us and the benefits were immediately worth it. (HTML auto formatting and validation, better syntax). Components were a thing before heex, I wouldn't say they are taking center stage now, there is no rewrite required there, you either use Component, LiveComponent or LiveView. When to use which is very simple as the their name indicate.
- blueblahvlah 4y agohttps://github.com/phoenixframework/phoenix/issues/4975 https://github.com/phoenixframework/phoenix/issues/4975
- preciz 4y agoThanks for linking this, we use LiveViews, we have only a few controllers.
- sb8244 4y ago
- revskill 4y agoThe main issue, is there's no demo !
- Alifatisk 4y agoWhat is the Rails equivalent to Livewire? Actioncable? Hotwire? InertiaJs?
- danieljacksonno 4y agoHotwire
- Alifatisk 4y agoDoes StimulusReflex count?
- d_sc 4y agoLiveView is evolving into a great piece of tech, but as others have noted elsewhere in the comments one of the challenging parts with LiveView right now (and to an extent Phoenix) is the outdated books & tutorials. Bruce Tate and Sophie DeBenedetto have been authoring the book “Programming Phoenix LiveView” (https://pragprog.com/titles/liveview/programming-phoenix-liveview/ https://pragprog.com/titles/liveview/programming-phoenix-liv...) which has the potential to be a great source for people that want to really dive into LiveView. The challenge though is they have not updated it to support the changes introduced in 0.18.0 which makes it really hard to start using the book when a new Phoenix application “mix phx.new dev_app” looks different than what’s in their book and some of their code breaks with the default installed versions of included plugs. While I wish the book would receive an update sooner that brings it back to a compatible state (meaning there are no issues following along with the book), the good news is they have committed to having the book be updated when LiveView hits 1.0.
- blueblahvlah 4y agoAny link/doc of roadmap for LiveView from 0.18.3 to 1.0 ? [edit] I like the Project Status section of bandit - https://github.com/mtrudel/bandit#project-status https://github.com/mtrudel/bandit#project-status
- _a_a_a_ 4y agoJust what is it? I can't find a simple one sentence description
- kevinplusone 4y agoWas excited to hear views are being dropped. Been creating Web applications for over 20 years and have seen very little benefit of using views. Always saw them as an extra layer to think about, especially when trying to find where a function/method is defined when maintaining code. I think the MVC/MVVC ideas as applied to Web development were a step forward in getting people to organize code in general, but a step backward in keeping coherent, colocated, and maintainable code as projects grow. I've found that reusable encapsulated components for structure and well documented utility classes for CSS styles have always been the most helpful tools for creating maintainable Web applications, which seems to be the direction Phoenix and LiveView are going.