# Library-independent code generation

**URL:** <https://forum.opencyphal.org/t/library-independent-code-generation/589>\
**Category:** Development & Maintenance\
**Created:** [August 9, 2019, 9:08am UTC](https://forum.opencyphal.org/t/library-independent-code-generation/589 "2019-08-09T09:08:56Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [August 9, 2019, 4:25pm UTC](https://forum.opencyphal.org/t/library-independent-code-generation/589/3 "2019-08-09T16:25:05Z")

</div>

> [@scottdixon](#):
>
> Totally on board with this.

Sigh. I was hoping for a lengthy debate with much deliberation on either side. _(no not really)_

> [@scottdixon](#):
>
> How do you want to handle the logistics? Should this be its own repo, a sub-folder of libuavcan, or perhaps this becomes something we add to Nunavut?

Can this be just a collection of predefined templates shipped with Nunavut? We could put them somewhere under [nunavut/src/nunavut at main · OpenCyphal/nunavut · GitHub](https://github.com/UAVCAN/nunavut/tree/master/src/nunavut) with a subfolder per language. Basically, all this would move under `nunavut/predefined_templates/python`: [https://github.com/UAVCAN/pyuavcan/tree/uavcan-v1.0/pyuavcan/dsdl/\_templates](https://github.com/UAVCAN/pyuavcan/tree/uavcan-v1.0/pyuavcan/dsdl/_templates)

Come to think of it, the above might be insufficient, because looking at the PyUAVCAN code generator I see that there is like a hundred lines of logic around the templates that appear quite necessary: [https://github.com/UAVCAN/pyuavcan/blob/uavcan-v1.0/pyuavcan/dsdl/\_compiler.py](https://github.com/UAVCAN/pyuavcan/blob/uavcan-v1.0/pyuavcan/dsdl/_compiler.py). So maybe instead of templates we could ship dedicated Python modules that can be also run as CLI tools, one per target language? `nnvg-python`, `nnvg-cpp`, etc.

I don’t yet know.

> [@scottdixon](#):
>
> We could also decide to implement this as c99 (i.e. just factor this out of libcanard) and use c99 dsdl data structures in libuavcan?

When the ancient proto-civilizations first invented the C language, they certainly did not plan for such use. This is confirmed by a recent discovery of a cave painting which said (my translation into modern English may be imperfect) that the lack of an adequate object model and namespacing in C makes it unfit for use with DSDL.

---

_[View the full topic](https://forum.opencyphal.org/t/library-independent-code-generation/589)._
