Hacker News new | ask | show | jobs
by mynegation 5405 days ago
If 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.

2 comments

SWIG worked wonders for me too when we had to iteratively lift a dependency on a proprietary ISAM C library in a critical application. The worse we had to do was to handle a bunch of corner cases due to some non-null terminated string handling and be wary of a silly global var which could have bitten us otherwise when multithreading. The extend functionality was awesome to make structs more object-oriented by adding a few key methods.

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.

Same experience in java. I had to write a java interface to some C++ code. I ended up writing a C wrapper, then interfacing SWIG to that. It made a complex problem very simple.