TL;DR: Third paragraph onwards.
Hello everyone,
I have recently found a job where they use PHP. They fortunately use the newest versions of it, but unfortunately they use it in a very old-school way - the templates are just HTML mixed with PHP code. I find it really painful working with code like that, so I have started looking for a way to improve it going forward.
Lately, I have been using React in my free time and I really enjoy how function components and the JSX syntax work. My first attempt at improvement was just cutting up the template I’m working on into separate functions, but I have quickly found the limitations of this approach - many of the “function components” require unwieldy arrays of parameters (which I need to manually document for each function) and passing in child components is extremely clunky too.
By chance, I was reminded of Haxe by a video and I realised that since it can compile into PHP and has metaprogramming, maybe it could be used to create a JSX-like DSL that would compile into PHP function calls similar to React.createElement() (which is what JSX is under the hood).
Well, in the previous paragraph I have used a lot of big words and short acronyms, but I am actually a junior programmer at best, and I don’t have any experience with metaprogramming, I have merely read about it. I would appreciate if someone could tell me if my thoughts have merit or if I’m completely off the mark, whether or not Haxe would be a good language to implement it, and maybe even point me towards some resources I could use.
Thanks!