HNHacker News
TopNewBestAskShowJobs

hasanhaja

138 karma · joined February 21, 2021

Software Engineer @ Cancer Research UK • Passionate about the web • All views are my own.

Mastodon: @hasanhaja@fosstodon.org GitHub: https://github.com/hasanhaja/ Website: https://www.hasanhaja.com/

submissionscomments
hasanhaja··on We keep reinventing CSS, but styling was never the problem
How's your experience maintaining styles written in this manner?

My experience has been increased cognitive load when I come back to tailwind styles after a long time, when compared to dealing with handwritten CSS selectors and classes

hasanhaja··on It's time for modern CSS to kill the SPA
No, but doing the rendering through JavaScript in userland will be slower than letting the browser handle it
hasanhaja··on It's time for modern CSS to kill the SPA
Why does this have to be the baseline architecture when you can render the HTML on the server with the template and data? Why send the data and the JavaScript to parse that data and transform it into HTML in a users browser when you can do it on the server?

For requests after the first, you can still continue to send the rendered HTML to be placed into the document. Here's an example using HTMX: https://htmx.org/examples/lazy-load/

hasanhaja··on It's time for modern CSS to kill the SPA
But this is exactly the point of the article. That'd be like if I needed to build a car, I started with a rocket blueprint in case I also need to go to space in the future.

The cost of speculating a highly interactive site that users will want to interact with is a suboptimal baseline experience until you get there. Provided you get there without losing users, it'll still be a subset of your audience that use your thing in a way that truly offsets all of these costs. If that works for your product/business, then awesome! But if these costs are too high and will hurt your product, then you need to be a lot more deliberate about how you engineer it.

I typically approach the problem first and see what tools work best to solve the problem, rather than work backwards from my preferred set of tools.

> Once you've dug that hole, you either have to live with it, or face a painful rewrite later.

Based on the tools you mentioned familiarity with, wouldn't something like Astro be a happy middle ground? You start as an MPA by default and only add complexity to parts (entire routes or parts of a page) of the application that require it? Also, this hole goes both ways. If you've built your site as a SPA, and you realise that your product just needs to be HTML to stay competitive, it's a painful road to unpick the layers of abstraction you've bought if you don't wanna rewrite it.

> dynamic features, anything from basic showing / hiding of content, list / configuration-based rendering, or requesting data

What would a highly dynamic feature be in your opinion and how does a SPA framework help you? All of the examples mentioned here, in my opinion, are fantastic candidates for server side templating and progressive enhancement. I don't need see the need for the SPA architecture here.

> mobile devices in low-bandwidth areas

Curious to know what kind of devices are present in your area? The implications of larger applications is both network and CPU [1], so if you live in a relatively wealthy area (say over 75% of users had iPhones) you'd notice the negative effects of too much JS less. If you're in the public sector or building for the public, then you can't get away with the excuse that people on slow devices and networks aren't your target audience; you need to meet everyone where they're at. A HTML-first architecture is a better and more inclusive baseline for all.

[1] https://infrequently.org/2024/01/performance-inequality-gap-...

hasanhaja··on It's time for modern CSS to kill the SPA
Are we aligned with the claims in the article that a SPA architecture is not a suitable baseline architecture for content-focused sites with shallow sessions (low number of interactions)?
hasanhaja··on It's time for modern CSS to kill the SPA
How does something like React help with any of the trickier UX problems you're describing?
hasanhaja··on Astro is a return to the fundamentals of the web
But if you don't know the underlying platform, how can you be sure that your framework is high level enough or that it can do everything that's possible on the platform? You either have a framework with escape hatches (that'll require you to drop down to the bad stuff) or you have to wait until the framework catches up to the platform. Actually now that I think about it, React would fall in both camps.
hasanhaja··on Astro is a return to the fundamentals of the web
But don't you need to need to understand the platform you're building on, warts and all?

How else can you fully grasp what's possible on that platform and the costs of different abstractions?

hasanhaja··on Astro is a return to the fundamentals of the web
Like what specifically? And why do you think Astro is not a good fit for it?
hasanhaja··on Astro is a return to the fundamentals of the web
There are a lot of moving parts when building an application and the abstractions that Next.js provides doesn't cover the same stuff when compared to frameworks like Ruby on Rails, Django and Laravel. The narrow band of problems Next.js solves for you are things like data fetching, routing, bundling assets and rendering interactive UI. It leaves things like auth, interacting with a database, logging, mailing, crons, queues, etc up to you to build yourself or integrate with 3rd party services. When you work with one of those frameworks, they pretty much solve all of those problems for you and you don't have to leave the framework often to get things done.

This is fine generally because you have the choice to pick the right tool for the job, but in the context of "a single, cohesive unit" you can only get that with Next.js if you all that you care about are those specific abstractions and want your backend and frontend to be in the same language. Even then you run into this awkwardness where you have to really think about where your JavaScript is running because it all looks the same. This might be a personal shortcoming, but that definitely broken the illusion of cohesion for me.

> The static parts of the page are never client-side rendered, whereas before RSC they were.

Didn't the hydration performance issues start when we started doing the contemporary SSR method of isomorphic javascript? I think Islands are great and it's a huge improvement to how we started doing SSR with things like Next.js Pages Router. But that's not truly revolutionary industry wide because we've been able to do progressive enhancement long before contemporary frameworks caught up. The thing I'm clarifying here is the "before RSC" only refers to what was once possible with frameworks like Next.js and not what was possible; you could always template some HTML on the server and progressively enhance it with JavaScript.

hasanhaja··on Astro is a return to the fundamentals of the web
Yeah, this is my gut-feeling too! Because the alternative for "complex" being discussed is Next.js, but that doesn't really help you with "complex" applications, and you still have to bootstrap a lot of infrastructure yourself (with dependencies, or by yourself).
hasanhaja··on Astro is a return to the fundamentals of the web
What do you mean by complex?
hasanhaja··on Astro is a return to the fundamentals of the web
What about DX in terms of template execution speed? There are many implementations of template fragments on various platforms like Go and Rust [1], which might arguably perform better than their JavaScript counterparts. Wouldn't quicker execution give you a faster feedback loop when developing, and also give you a faster UX?

[1] https://htmx.org/essays/template-fragments/#known-template-f...

hasanhaja··on Astro is a return to the fundamentals of the web
Do you have an intuition of when something becomes hefty and complicated, and would require a full stack solution like Next.js?
hasanhaja··on Astro is a return to the fundamentals of the web
> there wasn’t a developer experience by which you could build a website or web app (or both) as a single, cohesive unit, covering both front-end and back-end

How much of the frontend and how much of the backend are we talking about? Contemporary JavaScript frameworks only cover a narrow band of the problem, and still require you to bootstrap the rest of the infrastructure on either side of the stack to have something substantial (e.g., more than just a personal blog with all of the content living inside of the repo as .md files).

> while avoiding the hydration performance hit

How are we solving that today with Islands or RSCs?

hasanhaja··on Ask HN: What are you working on? (February 2025)
Been wanting to learn browser APIs like Service Workers and IndexedDB in depth, and HTMX, so started building a Todo App: https://github.com/hasanhaja/tasks-app

It's meant to work entirely offline and the service worker acts as the backend for the application.

hasanhaja··on We switched from Next.js to Astro (and why it might interest you)
You can just sprinkle in some <script> tags and not have to rely on UI frameworks. I appreciate that Astro let's you do this rather than invent it's own way of doing things.
hasanhaja··on If not React, then what?
How do you think it compares to Vaadin?
hasanhaja··on If not React, then what?
> That's what I mean - the author gives no prescription.

Are you expecting a prescription? If so, what could that look like? Specific technologies? When specific technologies are appropriate?

> Most teams do not have the privilege of being able to "ground their product decisions appropriately". Most teams - at least those in small to mid-size startups - will start out building A, route through A' and A'' and end up building B once they land on PMF.

I don't quite understand this. A bakeoff is meant to give you space to figure out what technologies are appropriate for the service you're building for your users and taking into consideration what your developers like. It's a collection of proof-of-concepts so it's a quick and lean way to get data on what's more likely to succeed for you. I can accept that the technology doesn't make a product, so focusing PMF is important, but you also don't want to pick something complex that you can't afford to manage as you scale.

The worst thing I see happening is you reach PMF and need to continuing scaling, but you hit a high complexity wall that you can't move past till you manage it. All that unnecessary complexity you took on and didn't invest your already limited resources is now tech debt that's oppressing your forward momentum. Bakeoffs can steer you towards the simplest tool you need to deliver your product so that it can stay out of your way so you can focus on iterating and developing your product.

> The rest of us will use React, which is roughly 80% as good as the optimal solution.

How are you measuring this? A lot of the evidence for using a technology and running with it without managing the complexity turns out badly (see The Reckoning series by Alex). And React is a high complexity tool that requires a lot of continued management investment.

The thing that appeals to me about doing bakeoffs to find the simplest thing for my product is not that it'll be the most optimal; it'll be the cheapest to maintain. The less complexity you have, the less you have to invest in managing it.

> I just don't think many of us are Google or Facebook.

I agree. That's why I think it's best to pick the simplest tools we can afford to manage so we can get on with building our products. Facebook or Bluesky or Airbnb can afford to build their products many times from scratch and they can pay to maintain whatever complexity they take on.

hasanhaja··on If not React, then what?
Why wouldn't simple HTML be a great starting point for simpler sites? What's it missing that React solves, in your opinion?
hasanhaja··on If not React, then what?
I don't think so. You can still generate a significant amount of your static HTML at build before pushing that to a CDN, and load dynamic content using JS; JAM Stack.
hasanhaja··on If not React, then what?
> though once you master it, it can be pretty efficient.

Would it be fair to say in which case that React shouldn't be a tool teams reach for unless they have people who have mastery of it or can pay for it?

> user won't be able to tell the difference.

I think the user can:

https://infrequently.org/2024/08/object-lesson/

hasanhaja··on If not React, then what?
https://infrequently.org/2024/11/if-not-react-then-what/#%22...
hasanhaja··on If not React, then what?
> and tech requires Javascript to even barely function: see his entire work on web components.

I'm confused by this characterization of web components. While they can minimally work without JS now (i.e., declarative shadow DOM), the whole premise builds atop of how the web and the browser works, and that is progressive enhancement. Your browser starts showing you the content before all of the content has finished downloading, and as it finishes, it progressively enhances the content of the page. Web components is a part of that story.

Why do you want web components to work without JS? Do you also put the same constraints on frameworks?

hasanhaja··on If not React, then what?
But most people don't use it for the only thing it does well and pick appropriate approaches for the other parts; they use it for everything and this has transpired into the reinventing of browser mechanisms like CSS in user land. This is the real problem. Not the tool "React" (or others like it) but the cult that vehemently denies their bets were wrong and doesn't take responsibility for the real damage it's caused.
hasanhaja··on If not React, then what?
How are you getting to O(n)? Is that in terms of the logic you need to read and keep in your mind? Or is it the actual computational complexity?
hasanhaja··on If not React, then what?
Yes, that's the one! Thank you for linking it.
hasanhaja··on If not React, then what?
Why do you think bad developers or teams without sufficient budget may produce bad experiences when using React? What should those teams be caring about that React doesn't solve for them?
hasanhaja··on If not React, then what?
I urge you to read Alex's Reckoning series.

> performance concerns in the real world are typically measured in, at worst, hundreds of milliseconds.

I think outside of the privilege bubble where a significant percentage of the world is in, these concerns are measured in the tens of seconds.

> it doesn’t create issues visible to my users

What do your users look like? What kind of devices are they on? Is it mostly mobile or desktop? Are they mostly accessing your service on cellular networks or not? Based on that, what does your INP look like? IMO you'll see the impact of React's legacy synthetic event system by looking at your INP because it's reinventing in userland what the platform already does well. This impact on INP is amplified on mobile and moreso on low-end mobile. See CRUX data visualised by desktop or mobile below:

https://infrequently.org/2022/12/performance-baseline-2023/#...

> Finally, the author doesn’t actually give a prescription as to what to use instead of React.

I think he does and that's a big part of this article. It's almost literally everything from the "OK, But What, Then?" section. The TLDR is there isn't a one-size-fits-all.

hasanhaja··on If not React, then what?
> Building a web application with a UI in a professional context without a frontend build is borderline malpractice.

Why do you think that? What problem is a build tool solving for you that without it you think you're being irresponsible for not doing it by hand?

← PreviousPage 2 of 3Next →