Live data from Hacker News

If Not SPAs, What?

macwright.com

341–350 of 456 posts

Re: If Not SPAs, What?

#341
post #332

Earlier quoted context omitted.

> Experienced programmers know that JS is an awful language BS blanket statement. Some - many, maybe - programmers that in all likelihood multiply your experience and talent by orders of magnitude believe it's a great language. Not everyone working with JS is doing so with a gun to their heads.

I don't know any polyglot programmers who would consider javascript better than at least one of the other languages they use, and would ditch js for those if they had the option. TypesScript, maybe.

Note how I didn't say that many polyglots may think it's the best language, just that it's great as opposed to awful.

I know as a fact from watching tech conferences and talking to people that some elite-level polyglot programmers make it their main working language out of pure choice. Surely one can't assume that everyone doing bleeding-edge Javascript at places like Google is programming every day in absolute misery, or that it's the only thing that they know.

Me personally, I've possibly enjoyed programming in C, OCaml, Swift or Python more at times, but I think ES6+ Javascript is great and I'm happy to use it.

Javascript appears as the 11th most loved language in the SO dev surveys, with 66% of devs working with it reporting to love it, while it appears quite far down in the dreaded list. Typescript indeed fares much better. [1]

Of course, there is the question of whether respondents are True Programmers™ or posers, but I think that's another debate.

[1] https://insights.stackoverflow.com/survey/2019#most-loved-dr...

Re: If Not SPAs, What?

#342
post #207
post #171

Earlier quoted context omitted.

I have literally never had a worse experience developing than with serviceworkers. Accidentally cache your index.js file? You are now stuck with your serviceworker forever (unless you do some chrome voodoo). The promise is there, but it’s just a gigantic footgun.

If you build your SPA to an index.js file and serve it without a timestamp you're screwed when it gets cached too.

Not nearly as much since every browser has a variety of ways to perform a cache refresh.

Any issue with webworkers is almost by necessity opaque.

Re: If Not SPAs, What?

#343
post #12

My argument for SPAs rests on the completely subjective yet I feel incredibly powerful impact of latency. When anything takes more than 50ms to react, it becomes mentally jarring to the user. Whether it is typing in an SSH session, clicking a menu with a mouse, auto-completing a box, etc - all these things generate a completely different human response and relationship with the application if they get below that thre…

I've designed and programmed highly interactive SPAs for customers large and small, and the reaction is invariably "I can't believe this is a website, it feels like an app". Being non-technical, they can't put their finger on it, but I know that while the base design plays a part, so does the concrete UI implementation. I wonder how many of the people crapping on SPAs are actual front-end or full-stack app devs, or o…

> Being non-technical, they can't put their finger on it

This is an interesting perspective. To me, SPAs blur the line between what's happening locally and server-side, so my impatience with slow functions on an SPA page is much greater than the same thing happening on a SSR page. Maybe it's just my conditioning to expect things on a single page to work much quicker as opposed to moving between pages.

IMO, well-designed SPAs should make use of the context-switching function of a complete page fetch in situations where the user might need to wait a relatively longer time for something to load instead of loading bars/spinners.

Re: If Not SPAs, What?

#344
post #336
post #328

Earlier quoted context omitted.

> It's still not a silver bullet. There's lots of things in a LV driven app where you're still wondering what front-end library to use with it. > Typically you wouldn't use LV to handle: > Menu drop dropdowns, tooltips, popovers, modals (in some cases), tabs (when you don't want to load the content from the server) or things that change the client side state of something but don't adjust server state. My experience i…

> My experience is that LiveView is fine for all but the last use case. I wouldn't want to impose a 50-500ms+ delay on someone to show a menu drop down or a tooltip or most of the other things listed out. With LV everything involves a server round trip. That's great for when you need to make a round trip no matter what (which is often the case, such as updating your database based on a user interaction), but it creat…

> My experience is that LiveView is fine for all but the last use case. >> I wouldn't want to impose a 50-500ms+ delay on someone to show a menu drop down or a tooltip or most of the other things listed out.

It's basically a UX standard that a tooltip only shows up after a few seconds, so that strikes me as a particularly bad example. That said, sure, if instant tooltips are important, a tiny bit of js and a specific class name in your markup would solve it.

> With LV everything involves a server round trip. That's great for when you need to make a round trip no matter what (which is often the case, such as updating your database based on a user interaction), but it creates for very unnaturally sluggish feeling UIs when you use LV for things that you expect to be instant.

Yeah, I do agree on that. While I feel using a tooltip is a bad example, in practice I wouldn't implement tooltips or menus in LiveView. Those would just be solved via some CSS trick or some plain old JavaScript.

> LV feels amazing on localhost but the internet is global. I still think it's worth minimizing round trips to the server when you can, not because Phoenix and LV can't handle it but because I want my users to have a good experience using the sites I develop.

I'll give you that generally I wouldn't use LV for tooltips and popups. But in part because those are really easy to solve without it.

But for /so/ much of the stuff involved in a SPA the latency has not been a problem in practice.

Consider tabbed content. Sure, I could make it all 'instant' by preloading the various bits of content and writing js to switch between these bits. But I can avoid that entirely by preloading those bits in my templates and using LV to switch/update classes. The tiny latency downside is worth the upsides: being able to update the content in those tabs live with no extra code (no API calls, no client-side frameworks, and server-side rendered as a nice bonus!).

My general approach is that I use LV as a default, and then use the 'Hook' system and some custom JS when latency is a concern. In practice that doesn't amount to much. So it's not a silver bullet, but it simplifies so much of what a typical SPA does.

Re: If Not SPAs, What?

#345
post #332

Earlier quoted context omitted.

I don't know any polyglot programmers who would consider javascript better than at least one of the other languages they use, and would ditch js for those if they had the option. TypesScript, maybe.

Note how I didn't say that many polyglots may think it's the best language, just that it's great as opposed to awful . I know as a fact from watching tech conferences and talking to people that some elite-level polyglot programmers make it their main working language out of pure choice. Surely one can't assume that everyone doing bleeding-edge Javascript at places like Google is programming every day in absolute mise…

> Note how I didn't say that many polyglots may think it's the best language, just that it's great as opposed to awful.

Fair enough :). I think 'great' is a bit of a vague concept, but I definitely would agree that it's far from awful.

