News for hackers. Stuff that matters.
Re:FrankenPHP: Modern PHP App Server by dgb23 on Thursday May 30, 2024 @07:30AM (#40522474)
You can't fully replicate JSON schemas in either language without writing logic.

In terms of just static definitions, Go has typed container types while PHP has not. That's a pretty common case for JSON. PHP is more convenient at another common case which is heterogeneous maps. Neither of those languages make me particularly happy in that regard.

It also depends on what you're doing with the JSON. If you want/need to walk through it in a single pass fashion, then Go is definitely more fitting.

Re:FrankenPHP: Modern PHP App Server by withinboredom on Friday May 31, 2024 @03:19AM (#40532302)
> Go has typed container types while PHP has not.

I suggest looking at https://github.com/Crell/Serde, if that is a requirement in PHP.

> PHP is more convenient at another common case which is heterogeneous maps.

Or arbitrary, user-defined keys...

> If you want/need to walk through it in a single pass fashion, then Go is definitely more fitting.

array_map, array_reduce, array_column is pretty good at walking through arrays very quickly, assuming you parsed the json into arrays instead of objects.

Re:FrankenPHP: Modern PHP App Server by kmwr on Monday June 03, 2024 @03:22PM (#40566495)
Go has builtin typed container types while PHP has not.