How to use multiple languages in a single program?

3

I've seen that Google Chrome is done in Python, C ++ and Assembly and it came to mind, how to program using multiple languages in a SINGLE program?

    
asked by anonymous 12.06.2016 / 18:48

2 answers

5

C ++, simply speaking, is a language that always generates an executable binary code for a processor after passing through the compiler < a>. Assembly does the same after going through the assembler . They can be linked together without any problem. Everything becomes a single executable because everything is executable code, it makes no difference in what language the source code was originally written, what matters here is the target code that is specific to a processor , is something the computer understands. Source code written in a language is something the programmer can understand.

Python is a bit different. It usually runs in an interpreted or semi-interpreted way (roughly). That is, you need a virtual machine that behaves as if it were a processor to execute language instructions. This virtual machine is software like any other. The best-known Pyhton virtual machine is written in C, which also generates binary code, and can be linked along with code generated by C ++ and Assembly.

Already the code written in Pyhton itself, either stays in an auxiliary file, or gets attached to the executable as a resource of the executable file or even a vector of bytes. It can contain either the source in Python or the bytecode of that virtual machine that will be generated from the source in Pyhton by a compiler.

This technique is known as an embedded virtual machine and can be done with several other languages like Moon and Harbour , just to name a few.

Note that I do not know if Chrome is a single program in fact. It is possible to do this, but nothing guarantees that it has been done. Before stating make sure this is true, there is a lot of misinformation out there. What I can state is that the basis of the Chrome code is C ++. You're likely to use some minimal thing in Assembly. Nothing tells me that Python is actually used on it. Actually I went to research and not only did not find anything about it, but even someone claiming it does not have it. Joining my observation with someone else stating, it makes me believe that this is actually misinformation. I just can not guarantee.

    
12.06.2016 / 19:27
0

In the development of a system you use various programming languages ( C# , JavaScrip , JQuery ). Each, as explained in Bigown's answer , has its "specialty."

Curiously, according to this forum , browsers were developed:

Firefox

  • Rendering: Gecko, C ++
  • JavaScript engine: SpiderMonkey, C
  • User interface: Mostly XUL (a custom XML dialect), CSS, and JavaScript, with some C ++.

Chrome

  • Rendering: WebCore, C ++
  • JavaScript engine: V8, C ++
  • User interface: Mainly C, although the mac port uses Objective-C, and some features in HTML, CSS and JavaScript.

Safari

  • Rendering: WebCore, C ++ (shared with Chrome)
  • JavaScript engine: JavaScriptCore, C ++
  • User interface: probably Objective-C with HTML

Internet Explorer

  • All in C ++

Opera

  • Opera switched to Webkit and V8, but the rendering was written in C ++
25.10.2016 / 18:43