TulipCharts / tulipindicators

Technical Analysis Indicator Function Library in C
https://tulipindicators.org/
GNU Lesser General Public License v3.0
818 stars 154 forks source link

C++, vectors #102

Closed codeplea closed 3 years ago

codeplea commented 4 years ago

@codeplea , have you ever thought about converting the library to a more C++ "style", and use vectors, instead of C-style arrays? I know it's easily possible to convert from one into another... but this would we a very interesting feature for future release versions...

Originally posted by @Malacarne in https://github.com/TulipCharts/tulipindicators/issues/35#issuecomment-655043352

codeplea commented 4 years ago

@Malacarne I moved your question to its own thread.

To answer your question, no. I don't see any advantage in moving from C to C++, and I see a lot of disadvantages.

For starters, C programmers won't/can't use C++, but C++ programmers can easily use C.

Also, std::vector is certainly going to be slower, and TI is focused on being fast. The safety provided by std::vector doesn't appear to be a huge advantage in this use case either, as each indicator still needs to do many other checks, such as seeing that each input vector is the correct size.

That said, if somebody wanted to make a C++ wrapper, I would support that, but I don't see any advantage to porting the C code to C++.

jayMcBee commented 3 years ago

Don't think either that would be a good use of resources -

I'm using Tulip from C++ and there's built-in ways of accessing the underlying data of e.g. a C++ vector as an array, no need to convert data..

codeplea commented 3 years ago

That's a very good point.