←back to thread

133 points avan1 | 2 comments | | HN request time: 0s | source
Show context
colesantiago ◴[] No.45077666[source]
I bit the bullet rewriting my app from PHP to Go and it paid off for my company, we're talking 20K lines of PHP code, reduced to 4K lines of Go and with the added efficiency gains with it.

I think some orgs just need to take the jump and plan a rewrite, add tests (easier with Go) and just do this if they are a PHP shop, I would say it's worth it.

Instead of blending Rust/PHP or Go together and having an unmaintainable mess of a codebase.

replies(6): >>45077715 #>>45077882 #>>45077891 #>>45078407 #>>45080182 #>>45081315 #
1. tayo42 ◴[] No.45077891[source]
Surprised you made it more compact and not have it turn into 40k lines of if err! = nil

Ive done do rewrites of stuff in python and it gets really verbose, plus dependency injection patterns for testing.

replies(1): >>45078490 #
2. benjiro ◴[] No.45078490[source]
A ton of stuff in PHP is mostly templating + DB calls for a lot of websites.

If you combine Go + Templ for instance, your "if err" are mostly on the DB calls. What you needed to check in PHP anyway.

Yes, the if err != nil is extreme frustration when your doing for instance, type conversion. But if your already doing this with reflection in your DB calls (by casting to the correct types in your struct), that saves a ton.

Same with getting external data, casting it directly to structs and if something is wrong, its a single "if err".

And if your just doing PHP style programming in Go, well, _, ignoring errors like PHP does and you can panic/recover to make Go act as badly as PHP, to save on the "if err". ;-)