4 ms·
As a long time PHP developer, it never fails to amuse (amaze?) me the lengths people go to in order to get the things the browser will give you for free.
by donatj 1y ago
As a long time PHP developer, it never fails to amuse (amaze?) me the lengths people go to in order to get the things the browser will give you for free.
- jiggawatts 1y agoThe most "special" code that I regularly come across is when a developer takes a JPG in blob storage -- already a public HTTPS URL -- then serves that in a "Web API" that converts it to base-64 encoded bytes inside JSON, sends it to client JavaScript, decodes it, and feeds it to an image in code. Invariably, it's done with full buffering of the blob bytes in memory on both server and client, no streaming. Bonus points are awarded for the use of TypeScript, compression (of already compressed JPGs, of course), and extensive unit and integration tests to try and iron out the bugs.
- asa400 1y agoThis is truly beautiful. Art, even.
- cnnlive789 1y agophp is great but I’m surprised by how people are not discussing htmx. It’s a chance to start all over yet again! Come on- we’re all up for that, we do it every few months!
- recursivedoubts 1y agosmdh!
- chuckadams 1y agoThe browser gives you a full-blown programming language with a rich API, but it seems a lot of people avoid that in favor of smushing together a static view on the server side with little more than string interpolation.
- endemic 1y agoI'd prefer not to download 2MB of JavaScript and feel my phone get uncomfortably hot just to fill out your online form.
- Xss3 1y agoThat's just bad coding no matter the framework. Too many devs pull too many packages in....Saving themselves minutes at the expense of all the users waiting longer. So much compute and co2 is wasted on it.
- const_cast 1y agoHTML templating isn't just string interpolation, Its a whole templating engine. It's not like JSX, which is fake templating. Server side frameworks have real templating. Plus, you have to convert data to HTML somewhere. If you're using react you do this typically on the front end. You traverse and read JSON and convert it to HTML... Just like you would in PHP. Just, on the front end.
- chuckadams 1y ago> You traverse and read JSON and convert it to HTML It gets converted to DOM nodes, and there is zero HTML source involved when using a component toolkit. Whereas in PHP, you can do things like this and it won't make a peep: $foo = '<h1 <um & hi=="bla""foo"""arglebargle>>>>>'; ?><?= $foo ?> Other template engines like twig or blade will at least escape it by default, but of course have a syntax for interpolating it raw, otherwise they wouldn't be very useful as template engines. That's the sort of templating I'm talking about. JSX is a tree builder syntax that doesn't even produce strings at all on the client side, and when rendered in SSR, produces HTML source that's correct by construction (syntactically anyway). You can call that "fake templating", I'd say it's not templating at all. Obviously there are other server-side template engines out there that are also correct in this fashion (HAML comes to mind), but I'm not referring to those, and neither is most of the "server-side is all you ever need" crowd.
- 1y ago
- mardifoufs 1y agoLike a super rich and very well tested front end client, that doesn't need a server to template everything for it?