Closed ignacionr closed 1 year ago
Hi @ignacionr,
I am good thank you! how about you ?
First, thank you for your interest in this project! although its still on beta and not 100% complete, you can still make decent bots (which don't use the inline mode as its not implemented yet).
I understand your concern about the inheritance-based extensibility technique used here and actually you are right, there is no strong reason behind it except few ones of my own:
Simplicity: My goal was to create a user-friendly experience when working with bot callbacks. In my opinion, the inheritance-based extensibility technique provides a well-organized and easily manageable structure. I drew inspiration from the olcPixelGameEngine and found it intuitive to override callbacks and define actions when they're triggered.
Flexibility: I started the library with the idea that someone might want to run multiple bots within the same program (a requirement I encountered in a previous project). Using polymorphism simplifies managing multiple bots, which will be something like:
std::vector<Bot*> bots;
bots.push_back(new MyBot1());
bots.push_back(new MyBot2());
bots.push_back(new MyBot3());
// Run all bots simultaneously for (Bot* bot : bots) { std::thread([&]{ bot->start(); }).detach(); } ...
- **Uniqueness**: There are many Telegram bot C++ libraries out there such as [tgbot-cpp](https://github.com/reo7sp/tgbot-cpp), [tgbot](https://github.com/egorpugin/tgbot) ... I want to give this one some sort of uniqueness on how it's used.
Regarding performance, I agree that the use of inheritance is unlikely to significantly impact clock cycles. This library listens for updates from Telegram server and as soon as there are new updates, it dispatches them to the relevant callbacks. Whether we use inheritance with overridden methods or std::function callbacks, the difference in performance is negligible.
However, I remain open to new ideas and alternative techniques. If you have any suggestions or recommendations, please don't hesitate to share them with me.
Once again, thank you for your interest, and I wish you a good rest of day!
Such a lovely answer, thank you. Yes I do appreciate your work!
The problem with inheritance is... inheritance. So I totally see someone creating a lineage of bots, then you change some little thing and the whole lineage is broken.
Of course, this will mean that good programmers will create their own adapters and keep independence from your implementations.
So I guess what I am saying is be aware that you're making it easy for bad programmers to make big messes.
Take care and keep up the good work!
Hey, how are you! I am shopping for a Telegram Bot C++ library, and yours seems great. I've only looked at it for a few minutes and I see mostly what I like to see. Most importantly, only a few dependencies, and reasonable ones (cpr, nlohmann::json). What I don't see myself doing, is inheritance... It's been a long time since I left that style of programming. I mean, with templates and/or callables, you can achieve the same with a lot more flexibility and even getting a plus of performance and general stability by not resorting to vtables.
Your valuable opinion will be appreciated.