Hacker News new | ask | show | jobs
by 10000101 3279 days ago
Silly question, but if redis is written in c , couldn't c++ call redis' interface directly. I'm aware it wouldn't be best practice and there would be problems if redis' c code base was non-compliant with c++ standards? But is this effectively a c++ wrapper ?
2 comments

This is not a silly question. Yes, using the C library from C++ is certainly possible. There would be nothing non-compliant about that, although you would need to write code that is somewhat frowned upon when writing C++ (i.e. using raw pointers all over the place). No, this is not a wrapper. It doesn't use the C library to pass queries to redis.
Makes sense, thanks for clarifying clishem
A wrapper is not entirely useless. It can use features of C++ like shared / unique pointers, lambdas, w/e to make working with redis in a C++ code base more C++ like. This takes advantage of all the features from C++ while hiding the low level C interface (which I assume uses manual memory management for instance).