Is discord.js faster than discord.py? #8992
-
Let's say I create the same bot with the two libraries. Now which one will process the events/commands/requests more efficiently using less resources? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is a bit like comparing apples to oranges, let me explain.
They are two libraries written in different languages running in different runtimes, each one has their pros and their cons, and while JavaScript on Node.js is arguably very performant for a dynamic untyped language, Python's performance varies a lot from runtime to runtime (CPython, Cython...). Also, the libraries they use also contribute a lot to their performance, for example we recently switched from Additionally, there are third-party optional packages you can install to speed-up Furthermore, the heaviest load and main reason for your application to be slow is out of your control: networking. It won't matter if discord.js is able to process a message in 0.01ms vs discord.py taking 0.1ms for the same, if the reply you send takes 100ms to reach Discord. The time difference is negligible. The second typical load on most applications are databases, some depend on networking, some are file-based that are updated by the application (SQLite for example), but for all intents and purposes, they perform the same in the two, considering that in the latter, most drivers are written in C or C++, and not in the languages the packages are for (except for bridging the C/C++ backend with the JS/Py frontend). It's hard to compare the two, they're fundamentally different even if they have the same goal/purpose, and their different ecosystems also make it harder to compare as each library has ways to massively improve their performance in a way. There are things each library do that the other doesn't, which skews benchmarks a little, although intents may allow you to eliminate any side overhead from either. For all intents and purposes, it's best to use whatever you're most comfortable with, computers are very powerful, and both libraries are fine to use on small to medium-sized bots. If you're looking into more performance intensive options, you can run a (not-so-small) bot on both libraries and see which one uses the least resources, or alternatively you can use a performance-focused language such as Rust. |
Beta Was this translation helpful? Give feedback.
This is a bit like comparing apples to oranges, let me explain.
They are two libraries written in different languages running in different runtimes, each one has their pros and their cons, and while JavaScript on Node.js is arguably very performant for a dynamic untyped language, Python's performance varies a lot from runtime to runtime (CPython, Cython...). Also, the libraries they use also contribute a lot to their performance, for example we recently switched from
node-…