I remember when I wrote a lot of JS back in the day ("Javascript: The Good Parts"), I did feel that stripped from the bad parts, I often preferred the elegance of the basic good parts over, say, Ruby and its "blocks, procs and lambda's" (for example).

Re: If Not SPAs, What?

#346
post #151

The fundamental problem is not that the SPA pattern is bad, is that it takes a lot of skill and effort to make a proper SPA. Obviously, skill and time are scarce resources and the result is that most SPAs are crap. OTOH all these component based frameworks have definitely brought us a much better way to produce interactive experiences compared to the jQuery days. This is not related to SPAs at all. You can use React/…

> The fundamental problem is not that the SPA pattern is bad

While it's not bad, SPA forced you to do view validation twice, one on backend and another on frontend. (Generally)

Let's say that in HN not everyone can view upvote score of comment. With classic server rendering, you can put the check on view directly (though not recommended, it's sometimes useful to cut corners) and it's guaranteed that those users won't see the score.

OTOH you can't do that with SPA, since you can easily sniff the content via API response.

Re: If Not SPAs, What?

#347

I'm kinda surprised that apparently we've moved on from SPAs. I've recently started a new project with preact and an express backend, and I'm in love with the smoothness of the dev experience. Seems like all my problems have been encountered already, there's dependencies and heuristics for everything. I'm just really productive and my app looks great. Surely, all of that wouldn't be the case, had I tried some random…

I'd say this is perhaps an unknown unknown situation. I've had a wonderful time working with Preact and Express, but I wouldn't go back to it after becoming comfortable with the LiveView paradigm.

Re: If Not SPAs, What?

#348

I use Clojuresript with a react interface to create SPAs for data analytics UI at work. It is much simpler and easy to manage. For me developing applications with javascript tend to get complex over time as the app grows. State management is really simple in Clojurescript. I was able to create reusable components which can be ported over to new projects with little effort. I now find it much more easier to develop th…

In your video, you're just hitting localhost.

Re: If Not SPAs, What?

#349

Earlier quoted context omitted.

I suspected things were getting too complicated in this space when I read that someone wrote a 150 page book on React Router

This hasn't been my experience. 10 to 15 minutes of looking at React Router's documentation was enough to get started with it. The major version bumps, however, have been a little taxing. If it takes six major releases to get the paradigm right, you should've done more research before moving onto the implementation phase.

A while back I was faced with using whatever god-awful backwards-incompatible version of react-router to use, or instead to go for a routing solution that wasn't as insane. I don't remember what I picked, but I think it was page.js. Something that's been around forever. It was astounding to me how much it simplified the whole project. I truly can't figure out what react-router actually brings to the table, considering it's version history, compared to the myriad of alternatives.

Re: If Not SPAs, What?

#350

Earlier quoted context omitted.

It’s remarkably efficient and simple: https://stackexchange.com/performance For those who are discouraged by the massive complexity of Kubernetes/Terraform and various daunting system design examples of big sites, remember you can scale to a ridiculous levels (barring video or heavy processing apps) with just vertical scaling. Before you need fancy Instagram scale frameworks, you’ll have other things to worry about l…

Wow. Stack Exchange is a curious case study. I share the general HN sentiment over microservices complexity but just to play devil's advocate... I suspect that server cost in this case is asymptotic. If the (monetary) cost of SE's architecture is F(n) and your typical K8s cluster is G(n), where n is number of users or requests per second, F(n) very large. In essence, the devil's advocate point I'm making is that mayb…

Microservices will add latency because network calls are much slower than in-process calls.

Microservices, as an architectural choice, are most properly chosen to manage complexity - product and organizational - almost by brute force, since you really have to work to violate abstraction boundaries when you only have some kind of RPC to work with. To the degree that they can improve performance, it's by removing confounding factors; one service won't slow down another by competing for limited CPU or database bandwidth if they've got their own stack. If you're paying attention, you'll notice that this is going to cost more, not less, because you're allocating excess capacity to prevent noisy neighbour effects.

Breaking up a monolith into parts which can scale independently can be done in a way that doesn't require a microservice architecture. For example, use some kind of sharding for the data layer (I'm a fan of Vitess), and two scaling groups, one for processing external API requests (your web server layer), and another for asynchronous background job processing (whether it's a job queue or workers pulling from a message queue or possibly both, depends on the type of app), with dynamic allocation of compute when load increases - this is something where k8s autoscale possibly combined with cluster autoscaling shines. This kind of split doesn't do much for product complexity, or giving different teams the ability to release parts of the product on their own schedule, use heterogeneous technology or have the flexibility to choose their own tech stack for their corner of the big picture, etc.

Post reply on HN