Live data from Hacker News

Write PHP Code Within Next.js Components

github.com

61–70 of 107 posts

Re: Write PHP Code Within Next.js Components

#61

It's funny, but all you see here and on Twitter are cheap shot one liners, many of these people have never even used Next.js. I find server actions combined with RSC to be incredibly useful and powerful. Easily define and call a type safe function from client to server with zero overhead. No API boilerplate, fetch, tRPC anything.. You just define a function and call it, very nice. Type safety, code completion, refact…

> You just define a function and call it, very nice.

What do you do when you change the action API (arguments / return type) and deploy? What happens with browsers still having the old code that assumes the old contract?

Re: Write PHP Code Within Next.js Components

#62

It's funny, but all you see here and on Twitter are cheap shot one liners, many of these people have never even used Next.js. I find server actions combined with RSC to be incredibly useful and powerful. Easily define and call a type safe function from client to server with zero overhead. No API boilerplate, fetch, tRPC anything.. You just define a function and call it, very nice. Type safety, code completion, refact…

> Not sure why it's being compared to PHP probably just because PHP is now recognized widely as fundamentally bad design. Its just that many people who came late to the party never really knew why, so they think to themselves, no this is actually great "no API boilerplate, fetch, tRPC anything.. You just define a function and call it, very nice.". And so the cycle continues...

First php doesn't have that ability, except for Livewire which not many people use. Second php has come a long way, is type safe now, very fast, battle tested, easy to host and a perfectly fine option for building websites with. It's why it remains today the most popular framework used to build websites with.

Re: Write PHP Code Within Next.js Components

#63
post #61

It's funny, but all you see here and on Twitter are cheap shot one liners, many of these people have never even used Next.js. I find server actions combined with RSC to be incredibly useful and powerful. Easily define and call a type safe function from client to server with zero overhead. No API boilerplate, fetch, tRPC anything.. You just define a function and call it, very nice. Type safety, code completion, refact…

> You just define a function and call it, very nice. What do you do when you change the action API (arguments / return type) and deploy? What happens with browsers still having the old code that assumes the old contract?

Pretty much the same as dealing with traditional API versioning. You can version the functions themselves, or put a version in they payload and return an error telling the user to refresh.

Re: Write PHP Code Within Next.js Components

#64

It's funny, but all you see here and on Twitter are cheap shot one liners, many of these people have never even used Next.js. I find server actions combined with RSC to be incredibly useful and powerful. Easily define and call a type safe function from client to server with zero overhead. No API boilerplate, fetch, tRPC anything.. You just define a function and call it, very nice. Type safety, code completion, refact…

> Not sure why it's being compared to PHP probably just because PHP is now recognized widely as fundamentally bad design. Its just that many people who came late to the party never really knew why, so they think to themselves, no this is actually great "no API boilerplate, fetch, tRPC anything.. You just define a function and call it, very nice.". And so the cycle continues...

I'm still yet to see something as productive as PHP for web apps, ecommerce etc.

You ask for a customised e-commerce shop with many standard features out of the box. How long will the Java or Rust engineers quote you? A year? Php? A week?

Re: Write PHP Code Within Next.js Components

#66
post #49

Earlier quoted context omitted.

Can you elaborate on why Astro is better or what type of fight with Next? Your type of post with strong opinions but none of the underlying _reasons_ are one of the reasons why JS framework wars are tiring. I'm really interested in alternatives to Next, but it's difficult to good, non-vitriolic, shop talk. We bolted Next onto the React/Python application at work for SEO stuff. There's a number of self-inflicted probl…

What direction would you prefer Vercel went in?

I don't really have a strong opinion. Vercel is a really loud voice in the React world, so I guess I'd like them to survive a post-zero interest rate policy world (many growth companies have struggled). Or at least, not push paradigms and features specific to their needs on the React world, then run low on cash, leaving those paradigms functionally unsupported and half adopted by other React libraries.

My needs that Next solved mid-2021 when I picked it: framework that can build on existing React code with strong SSR/ISR primitives + tools for bundle size control for SEO. Nice DX with hot reload was a big plus. My backend is Python and that's pretty set in stone.

Vercel seems to be very focused on solving full stack problems, with the app vs pages routing changes, RSC, server actions. It's clear they're listening to paying customers and I wouldn't tell them to stop. It's just not the problem I have.

Re: Write PHP Code Within Next.js Components

#67

Earlier quoted context omitted.

> Not sure why it's being compared to PHP probably just because PHP is now recognized widely as fundamentally bad design. Its just that many people who came late to the party never really knew why, so they think to themselves, no this is actually great "no API boilerplate, fetch, tRPC anything.. You just define a function and call it, very nice.". And so the cycle continues...

What do you think is fundamentally bad about PHP exactly? It powers a large percentage of the web and does it quite well.

I installed wp with a theme a few years ago and the box was turned into a zombie file dump. Modern php is still not there.

Re: Write PHP Code Within Next.js Components

#68
post #61

Earlier quoted context omitted.

> You just define a function and call it, very nice. What do you do when you change the action API (arguments / return type) and deploy? What happens with browsers still having the old code that assumes the old contract?

Pretty much the same as dealing with traditional API versioning. You can version the functions themselves, or put a version in they payload and return an error telling the user to refresh.

How do you version the functions? How does the server determine which function to call? Does it use the name of the function, or its source code file, or something else? If I rename the old version and call it `actionOld` while the new version is `action` will it know how to call the old one, or do I need to do the opposite (call it `actionNew`)? What if I move the old one to a different file?

Re: Write PHP Code Within Next.js Components

#69
Moving past the excellent joke.

The problem I see with Next has nothing to do with re-visiting these concepts, and almost everything to do with the examples. Flipping your mindset from “react is a framework for client side rendering” to “react is a dsl for building HTMl on the server” is a leap and it brings all this junk with it. I think thats how we get these parodies, and the “sql in a component” nonsense.

What is missing though is guidance on how to clearly separate these things. How do you do permissions, security model, clear separation of concerns, etc within nextjs in this new world? This is not new ground so the patterns should be pretty easy to describe. But thats missing and as a result, we do have people saying “no no. The process.exec call was a demo” without realizing that people are going to refer to that as a best practice.

Re: Write PHP Code Within Next.js Components

#70

Moving past the excellent joke. The problem I see with Next has nothing to do with re-visiting these concepts, and almost everything to do with the examples. Flipping your mindset from “react is a framework for client side rendering” to “react is a dsl for building HTMl on the server” is a leap and it brings all this junk with it. I think thats how we get these parodies, and the “sql in a component” nonsense. What is…

Imo I liked the dev experience with next but I'd be nervous releasing it to the public
Post reply on HN