!dMDtGbujSAcxoTlFTk:matrix.org

GTAD - Generate Things from API Descriptions

7 Members
GTAD 0.7 is out | https://github.com/KitsuneRal/gtad3 Servers

Load older messages


SenderMessageTime
11 Jul 2018
@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:32
@kitsune:matrix.orgkitsuneBut this is C++ - it can be much better with functional languages, truth be told.00:47:55
@adam:thebeckmeyers.xyz@adam:thebeckmeyers.xyzRight. I wouldn't be actually generating code in this case. Just writing macros.00:48:06
@adam:thebeckmeyers.xyz@adam:thebeckmeyers.xyzDoesn't allow me to easily adjust final product for edge cases though, which would be big advantage of this way.00:48:42
@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:48:56
@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:51:17
@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:54:25
@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:55:35
@kitsune:matrix.orgkitsuneThe template should be considerably easier for simpler languages.00:56:14
@adam:thebeckmeyers.xyz@adam:thebeckmeyers.xyz
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:17
@kitsune:matrix.orgkitsuneAnd nothing beats YAML in conciseness when it comes to mapping the type system, which you have to do anyway.00:56:53
@adam:thebeckmeyers.xyz@adam:thebeckmeyers.xyz(he says as he sits on the couch reading a trash sci-fi book instead of doing anything productive)00:56:57
@kitsune:matrix.orgkitsuneWell, it's your project :)00:57:07
@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.00:59:46
@kitsune:matrix.orgkitsuneYou get files on input, parse them, make an intermediate model, feed that model to the backend that actually produces files.01:00:40
@kitsune:matrix.orgkitsuneIf you need/want, you can make the analyzer and the backend configurable.01:01:06
@kitsune:matrix.orgkitsuneThat's pretty much it.01:01:13
@adam:thebeckmeyers.xyz@adam:thebeckmeyers.xyzSkimming 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:01:51
@kitsune:matrix.orgkitsuneYou should take gtad.yaml but not templates.01:02:23
@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:02
@kitsune:matrix.orgkitsuneThen the real problem for you will be that the model exposed to Mustache is not documented.01:03:53
@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:04
@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:05:51
@kitsune:matrix.orgkitsuneOr you can just write the entire thing :)01:06:14
@adam:thebeckmeyers.xyz@adam:thebeckmeyers.xyzAlright. I'll take a look around and let you know.01:13:01
@adam:thebeckmeyers.xyz@adam:thebeckmeyers.xyz 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:13:50
@adam:thebeckmeyers.xyz@adam:thebeckmeyers.xyzHope that whatever's tying you up through Thursday turns out well for you. :)01:18:42
@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.03:52:35
@benpa:matrix.orgbenpa-matrix joined the room.09:43:33
15 Jan 2019
@benpa:matrix.orgbenpa-matrix changed their profile picture.13:13:57

Show newer messages


Back to Room ListRoom Version: