4 ms·
Can you comment on why this is C and not C++? (Although some examples are in C++)
by swah 13y ago
Can you comment on why this is C and not C++? (Although some examples are in C++)
- desas 13y agoIt's very easy to re-use C code in most other languages.
- wtetzner 13y agoSure, but why not write in C++ and just expose a C interface?
- nostrademons 13y agoThat's possible, but it doesn't actually save all that much effort, and the interface layer would slow things down needlessly. The parts of C++ that I most missed with this project were standard libraries for string and vector. Many times they were just accumulating or munging values that would eventually end up in the C-API parse tree, and so if I wrote them in C++, I'd just need to translate to a C implementation afterwards. I could potentially have used classes & objects for some of the states, but the array-of-function-pointers that it currently uses is basically just as easy and simpler.
- johnbellone 13y agoIf you are writing this as a library you're most likely going to end up having to write a C wrapper for most language bindings. In the end it may just be easier to write the whole library in C and then write the specific binding for Python, Ruby, etc.
- nostrademons 13y agohttps://news.ycombinator.com/item?id=6213558 https://news.ycombinator.com/item?id=6213558