!dMDtGbujSAcxoTlFTk:matrix.org

GTAD - Generate Things from API Descriptions

6 Members
GTAD 0.6 is out - https://github.com/KitsuneRal/gtad/blob/master/README.md4 Servers

Load older messages


Timestamp Message
11 Jul 2018
00:45:12@kitsune:matrix.orgkitsuneMaking your DSL along the way :)
00:47:32@kitsune:matrix.orgkitsuneI actually started without templates, just generating files from C++. I soon found that any change and improvement in the generated code comes at a great price - even cosmetic generated code changes were heavy to the generator code.
00:47:55@kitsune:matrix.orgkitsuneBut this is C++ - it can be much better with functional languages, truth be told.
00:48:06@adam:thebeckmeyers.xyz&AdamRight. I wouldn't be actually generating code in this case. Just writing macros.
00:48:42@adam:thebeckmeyers.xyz&AdamDoesn't allow me to easily adjust final product for edge cases though, which would be big advantage of this way.
00:48:56@kitsune:matrix.orgkitsuneThe thing is - if you can have your code be structured in exactly the same way as the swagger definition, then you really need to just right some clever transformation function.
00:51:17@kitsune:matrix.orgkitsuneExactly! but then come all the particular cases, and you have to specialise that transformation function and, most dauntingly, you have to keep the context around, and that's where things really go nuts. It's no more just a transformation function, you have to make a System so that this function picks the right transformation in right cases.
00:54:25@kitsune:matrix.orgkitsuneI actually feel limitations of Mustache and really think of switching to Lua or something like that as the templating engine in some next iteration. Mustache is good to contextually unfold arrays into code but when it comes to applying any conditional logic, it becomes very verbose because it's not fit for such things.
00:55:35@kitsune:matrix.orgkitsuneBut C++ code is in general TERRIBLY difficult to produce - a single thing that you have to produce two files rather than one brought another box of complexity.
00:56:14@kitsune:matrix.orgkitsuneThe template should be considerably easier for simpler languages.
00:56:17@adam:thebeckmeyers.xyz&Adam
In reply to @kitsune:matrix.org
Exactly! but then come all the particular cases, and you have to specialise that transformation function and, most dauntingly, you have to keep the context around, and that's where things really go nuts. It's no more just a transformation function, you have to make a System so that this function picks the right transformation in right cases.
I'm still tempted to forge my own. Julia's multiple dispatch maps really well to this kind of thing. I definitely see the wisdom of taking advantage of you having already done this tedious part, but the call of NIH is still strong. Haha.
00:56:53@kitsune:matrix.orgkitsuneAnd nothing beats YAML in conciseness when it comes to mapping the type system, which you have to do anyway.
00:56:57@adam:thebeckmeyers.xyz&Adam(he says as he sits on the couch reading a trash sci-fi book instead of doing anything productive)
00:57:07@kitsune:matrix.orgkitsuneWell, it's your project :)
00:59:46@kitsune:matrix.orgkitsuneI believe I did a fairly reasonable job at putting out things that should be configurable. Hacking the generator code just because you need to change this or that part of the generated definition quickly becomes a chore. But I haven't really invented anything new, it's a pretty usual simplistic compiler inside.
01:00:40@kitsune:matrix.orgkitsuneYou get files on input, parse them, make an intermediate model, feed that model to the backend that actually produces files.
01:01:06@kitsune:matrix.orgkitsuneIf you need/want, you can make the analyzer and the backend configurable.
01:01:13@kitsune:matrix.orgkitsuneThat's pretty much it.
01:01:51@adam:thebeckmeyers.xyz&AdamSkimming through, I think the most difficult part would be in using the libqmatrix stuff as an example. Not working in a language quite as crufty as c++, I keep going "don't need that or that or that"...
01:02:23@kitsune:matrix.orgkitsuneYou should take gtad.yaml but not templates.
01:03:02@kitsune:matrix.orgkitsuneAnd from gtad.yaml, you should take only the types map and the trick to avoid clashes with the language's reserved words, if needed.
01:03:53@kitsune:matrix.orgkitsuneThen the real problem for you will be that the model exposed to Mustache is not documented.
01:05:04@kitsune:matrix.orgkitsuneAnd that's why I said that probably the best thing would be if you give me an example of a file for a structure definition and for an API call definition in Julia (the way you want them to look) and then I templatise them on my end.
01:05:51@kitsune:matrix.orgkitsune(I actually said that I'm willing to help you with template files after Thursday but the above is the proposed way to help you :)
01:06:14@kitsune:matrix.orgkitsuneOr you can just write the entire thing :)
01:13:01@adam:thebeckmeyers.xyz&AdamAlright. I'll take a look around and let you know.
01:13:50@adam:thebeckmeyers.xyz&Adam Oh gosh. Vector{Int64} in Julia would be an array of integers, so now I've got Vector{{{1}}}. Need to actually go read the moustache spec to see what escaping is needed.
01:18:42@adam:thebeckmeyers.xyz&AdamHope that whatever's tying you up through Thursday turns out well for you. :)
03:52:35@kitsune:matrix.orgkitsuneHuh, tough start :) Luckily, mustache allows to replace delimiters with custom ones. I don't think GTAD will like it but I think I can convince it into behaving.
09:43:33@benpa:matrix.orgbenpa joined the room.

There are no newer messages yet.


Back to Room List