> 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.

<sup>(however, there has been some *slow* progress in programming languages: Rust is more expressive than C or perhaps even C++ but its implementation is almost as performant, and probably will improve to generate equally fast executables. So you need to learn new programming languages during your professional life; however there is [*No Silver Bullet*][6])</sup>

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][7] (or some [domain specific language][8]) in a large application. This design idea (related to domain-specific language) has been used for decades (a good example is the [Emacs][9] source code [editor][10], using Elisp for scripting since the 1980s). Then you'll use an easily embeddable interpreter (like [Guile][11], [Lua][12], [Python][13], ...) 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][14] (including Linux, Windows, Android, MacOSX, Hurd, ...), in several cooperating [processes][15] using some kind of [inter-process communication][16] techniques. It can even run on several computers (or many of them), using [distributed computing][17] techniques (e.g. [cloud computing][18], HPC, client server, [web applications][19], 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*][20] for more.

See also [this][21] & [that][22] & [that][23] & [that][24] 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*][25]</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/No_Silver_Bullet
  [7]: https://en.wikipedia.org/wiki/Scripting_language
  [8]: https://en.wikipedia.org/wiki/Domain-specific_language
  [9]: https://www.gnu.org/software/emacs/
  [10]: https://en.wikipedia.org/wiki/Source_code_editor
  [11]: https://www.gnu.org/s/guile/
  [12]: http://lua.org/
  [13]: https://docs.python.org/3/extending/index.html
  [14]: https://en.wikipedia.org/wiki/Operating_system
  [15]: https://en.wikipedia.org/wiki/Process_(computing)
  [16]: https://en.wikipedia.org/wiki/Inter-process_communication
  [17]: https://en.wikipedia.org/wiki/Distributed_computing
  [18]: https://en.wikipedia.org/wiki/Cloud_computing
  [19]: https://en.wikipedia.org/wiki/Web_application
  [20]: http://pages.cs.wisc.edu/~remzi/OSTEP/
  [21]: https://softwareengineering.stackexchange.com/a/277229/40065
  [22]: https://softwareengineering.stackexchange.com/a/339948/40065
  [23]: https://softwareengineering.stackexchange.com/a/288144/40065
  [24]: https://softwareengineering.stackexchange.com/a/307685/40065
  [25]: https://en.wikipedia.org/wiki/The_Mythical_Man-Month