News for hackers. Stuff that matters.
Re:Pybind11 — Seamless operability between C++11 and Python by fulafel on Friday August 25, 2017 @09:57AM (#15098424)
The difference is that this was a function exposed to Python. The expectation of Python programmers is that calling into the module won't explode.

The Python vs C++ joke here is that the minimal a + b example turns out to be unsafe to call with random numbers.

Re:Pybind11 — Seamless operability between C++11 and Python by kazinator on Friday August 25, 2017 @04:24PM (#15101901)
A certain loss of safety is common when you're using FFI.

Take any language's FFI and bind to the C library atoi function. Poof, you have instant undefined behavior for bad string to int conversions.

If you want a safe, robust module that is based on FFI, you have to write some padding in the higher level language that avoids misusing the foreign API in any way.

Directly exposed FFI stuff is not safe and cannot reasonably be safe; it makes no sense to expect that.

Re:Pybind11 — Seamless operability between C++11 and Python by fulafel on Saturday August 26, 2017 @02:56AM (#15104403)
I disagree that this is a FFI. There's are FFIs for Python, the builtin one is called ctypes, and users know it's an exception to Python's safety. Modules implemented in C++ and presenting functionality to Python programs in a native way are expected to be safe.
Re:Pybind11 — Seamless operability between C++11 and Python by kazinator on Saturday August 26, 2017 @10:20AM (#15105559)
Unless I'm mistaken, the topic is Pybind11, which is a foreign binding mechanism. Being criticized is the example in its documentation:

http://pybind11.readthedocs.io/en/master/basics.html

under the heading "Creating bindings for a simple function".

Looks like FFI to me.