Hacker Newsnew | past | comments | ask | show | jobs | submit | shthrow's commentslogin

How is it a good idea for every user interaction to hit the server?


Websockets are crazy fast and the BEAM has crazy fast IO (at the expense of slower CPU-bound tasks, but that is another story). LiveView also minimizes (to an obsessive degree) the amount of data that flows over the socket. The payload is about exactly the size as the exact diff being rendered in the DOM (often times this is simply the `innerHTML` of a node).

The advantage is stack simplicity. As stated in the beginning of the article, LiveView completely removes your need for any kind of API between your front and backend. It also makes it very easy (through JS hooks) to offload any interactions you want to the client if that makes more sense. But of course, if you end up offloading EVERY interaction to the client, you should be using a frontend framework--LiveView is very clear about not being suitable for every need--if you are building a super UI heavy app (like a text editor or painting app or the like), LiveView probably isn't going to cut it.


A server round trip is a cost. It's not a good idea or a bad idea.

I will pay the cost of a round trip if (a) it simplifies my life and (b) the cost is low enough. LiveView simplifies interactive app development (for me). Since I can run my Phoenix servers close to people, the round trip cost is usually very low.


This is not the idea. Interactions that don’t influence server-side state are suggested to be handled by JavaScript. Docs give an example for integrating AlpineJS, but you can use vanilla js or other libraries with little plumbing.


Whether it's a good idea or not really depends on your app, what you're trying to do, and who your users are.

Now if you want to avoid round trips to the server for interactions such as opening a modal, you can!

There are at least two ways to handle this - Javascript hooks that let you attach JS to your DOM, or the light AlpineJS framework. The latter is a perfect fit for Liveview and it's part of the unofficial go-to stack name PETAL - Phoenix Elixir Tailwind AlpineJS Liveview.


The first 20-odd years of the web were mostly this way... somehow we managed.


it helps debugging and avoid any issue with cache(old JavaScript, unexpected JS error etc).


No, think of it like checked exceptions, you only need to handle the effect _at most once_ before it reaches the top (it's up to you to let it keep getting passed up or handle it immediately), otherwise the compiler will automatically infer the effect types in the layers between.


Okay, so type inference is the vital feature here.

It can help in a closed code base. In an open code base, you could inadvertently change a public API, breaking callers that are unknown to you, if the type signature of something public is inferred.


Correct, but that is the same for any kind public API though. However that is slowly starting to change with statically typed APIs like GraphQL and Protocol Buffers. You can imagine a public API that is introspected and can tell the client about deprecation and all that.


Old man yells at cloud.

What these people usually don't get is that computer at the end of the day is just a tool. It is a means to an end not the goal. Having a powerful computer for the sake of having a computer doesn't accomplish any meaningful.


"Why did all major software companies settle on parallel career tracks? To keep engineering managers from developing loyalty to engineers."

I think your tone here implies intent


You're right. When I talk about complex systems I generally mean "this behavior emerged because of pressure to optimize for property X", but it's awkward to keep repeating that so I anthropomorphize them for simplicity. Should clarify that at some point.


This is a great clarification. I'd even argue that systems and organizations can have an independent intent, though we don't often use the word in that context.


> I'd even argue that systems and organizations can have an independent intent

You're not the only one: http://slatestarcodex.com/2014/07/30/meditations-on-moloch/ (If section I seems a bit slow - it's busy establishing that there is a problem in the first place - skip to section II.)


Everyone has some kind of social event app as one of their first ideas. It never works.


Same here, I built one called "2 Events 1 Time" failed


yeah i built one over a month and it was a dud


Yeah man my friend built one and it was a dud


Built one in uni. Can confirm.


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

Search: