Live data from Hacker News

Things I wish I knew before moving 50K lines of code to React Server Components

mux.com

161–170 of 540 posts

Re: Things I wish I knew before moving 50K lines of code to React Server Components

#161

Earlier quoted context omitted.

It's a limiting, but saner approach for any larger app/company. It's the same logic why in OOP you have private members/methods. As owner/maintainer of some component you want keep stable public api and be able to iterate on the internals. Letting any client willy-nilly directly fetch from database is unsecure and unmaintainable in future.

> Letting any client willy-nilly directly fetch from database is unsecure and unmaintainable in future. Surely you'd just want to be calling the internal API that the other endpoint is using behind the HTTP endpoint? If you're in the same process (big if, but nothing to suggest they aren't), there's not a lot of sense serialising out to a socket and back again rather than making a function call.

Sure, calling internal API is sensible. I am not saying it needs to be public API. But you probably can't avoid some serialization (be it REST, GQL, GRPC), the service that owns the data can be different than the one serving the html.

I am not saying everybody needs to do microservices but my experience with monolith is bad. You want at least "some" services and the html-serving service shouldn't usually own the data. User data belongs to user service, report/analytics data to analytics service etc.

Just from the security point of view, the stuff facing internet should have minimum rights to read/write anything. Definitely not direct function-calling or db access.

Re: Things I wish I knew before moving 50K lines of code to React Server Components

#162
post #31

I guess you use what you are familiar with, but using react for doc site instead of using some off the shelf static site generator/cms with caching seems like wasted effort. More fun from dev point of view with react no doubt.

It is statically generated. The reason to use React is so you have one language across the front-end rather than having some people using React on one site, and then people using Gatsby/Hugo for something else. Next.JS can do the same thing as Gatsby/Hugo but has more features and is in React.

Re: Things I wish I knew before moving 50K lines of code to React Server Components

#163
post #89
post #31

I guess you use what you are familiar with, but using react for doc site instead of using some off the shelf static site generator/cms with caching seems like wasted effort. More fun from dev point of view with react no doubt.

Great doc sites are dynamic in heaps of little ways. Stripe started the trend of showing you code snippets with api keys from your account to test with. Frontend docs sites almost always include runnable examples, that you can play with inside the docs.

> Stripe started the trend of showing you code snippets with api keys from your account to test with.

Pretty sure Google started / had this years earlier (before Stripe even existed?). And there may have been others earlier as well.

Re: Things I wish I knew before moving 50K lines of code to React Server Components

#164

I get the impression that React is trying hard to catch up with the more modern, easier, faster and cheaper alternatives. But instead of fixing the root problems (rerendering and often required memoization, leaky abstractions) and make React easier, it becomes more complex. If the end result was great, I would understand all the effort. But it isn't. React is even slower in real world than the benchmarks show. Next i…

They can't. The ecosystem has too many dependencies that break at this point. Consider that Target.com, Walmart.com, Microsoft Teams, and untold masses of sites are React. The huge component ecosystem. Entire companies built around it. The core concept is broken§, but fixing it means possibly breaking everything else. If you're going to break everything, might as well use something else. All we can do is truck along…

Could you explain how the opt out/opt in works? Im a bit confused

Re: Things I wish I knew before moving 50K lines of code to React Server Components

#165
post #157

Earlier quoted context omitted.

> Are there a lot of server side template languages that can’t do this? Did I say there weren't a lot of template languages that can do this? A dead give-away that this subject isn't as "straight-forward" as you think is that, at one sentence in, you've already misidentified the conversation taking place. This isn't about can vs can't, but about the right tool for the job. What template language would you personally…

classic ASP

Maintaining VBScript sucked 100x worse than TypeScript.

How would you approach SSG with Classic ASP?

Re: Things I wish I knew before moving 50K lines of code to React Server Components

#166

I think i am getting old. These frameworks are so big and complex. For a simple web hello world you need a huge build and compile pipeline. And now its extended with serverside components. I really wonder what the overhead is. How many of layers of frontend and backend framework code is executed to get the hello world example running. I retreat back to my simple 10kb component framework in which i need only f5 to reb…

F5ing to refresh is a heavier workflow than the hot-reload/refresh you get with every modern web framework.

For sure. Ever had to debug a bug deep inside of a webpage's code that relied on 5-10 preconditions to get it to appear? Without HMR, you're spending a lot of time F5ing and navigating to reproduce/fix it.

Re: Things I wish I knew before moving 50K lines of code to React Server Components

#167
post #55

What I love about this is how PHP and JavaScript had basically the same syntax (minus a $ symbol here or a var keyword there), and then NodeJS was like, but we want to run JS on the server! And now, 15 years later JavaScript has finally caught up and it’s basically the same as PHP, but with more acronyms and a steeper learning curve (to be fair, streaming data from server to client components using suspense is cool).…

Well, PHP has no client-side rendering, so it's a weird comparison

OP said PHP + Javascript. JS is used for client side rendering. Nowhere was implied that PHP does that.

Re: Things I wish I knew before moving 50K lines of code to React Server Components

#168
post #55

What I love about this is how PHP and JavaScript had basically the same syntax (minus a $ symbol here or a var keyword there), and then NodeJS was like, but we want to run JS on the server! And now, 15 years later JavaScript has finally caught up and it’s basically the same as PHP, but with more acronyms and a steeper learning curve (to be fair, streaming data from server to client components using suspense is cool).…

Well, PHP has no client-side rendering, so it's a weird comparison

[deleted]

Re: Things I wish I knew before moving 50K lines of code to React Server Components

#169
post #87

Earlier quoted context omitted.

Isn’t everything a new take on an old idea? And that’s what makes them novel. As Sagan said, “If you want to bake a cake from scratch, you must first invent the universe.” We’re remixing everything all the time, nothing is completely new and that’s fine. We still move forward.

I see what you're saying and in a broader sense that's true. More specifically though — in the world of web development — some ideas are actually [as good as] original. When CSR/SPA became well established as an approach in web development, there wasn't a time before it when that approach had been common. The approach to web development described in the article however is essentially the same approach that web develo…

Thin vs thick client is a much older debate, but you have to go back to the times before the Web ;-)
Post reply on HN