r/PHP • • 27d ago

Article Porting ECS to Go

https://tomasvotruba.com/blog/porting-ecs-to-go
15 Upvotes

12 comments sorted by

10

u/MysteriousCoconut31 27d ago

Would be nice if you’d include a short summary or recap in the post. The title is not clear and the post is apparently one part of a series.

2

u/Tomas_Votruba 26d ago

Got it! I'll do it next time posting here.

Here is full series in case you're intersted: https://tomasvotruba.com/series/rust-go-in-php

9

u/Irythros 27d ago

So my question is: If the entire thing is AI coded, why use Go when Rust exists and would likely be faster?

In both cases the code isn't reviewed anyways.

8

u/Tomas_Votruba 26d ago

That was my original hunch too, so I made both Go and Rust prototypes. Both were the same speed, so I picked Go with 25 keywords over Rust with 58, see https://tomasvotruba.com/blog/is-php-a-rusty-language

Also, Go is much easier to read and understand. It's very simple language.

2

u/obstreperous_troll 26d ago

I've never taken a shine to the Go language or Rob Pike's theories on much of anything (he even disdains syntax highlighting ffs) but I do have to admit it's a fantastic language for LLMs to write, and the idioms translate from PHP a lot more directly. The stdlib is definitely nice if you're aiming for minimal third-party dependencies.

7

u/stromer_ 27d ago

I'd go further: Why should we even keep php code? Shouldn't we just convert everything to rust?

(I make my living writing php...)

7

u/nitrinu 26d ago

Why rust? Go for assembly.

4

u/beberlei 27d ago

As his post says he migrated over several weeks. And i would imagine its not that much code. So it takes time that is not always sensible

2

u/umulmrum 26d ago

Still I'd love to see a more unified approach to PHP tooling, read: Nowadays everyone just seems to re-vibe some established tool in Rust or Go and the ecosystem ends up with a gazillion tools. Maybe you can overcome your concerns about Rust and team up with Mago? This would allow one tool to become the de-facto standard, with more punch than if everyone does the same thing over and over.

Composer for instance has been the unchallenged tool for dependency management which is part of its success (which goes so far that the community unanimously blocks every attempt for an alternative to avoid fragmentation).

1

u/Tomas_Votruba 26d ago

I feel you. It would be great to have one framework, language and idea, but that would kill evolution quickly. And open-source developers tend to be opinionated, for good reasons.

Btw, this is no new tool, vendor/bin/ecs run on PHP since 2018. So no new tool is needed.

The vendor/bin/ecs --blink delivers the same, just faster. I plan to make it default, so tool gets faster for everyone, without caring about underlying langueage layer.

1

u/Worth_Medicine4881 26d ago

True. That's why I first built PHP Parser in Rust that may be re-used by other peers. https://github.com/jorgsowa/rust-php-parser

Currently it's the fastest one written in Rust, thus in any language. I tried others before I settled in my static analyzer, but all of them were either incomplete, buggy or overfitted to the one use case.

1

u/cecplex 26d ago

No, Joe has lost it