> I can't seem to understand the reason as to why multiple programming languages are used in the same product or software?

It is quite simple: there is no single programming language suitable for all needs and goals.

Read Scott's book [*Programming Languages Pragmatics*][1]

Some programming languages favor expressiveness and [declarativity][2] (a lot of scripting languages, but also high-level programming languages like [Agda][3], [Prolog][4], [Lisp][5], Haskell, Ocaml, ...). When the cost of development is important (human time and cost of developers), it is suitable to use them (even if the runtime performance is not optimal).

Other programming languages favor run-time performance (many low-level languages, with usually compiled implementations, like C++, Rust, Go, C, assembler, also specialized languages like OpenCL ...). When the performance of the code matters, it is preferable to use these languages.

In practice, it is unlikely to have a programming language which is highly expressive (so improves the productivity of the developer, assuming a skilled enough developer team) and very performant at runtime. In practice, there is a trade-off between expressivity and performance.

Notice that the cost of development is more and more significant today (that was not the case in the 1970s -at that time computers where very costly- or in *some* embedded applications -with large volume of product). The rule of thumb (very approximate) is that a skilled developer is able to write about 25 thousand lines of (debugged & documented) source code each year, and that does not depend much on the programming language used.


A common approach is to embed some [scripting language][6] (or some [domain specific language][7]) in a large application. This design idea (related to domain-specific language) has been used for decades (a good example is the [Emacs][8] source code [editor][9], using Elisp for scripting since the 1980s). Then you'll use an easily embeddable interpreter (like [Guile][10], [Lua][11], [Python][12], ...) inside a larger application. The decision to embed an interpreter inside a large application has to be done very early, and has strong architectural implications. You'll then use two languages: for low level stuff which has to run quickly, some low level language like C or C++; for high level scripts, the other DSL or scripting language.


Notice also that a given software can run, within most current [operating systems][13] (including Linux, Windows, Android, MacOSX, Hurd, ...), in several cooperating [processes][14] using some kind of [inter-process communication][15] techniques. It can even run on several computers (or many of them), using [distributed computing][16] techniques (e.g. [cloud computing][17], HPC, client server, [web applications][18], etc...). In both cases, it is easy to use several programming languages (e.g. code each program running on one process or computer in its own programming language). Read [*Operating Systems: Three Easy Pieces*][19] for more.

See also [this][20] & [that][21] & [that][22] & [that][23] answers of mine related to your question.

<sup>PS: there are also social or organizational or historical reasons to mix programming languages; I'm ignoring them here, but I know that in practice such reasons are dominant. Read also [*The Mythical Man Month*][24]</sup>


  [1]: https://www.cs.rochester.edu/~scott/pragmatics/
  [2]: https://en.wikipedia.org/wiki/Declarative_programming
  [3]: https://en.wikipedia.org/wiki/Agda_(programming_language)
  [4]: https://en.wikipedia.org/wiki/Prolog
  [5]: https://en.wikipedia.org/wiki/Lisp_(programming_language)
  [6]: https://en.wikipedia.org/wiki/Scripting_language
  [7]: https://en.wikipedia.org/wiki/Domain-specific_language
  [8]: https://www.gnu.org/software/emacs/
  [9]: https://en.wikipedia.org/wiki/Source_code_editor
  [10]: https://www.gnu.org/s/guile/
  [11]: http://lua.org/
  [12]: https://docs.python.org/3/extending/index.html
  [13]: https://en.wikipedia.org/wiki/Operating_system
  [14]: https://en.wikipedia.org/wiki/Process_(computing)
  [15]: https://en.wikipedia.org/wiki/Inter-process_communication
  [16]: https://en.wikipedia.org/wiki/Distributed_computing
  [17]: https://en.wikipedia.org/wiki/Cloud_computing
  [18]: https://en.wikipedia.org/wiki/Web_application
  [19]: http://pages.cs.wisc.edu/~remzi/OSTEP/
  [20]: https://softwareengineering.stackexchange.com/a/277229/40065
  [21]: https://softwareengineering.stackexchange.com/a/339948/40065
  [22]: https://softwareengineering.stackexchange.com/a/288144/40065
  [23]: https://softwareengineering.stackexchange.com/a/307685/40065
  [24]: https://en.wikipedia.org/wiki/The_Mythical_Man-Month