Re: Self Modifying Code
- Posted by ghaberek (admin) May 27, 2019
- 1398 views
It seems like so much of the World Wide Web is built with php, using embedded php code in html documents. For example:
Just because PHP does it, and just because PHP is popular, does not make this approach good. See: Appeal to Popularity.
This is my biggest gripe with PHP. Having the ability to intermix backend code with frontend markup is very bad and very sloppy.
Designing an application around proper separation of concerns leads to a cleaner design that's (if done well) easier to maintain.
BUT, why could we not do something similar using Euphoria?
What you're looking for already exists. It's running this website right now. Check out the euweb project, which is built with Jeremy's webclay. Specifically etml.ex, the HTML/code preprocessor.
I wrote a preprocessor using an example from the OpenEuphoria site, to extract the Euphoria code and execute it. At this time, it does not return an html document with the embedded Euphoria code replaced with the results of running the preprocessor, although I imagine that is possible. I thought that Self Modifying code might be helpful. Here is the preprocessor:
I firmly believe that self-modifying code is a very bad idea. I think that if you've reach this idea as a solution, you need to take a step back and re-examine your approach. What exactly is the problem you're trying to solve?
I'm planning to replace euweb/webclay with a new framework: Euphoria MVC. This new framework provides cleaner separation of the parts of your web application. I think you'll like it. Please check it out.
At the very least, you may be interested in the template parser. It supports basic Euphoria code structures like if and for. There's also automatic dot notation for map keys, which makes for very clean code markup? template logic.
-Greg