pyy + C# = pyysharp?
Advances in C#’s syntax almost allow for a rudimentary implementation of pyy to be created. Comparatively, it is much uglier, less useful, and more of a pain to program than its Python counterpart which is why I doubt a functional C# version will ever become a reality.
Are there any advantages to using something like pyy when ASP.NET is available? Writing simple (X)HTML elements becomes a battle with the syntax and the code readability is greatly ruined. Creating a simple header link turns into an abomination that resembles Objective-C except with curly braces and parenthesis:
new h1(new {id="header"}, new a(new {href="/home/"}, "Link Title"))
The property-initializer syntax was also considered but the tag attributes seem too disjointed from the actual object:
new h1(new a("Link Title") {href="/home/"}) {id="header"}
The pyy equivalent for both of these examples is:
h1(a("Link Title", href="/home/"), id="header")
Unless some niche is made evident for a full pyy port don’t expect any of this code to see the light of day beyond the simple HtmlTag base class via this Gist.
Leave a Reply