I know that you can use assembly combined with C++(either inline or using modules written completely in assembly, linked with the rest of the program), and I was curious how does a program written in different programming languages(eg Mozilla Firefox)work, and how it gets built.

You must first choose a base language that has support(via additional libraries and headers) for the other languages.
C and C++ has additional libraries for Python,Lua,Perl,XML and some more. I'm trying my best to implement Lua in a project of mine but am stuck with parsing events with SDL while the Lua interpreter is running.
You can get a general idea of how to from my post "Lua and SDL having a hard time". Its not really all that difficult once you understand the peculiarities of the library that you intend to use.