Hacker News new | ask | show | jobs
by kevincox 1621 days ago
If I understand this is a fairly straightforward source-to-source PHP-to-Javascript compiler. It is so simple that when complied to Javascript it uses Javascript semantics!

If a PHP look is all that matters I guess it is useful, however the semantic difference between the two languages would be both a pain to work with an a footgun. You are essentially writing two languages at once and you will need lots of diligent testing to ensure that the two behave the same if you ever want to run the same code on the client and server. From my pessimistic viewpoint it looks like using the same code on client and server is not going to work with this approach.

If I was writing this I would have tried to make a much more faithful implementation of PHP. Obviously you can't directly connect to your database from the browser but I would try to make the code behave identically (within the supported features). This would likely result in slower code on the client but at least it would be predictable.

1 comments

Well, your point is valid. You do need a lot of testing. A lot of your concerns are mentioned in the docs. The point is, whatever is possible to do in the browser you write in your component. Need something from the DB, etc. - you use HttpClient to talk to the server. Faithful implementation - there are Livewire, Yoyo dev, etc. They run PHP on the server only. Your feedback is highly important for me, thank you This helps me to improve my solution and provide the best quality