Hello everyone,
I have a problem... I'm not smart enough to write the code to solve a problem I have, and I'm hoping that by writing this essay, maybe I will be able to connect with someone who is smart enough, and who can see why I want to solve the problem in the first place.
So let me tell you a little story.
When I first started my journey into the world of perl, I had no clue about well... er... anything really! My first scripts were very "C".
I carried on like that for a long time... working tangentially to the mainstream world of perl. CPAN was unknown to me, DBIx::Class, catalyst... these were not terms I was at all familiar with.
As a result, and prior to my enlightenment, I trod a certain path which took me to an unknown code place, a place I cannot find anything similar to at all.
I wrote my own templating syntax... but it's more than that, much more.
I fell in love with the syntax I produced, it was neat, tidy and oh so easy to construct complex systems with. But no one else knows about it, no one else can help with my problem.
My very best efforts at making an efficient system from it result in page render times of around 0.03 to 0.12 seconds on a 1.6ghz celeron processor.... not fast enough!
But I cannot look away from what I have found... the simplicity... the elegance of it... this is no ordinary templating markup language, its unique and special and I really want to bring it to the world....
But I am not smart enough to make to make it as efficient as it should be, my best efforts over several years have resulted in a regex-ing eval-ing slow lumbering monster trying desperately to be a beautiful flower.
So I need help. I know I should just use catalyst and DBIx class... I know I would be doing my career a huge favour by throwing in the towel and joining the herd.
But I can't.
Not because I'm not capable of writing standardised code, but because I cannot ignore what I found out there in the lonely wilderness of standards ignorance.
So here I am going to lay bare the syntax model I found, and by doing so I hope maybe, someone out there will just for the craic, have a look at it, and maybe glimpse something of what I see in it, and why I struggle onwards with it. I'm hoping that just maybe someone will see that I'm not just being stubborn, and that there is something about it that is worth playing with, worth exploring, worth coding with superior insight and intelligence than I can bring to the problem... because it's been a long time now, and I have worked and worked at it alone, but I am running out of ideas, insight and IQ points.
Ok...
<say>hello world</say>
>hello world
(db mode="mask")
<query>
(use)queries/someSQLquery(/use)
</query>
<mask>
<d>someColName</d><br>
[link to="someURL"]<d>someOtherColName</d>[/link]
</mask>
(/db)
So what is going on here? what is with the extra tag delimiter types... is this garbage?
I understand that many of the readers will already be looking elsewhere, dis-interested, not seeing through the difficulty I have in expressing why it is that I am even talking about this... that's fine, your still here.. let me explain further, maybe you will read on and conclude that it was a waste of time, if so I am sorry, but then maybe you will think hold on... I see what this nutcase is on about, ahhhh... that's cool...
I know from experience of showing my working parser to others that when they see what it does they like it... I just don't know how to get it across the dynamic nature of the thing in static text.
the syntax is made up of tags which can be used in a seemlinly endless number of combinations which all arise from a very simple set of rules.
rule 1 : tags are computed from the innermost towards the outermost.
<a><b><c>d</c></b></a>
is computed as c,b,a where the data "d" is handed to the expression c, which then computes and its result is handed to b, which then computes and hands its result to a.
let us say that d = 5
and that c means add 7
and that b means multiply by 2
and a means add 10
the resulting computation looks like this
<c>5</c> = 12
<b>12</b> = 24
<a>24</a> = 34
therefore the result of the expression
<a><b><c>d</c></b></a>
equals 34 when d equals 5
the meaning of the tags is defined by code in plugins corresponding to the tag names... so the code for the plugin
"a" would look like this;
$result = $data+10;
where $data is the value contained in the tag when it is executed.
with me so far? I know at this stage this may seem very arbitary, but please bear with me, this system is highly abstract, infact mathematical abstraction is what this is all about.
Rule 2 : tags formed with ( ) brackets are computed prior to
their child tags unless those child tags are also type ( )
(a)(b)(c)5(/c)(b)(a) is exactly the same as the above example.
however
(a)(b)<c>5</c>(/b)(/a) is not.
in this case the compute order would be b,a,c
b runs first with
"<c>5</c>" as its data. b means multiply by two so since its a string rather than a numerical value the result is
<c>5</c><c>5</c>
this would then be handed to a which means add ten... again since its a string the result would come out as
<c>5</c><c>5</c>10
the last thing to run is c... but this time because a prior tag added an extra
<c> tag in when it multiplied it by 2, the c tag executes twice giving the end result :
121210
ok... I guess your probably really scratching your head now... but not about the syntax... but rather why am I so keen on this? what do I see in this... its silly right?
Rule 3 : tags composed of type
are computed last
[a][b][c]5[/c][/b][/a]
is the same as before.
however
<a>[b]<c>5</c>[/b]</a>
computes in the order c,a,b ... giving :
1 : <a>[b]<c>5</c>[/b]</a>
2 : <a>[b]12[/b]</a>
3 : [b]12[/b]10
result : 2410
That's all the rules....
but what good is that???
consider this;
(given this="hello")
<hello>
[use]somefile[/use]
</hello>
<else>
[use]someOtherFile[/use]
</else>
(/given)
we have two tags here, and some markup
(given) runs first and because of the code in the plugin for given, it selects the matching tag from its children and returns it as the result.... one of the two "use" tags.
the upshot is with just these 3 rules, a complex hierarchy of nested tags can be built up which can define arbitrarily
complex behavioural results.
(given this="(c)5(/c)")
<12>
the answer is 12!
</12>
<else>
the answer was not 12, so therefore c was given
a value other than 5
[link to="someurl"]click[/link] here to try again!
</else>
(/given)
I have developed around 50 plugins for my system... and it
does work!
It's just not fast enough....
here is a forum system that is built entirely using these principles : http://67.23.4.149/action.pl
the theory is right.... its just that I don't know enough / am not smart enough to implement an efficient solution.
It's not my fault, I never finished college....
I know _FOR SURE_ that this system is wonderful to work with, all I need to do is make it efficient, and stop using a regexing / evalling old fashioned parsing system.
Please do not tell me to give up and use mainstream methods,
I AM NOT GOING TO DO THAT.
worst case scenario is that not a single one of you made it to the end of this document, and I just have to wait for the inevitable action of moores law for the code I have to become production viable... but then again, maybe I have just sparked someone's interest in this... I can only hope so.
It's not stubborness... please don't assume that because I can't make it efficient that it cannot be efficient, or that because I am not able to do it alone that there is no value in this code tangent, or the syntax rules that I have discovered and outlined above.
writing sites using this syntax set is a real breeze, it is wonderful to work with.... I am 100% sure I am onto something important and special... so please...
can you help?