Live data from Hacker News

Second-guessing the modern web (2020)

macwright.com

181–190 of 309 posts

Re: Second-guessing the modern web (2020)

#181

One thing I've seen happen again and again in a lot of technologies is a "framework gravity". A lot of people see this as engineers just wanting to work on "hype" technology but I think what is actually happening is a reflection of global engineering time. React is great for SPAs. Most large companies are working on honest-to-god SPAs. By extension most engineers are working on SPAs. So most tooling is created for SP…

Another big issue is the ability to seamless transition parts of your software between different programming models. We just don't have good solutions to this that I know of. The thing with SPAs is that you are probably worse off starting with a traditional server-rendered HTML web site and slowly introducing more and more interactivity, unless you know you won't eventually be better off with an SPA at the foundation…

The problem you describe is a data modeling problem, its because the same data comes from different places and is stored on multiple places, where each change triggers many changes. Its like like programming using only global variables. The solution is to have one directional data flow rather then bidirectional. UI should only listed to changes- not mutate data directly. Instead UI input should be sent to a client/server data store that in turns trigger the listeners.

Re: Second-guessing the modern web (2020)

#182
post #53
post #45

Earlier quoted context omitted.

You want to know why they exist? Because of Google Core Web Vitals metrics! CLS (Cumulative Layout Shift) can go to zero if you place proper skeletons. I still prefer it to content jumping around when the API response is done.

This is a really good solution to a problem that shouldn't even exist.

Slow APIs? Good luck eradicating those

Re: Second-guessing the modern web (2020)

#183
I have to admit, I’ve been avoiding TypeScript and React for any professional projects.

TypeScript due to lack of experience, but I understand the benefits.

React due to many reasons, but most of which is that I don’t agree with the “benefits”.

I have been working with the Frontend for over a decade and have been on the forefront of its progression. KnockoutJS was a pivotal moment and cemented what followed with Backbone, Angular, Vue, and React (and several others).

It don’t think the current state of development is going in the right direction. But that’s just my opinion and a wild one at best.

Re: Second-guessing the modern web (2020)

#184
post #64

