Live data from Hacker News

Write PHP Code Within Next.js Components

github.com

81–90 of 107 posts

Re: Write PHP Code Within Next.js Components

#81
post #36

Earlier quoted context omitted.

I get what you’re saying, but you can use React without RSC just fine. Next.js might be pushing RSC, but using Vite and normal React is fine. Hell, even the pages directory still works in Next.js and it has no RSC.

I would argue that unless your need SEO there is no reason to reach for Next.js or any other react framework. The default should be vite and client only. Everything else only serves corporate interests.

What if I don’t like preloaders and content flashes?

Re: Write PHP Code Within Next.js Components

#82
As much as I like PHP and JavaScript, as the README in this repo alludes to, this is cool concept but its not a good idea to actually use this.

Some of the worst code I've had to maintain are weird mixtures of PHP/JS all in the one view file including where you have PHP generating JS/interpolating in variables.

PHP as a templating language alone is actually pretty decent, but you need to keep the JavaScript separate to keep things clean.

Re: Write PHP Code Within Next.js Components

#83

Ironically, these days PHP has its act together - look at Laravel - better than most of the JS ecosystem does. I don’t mind JS as a core language. Web Browser APIs are pretty awesome (with a few notable exceptions like IndexedDB). But the Node and SPA ecosystem is, speaking objectively, a dumpster fire. We parody “enterprise” software, where vendors convince large companies to invest in over-engineered garbage. Node,…

To me JS proves that in the right scenario, the technical quality of the language doesn’t matter at all.

Re: Write PHP Code Within Next.js Components

#84
post #60
post #45

Earlier quoted context omitted.

Next has always been inspired by PHP. in his keynote Rauchg even spent like a moment of silence dedicated to the PHP Lambo, completely out of context. it must have been confusing to others not in on the joke but for those of us in the audience it was great

Isn't PHP Laravel author owner of a Lambo? I wonder what the plate reads.

LARAVEL

Re: Write PHP Code Within Next.js Components

#85

As much as I like PHP and JavaScript, as the README in this repo alludes to, this is cool concept but its not a good idea to actually use this. Some of the worst code I've had to maintain are weird mixtures of PHP/JS all in the one view file including where you have PHP generating JS/interpolating in variables. PHP as a templating language alone is actually pretty decent, but you need to keep the JavaScript separate…

I'm not sure if it still has it but the Wordpress login file had some mix of JS and PHP a few years back.

Re: Write PHP Code Within Next.js Components

#86

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…

> “react is a dsl for building HTMl on the server”

Whats quite amusing to me in the context of this joke, is back in the late 2010s we actually used React this way in PHP via the V8JS PHP extension lol

In production, too.

Re: Write PHP Code Within Next.js Components

#87

Earlier quoted context omitted.

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?

I've been working exclusively in javascript/node since 2015 and nothing in the JS ecosystem has ever felt as productive as rails or django or laravel. Maybe it's rose tinted glasses when working on those select few projects but compared to the node ecosystem I'm bashing my head against the wall updating libraries that provide no migration docs seeing alternative solutions saying "we don't support X, sorry." It's just…

This has been exactly my experience as well. There were things I really liked about JavaScript and node, but in the end the lack of framework and the ridiculously fast rate of change that can bit rot a code base in six months, was enough to drive me back.

I found elixir and Phoenix to be exactly what I needed. I use it exclusively now, except for legacy apps. Phoenix is the full framework, comprehensive in what you need. Compared to rails, I like it a bit better. It fixed some of the things I didn't like about rails, such as the extreme levels of magic. Phoenix is a lot more explicit. Performance is incredible, and you get some amazing features like live view, and many others just from being on the beam VM. Definitely worth a look if you're feeling like this.

Dang I didn't mean to turn this into a sales pitch for Phoenix! NextJS has also been quite enjoyable for me. I use it for static sites, or really anything that doesn't require a database. The ability to SSG everything and just serve it with nginx is a killer feature in my opinion.

Re: Write PHP Code Within Next.js Components

#88
post #16

I think part of what makes these recent gags so funny to me is that it illustrates how perilous mixing RSC with client code feels in practice. Worrying about teammates accidentally exposing environment variables was already bad enough. Debugging is now even more troublesome, and for what? So we can use some XML-like syntax everywhere? React serves a purpose but this doesn't feel like it. All these directives, the loo…

I take it you don't write HTML because you don't want to use an "XML-like syntax"?

Re: Write PHP Code Within Next.js Components

#89

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.

Lack of native async support for one

Re: Write PHP Code Within Next.js Components

#90

Earlier quoted context omitted.

Who would win? A literal trillion dollar ecosystem ... vs. ... le edgy joke.

All these haters of Javascript, you'd think no one actually uses it.

Javascript is widely used for frontend development because it's the only choice, not because it's a well-designed language that developers love.
Post reply on HN