does PHP work as a compiler target? (error handling, debugging, reflection) #72
mindplay-dk
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I love everything you're trying to do with this language - give us all the nice things that everyone except the PHP core team wants. 🙃
One of the first questions on my mind though is... does PHP actually work as a compilation target?
I mean, practically any language "works" as a compilation target, but what about error handling and debugging?
There have been a few attempts in the past at targeting PHP with a "better" language (though I do believe it's the first time I've seen anyone attempting an actual superset) but it never seems to pan out.
I've looked into it myself in the past, and have written things like a template language, but I could never see a way to get something like source maps to work for error messages - that is, we don't want to see "error in generated_file.php line 123", we would expect to see error messages remapped to the source language.
The same goes for debugging - I don't know how you could make something like this work with XDebug? But maybe you have something else in mind.
It's been many years since I looked into it and obviously PHP has changed, so maybe those things are possible now.
I also wonder how you would support reflection? Inevitably, third-party libraries that use reflection would be reflecting on the generated PHP code - which isn't a problem in itself, since those libraries aren't expecting to be able to reflect on e.g. generic types. But I'm assuming you would need either an extended or a replacement reflection facility to support those things?
One of the things I'm missing worse than anything is typed arrays and reflection for that - building even the most basic controller request mapping/injection facility in PHP right requires a monumental amount of code to parse and cache PHP-DOC blocks, etc... an obscene amount of complexity for something that most newer languages can do with a few lines of code, with proper IDE support, and so on.
I don't want to bombard you with questions at this point, but those are the biggest road blocks in my mind - I was just curious how (or whether) you plan to address those?
I'm pretty excited that someone is finally brave enough to take a stab at this, but there's also a part of me that wonders why we don't just take a much simpler language which is already bootstrapped for most of the qualities we long for in PHP, and just bring the PHP features we like into that? There are plenty of things I like about PHP, and it's one of the most productive languages for me, but it's also just old, with a lot of syntax and feature controversies, and a superset will inherit a lot of that cruft. 😅
Beta Was this translation helpful? Give feedback.
All reactions