I agree with a lot of these points, but differ slightly in two regards: 1. In my experience React DOES lure people into the "pit of success" in at least one important aspect -- modular and re-usable front-end code. React is certainly not the only way to get this, but it does help force you into some good patterns. 2. The "sweet spot" for React is pretty large. If your site is truly static (e.g. a blog, a product land…

How? It's the most painful, difficult, slow, frustrating, confusing programming experience I've ever had in my 25 years. It's made me want to leave the industry completely and I honestly think I will after this project. It has single handedly slaughtered and destroyed my quarter century love affair with programming. It's a wildly inflexible architecture that aggressively forces their users to conform to an orthodoxy…

Gamedev (w/o big engine) or terminal apps in your favorite language! Lots of freedom to be had in those environments.

Re: Second-guessing the modern web (2020)

#185
post #62

Earlier quoted context omitted.

I think this is a good assumption, but it breaks down when you look at bandwidth costs. A large reason why these apps take so long to load is because of the kb of dependencies and bundles they have to download. That adds up quickly with many visitors, and there's practically no way you would be accruing the same amount of bandwidth costs with a bland PHP or direct HTML response.

You think heavy HTML responses are cheaper than one extra-heavy initial JS request? I'd like to see some analysis on that. I'm assuming if you're building an SPA or any kind of app, many of your visitors and clicks are repeat visitors and won't have to download that bundle... probably once a day, M-Th assuming daily release schedule w/ lets-not-break-it-before-the-weekend policy. I think all that client-side caching…

> many of your visitors and clicks are repeat visitors

I think this isn't a guarantee and depends on what kind of application you're trying to build. A DMV website is (hopefully?) not going to have many users returning every day or even every week or month. If it's not social media or gaming, it's probably not going to have any sort of consistent userbase, so most visitors are not going to benefit from client side caching.

> You think heavy HTML responses are cheaper than one extra-heavy initial JS request?

If we assume "cheap" means cost-wise here, almost certainly. Consider a search engine like Google. If you are generating HTML server side (ex. PHP), the row count is limited by whatever you assume the user's screen resolution will be. That means a few hundred results returned at most, since no user is going to scroll through thousands of results on the same screen. So you perform a DB query and generate the HTML for a hundred rows or so and return it, job done.

Now consider the JS equivalent: the user downloads up to a megabyte of bundled JS. Then, the JS has to perform a fetch call to some API which probably returns the rows in JSON. At last, the client side JS iterates over the JSON and generates some new DOM elements for each row. Job done.

In the JS example, the user's browser had to download the bundle and the API response in order to render the rows, while the PHP example only queried the DB in order to render them. You might think, well the PHP way still uses up bandwidth to get results from the database right? Which is technically true, but pricing wise your database is most likely in the same data center as your web server so you're not paying anything for that bandwidth (since it's going over a physical direct connection cable instead of the Internet proper). Whereas the user is 100% not going to be in the same data center as your API server, so you're going to get whacked with bandwidth charges wherever your API is hosted on top of serving the JS bundle.

Of course, for the majority of people we're talking about pennies here. It really doesn't matter until you start getting more than 1 request per second, at which point every hour of every day of every month of every year is going to compound your bandwidth pricing problem until you figure out a way to slim down your payloads. Or, just do what most news sites do and keep adding third party advertiser JS until your ad profits outweigh your bandwidth expenses. Lots of options in this brave new frontier!

See 1MB club: https://1mb.club/

Re: Second-guessing the modern web (2020)

#186
post #158

Earlier quoted context omitted.

I don't think it makes sense to say "React is a library because you can forego using enough of its features to fall below some arbitrary line". By that logic, I can include Ember in a page and not use any of its features other than `console.log(Ember.VERSION)`, and voila, "it doesn't call you", "it doesn't permeate the codebase", "it doesn't exclude any architectural patterns", therefore it's not a framework. This li…

I don't think it makes sense to say "React is a library because you can forego using enough of its features to fall below some arbitrary line". Please note that I’m not arguing that React itself is or isn’t a framework. I’m simply saying that it can be used in multiple and qualitatively different ways, in contrast with your own position in the comment I originally replied to. In particular, nothing stops you from usi…

> it can be used in multiple and qualitatively different ways, in contrast with your own position

I agree React can be used in different ways but as I already pointed out earlier, this is a not-particularly-notable characteristic shared by a variety of frameworks, so what you're saying is more of a tangent (i.e. that a tool within a class of flexible tools is itself flexible too) than a contrast to anything I said (i.e. that the bullet points support the idea that React is a framework). In order to contrast to my original comment, the logical thing to do would be to present arguments to support the idea that React is not a framework, since that was the point of contention upthread that I was responding to.

Re: Second-guessing the modern web (2020)

#187

Earlier quoted context omitted.

Wait til I tell you about the custom UI system I'm building with canvas. http://www.adama-lang.org/blog/ui-flow-with-adama

Nice blog post! I read the whole thing. I'm working on something with multiplayer using an unbounded queue of command events, so I learnt a few things about that situation. If you have any posts that elaborate on the typical infrastructure events from running that in production, I'd love to read it as you obviously put a lot of effort into your blog posts.

This is entirely new infrastructure, and I don't have data yet since this is a side project.

I am biasing towards relying on a connected socket for all state management which is fair for board games (and, I do believe more generally given how connected the world is becoming).

There are tremendous problems with using WebSockets in production, but they can be overcome with a decent protocol design as you have a number of failure modes to contend with. I'm in the process of publishing a paper for a conference that will share some of the architecture of my production learnings.

Re: Second-guessing the modern web (2020)

#188

One thing I've seen happen again and again in a lot of technologies is a "framework gravity". A lot of people see this as engineers just wanting to work on "hype" technology but I think what is actually happening is a reflection of global engineering time. React is great for SPAs. Most large companies are working on honest-to-god SPAs. By extension most engineers are working on SPAs. So most tooling is created for SP…

There is a name for this kind of phenomenon - Inadequate Equilibria - why civilizational scale failures can still occur even if every actor is doing things as efficiently as possible.

Some of you might want to read the excellent book that introduced the concept - https://equilibriabook.com/

Re: Second-guessing the modern web (2020)

#189

One thing I've seen happen again and again in a lot of technologies is a "framework gravity". A lot of people see this as engineers just wanting to work on "hype" technology but I think what is actually happening is a reflection of global engineering time. React is great for SPAs. Most large companies are working on honest-to-god SPAs. By extension most engineers are working on SPAs. So most tooling is created for SP…

Yes there is a framework gravity. More directly it is Invented Here Syndrome: https://en.m.wikipedia.org/wiki/Invented_here Due to missing leadership and absent mentorship many developers are hoping tools provide the guidance they need.

This hit a nerve...

Re: Second-guessing the modern web (2020)

#190
Many of these problems are solved:

> Most bundle splitting techniques require you to load that ‘index bundle’, and then only once that JavaScript is loaded and executed does your browser know which ‘page bundle’ it needs. So you need two round-trips to start rendering.

Hopefully you're performing some server-side rendering, which should know which page is being rendered, and save the browser a round-trip by including the page bundle in the initial response.

> So the user will be using an old version of your JavaScript frontend with a new version of your API backend

You should never couple your API backend that tightly to your frontend release version. What if you find a critical bug and have to roll back? Anyone that deals with a native app also has to deal with people not installing updates.

> (regarding SSR) The first is that the page you initially render is dead

You can always make your JS render-blocking if it's really that important. Most people would rather see the content first.

> If you do SSR on any pages that are custom to the user, then you need to forward any cookies or authentication-relevant information to your API backend and make sure that you never cache the server-rendered result.

This applies to every website.

> But no option really lets a web app be careless about its data-fetching layer.

This applies to every program that has to fetch data from somewhere.

> Speaking of data fetching. It’s really important and really bizarre in React land

This is definitely true but also something React expressly considers out of scope, for better or worse. I think the reason the GraphQL clients tend to have a better story here is that a lot of the tricky things about data fetching (data normalization, deduping queries, updating related objects, etc.) are difficult or impossible without a common query schema with standardized field types, which GraphQL provides.

All in all, I think the SPA pattern has won out because it's the one pattern that lets you treat your website like an actual long-running program, instead of a series of stateless requests. People will complain about complexity and tout the zen-like purity of their Jekyll blogs, but this complexity is what allows the web, as a platform, to thrive and compete against native apps and the walled garden of app stores.

Post reply on HN