On Saturday, 19 September 2020 at 20:17:06 UTC, aberba wrote:
Arsd cgi.d might be what you want if you want to it your way as its more low-level interface-wise.

Eh, it depends. My lib lets you do as much or as little as you want.

About ten years ago, I wrote a framework on top that automatically generates javascript/json interfaces as well as html form and output UI just given an ordinary D class. Had full interop with PHP too... all with no UDAs since they didn't exist yet!

I never really documented how to use it. Wrote a few examples on the forum but nothing formal. I kinda regret that; I've *still* never seen anyone else, anywhere, automate as much as it did.

old demo I posted in May 2011: http://arsdnet.net/cgi-bin/apidemo/javascript

I can't find the source to that anymore but it would be something like:

---
import arsd.web;

class CoolApi : WebApi {
   enum Color { red, green, etc }
   struct Person { int id; string first; string last; }

   Element getABox(Color c) {
         auto div = Element.make("div");
         div.style.color = to!string(c);
         return div;
   }

   int addSomeNumbers(int a, int b) { return a + b; }

   Person[] getPeople(int startingId) { return [Person(...)]; }
}
mixin FancyMain!CoolApi;
---

That's it - all the html and javascript are all auto-generated.


Nowadays I'm merging all those ideas into cgi.d and actually writing about it in my blog. There's a lot in my old implementation I didn't like but now that D's reflection is better than it was, I have techniques to make it even better.

My new dwidder website is the only public example of the new code so far https://github.com/adamdruppe/dupdates/blob/master/main.d#L157

Still a bunch more I'm slowly bringing together. D has unique strengths for web that javascript, ruby, and python can just *never* do and we should be pushing the edges to go as cool as we can.

Reply via email to