SWIG author on the complexity of SWIG
code.activestate.com
SWIG author on the complexity of SWIG
1–10 of 12 posts
Re: SWIG author on the complexity of SWIG
#2Later, when I had to write native code to speed up Python, I always used plain old C and swig worked flawlessly.
Re: SWIG author on the complexity of SWIG
#3Re: SWIG author on the complexity of SWIG
#4Definitely agree with the C++ corner cases thing being a challenge - at times I felt like I was writing another compiler on top of the C++ type system to handle the corner cases. But again, I used powerful abstractions to handle that. For instance, my library uses boost graph library and djikstra's algorithm to handle C++'s tangled web of automatic type conversions.
Re: SWIG author on the complexity of SWIG
#5Re: SWIG author on the complexity of SWIG
#6If it shows anything, it is a horrible language design of C++. I wrote a C++ front-end long ago, and it is excruciating. Later, when I had to write native code to speed up Python, I always used plain old C and swig worked flawlessly.
The key was to handle the resulting Python module as a low level C wrapper effectively allowing us to write "managed C" in Python, which we encapsulated neatly in a library with a much more pythonic API. We then naturally went all the way up and implemented SQL-like API (no parser, just methods) and a Django model subset. A SQL subset parser and DBAPI compliance were planned features. All of that allowed us to develop new features in Python and on Django while maintaining compatibility with the old components (also thanks to Django multi-db support) and making the planned switch to a complete SQL database a drop-in replacement.
Re: SWIG author on the complexity of SWIG
#7If it shows anything, it is a horrible language design of C++. I wrote a C++ front-end long ago, and it is excruciating. Later, when I had to write native code to speed up Python, I always used plain old C and swig worked flawlessly.
Re: SWIG author on the complexity of SWIG
#8Re: SWIG author on the complexity of SWIG
#9I've been thinking about how to do this effectively and cleanly for a while now, and I wonder if the right path isn't to use clang to parse the C or C++ code and then generate interfaces from the LLVM IR. As far as I know, all the metadata you need is there, so it might prove simpler than parsing things on your own.