Hi David
Quoting David Bennett <[email protected]>:
I'm a compiler guy (amongst other scars). I was somewhat surprised
when I opened up the Thrift compiler to discover that it uses
industrial strength parsing (for a very slim language) and a
hand-rolled, ad hoc source code generator (for a serious backend
problem). I had expected the exact opposite.
After reading a few comments on this list I think a number of the
shortcomings of Thrift result from this. The compiler may be
'tweakable' but it sure ain't configurable. The precise content of
the generated code (and how to alter it) is an ever present problem.
My suggestion is that the backend of the compiler should be entirely
rewritten using modern code generation technology and a selection of
'skeletons' provided as separate text files. Anyone who wanted to
tweak the output for any of their special use cases could easily
copy and modify an individual skeleton without having to venture
into the dark recesses of the C++ compiler.
Did you had a look at the JIRA issues related to rewrite and changes on
the compiler?
Have you seen the python variant? This was another try to do it again.
I have seldom seen some successful rewrites, usually it takes too long
to bring them to the same level. Personally, I'm a fan of evolution.
With luck, the initial batch of skeletons could be extracted
directly from the existing compiler. It's still a biggish job.
[Side digression: for some languages code generation is not really
needed. The language has sufficient abstraction capability to
implement the IDL directly. Since there are other languages that do
not, we are stuck with code generation.]
The biggest choice is: which product to use for the code generation?
I have a little familiarity with T4 and the ANTLR StringTemplate,
and I've hand-rolled a couple of my own but there are heaps of
others out there. Maybe it all comes down to what you're used to.
I'm not sure I'm quite ready for the investment of time.
Feel free to rewrite the compiler and provide a test suite for review.
Improving the test suites across languages, improving CMake, fixing bugs
and many other topics to improve on Thrift has much higher priority than
rewriting something we already have.
best!
Roger
PS: dev list is a better place for such discussions.
Regards
David M Bennett FACS