-4

I have looked this up and I still cannot find any sort of answer to this.

The thing I am referring to is Polyglot programming, which is the use of multiple programming languages to make an application (I think that's a correct definition).

I am just wondering why you would use something like C++ and Java together?

I am aware they have their advantages and disadvantages but what is the actual point and how would these two be put together to work with each other?

Bart
  • 19,692
  • 7
  • 68
  • 77
6a6179
  • 272
  • 4
  • 20
  • What's the point of both Oil Paint and Colored Pencils? –  Jul 29 '11 at 21:30
  • Polyglots don't have advantages or disadvantages. They're done **for fun**. – R. Martinho Fernandes Jul 29 '11 at 21:30
  • You mix languages for the same reason you mix platforms. For example, OpenOffice can be automated from C++ or Java. ASP.NET is typically C# or VB.NET. There can be many a tremendous amount of existing source code, or expertise within a company, or availability of a library for a particular platform. You might want to use Linux for security, but then you figure out a library only exists for Windows, and you put that into a web service. It's often done out of necessity. – Tamas Demjen Jul 29 '11 at 22:54

1 Answers1

4

Polyglots aren't one application made of multiple languages, they're one source code text which compiles as valid multiple languages, and they pretty much don't have a use.

You use multiple languages for their individual strengths. For example, I might use C# for GUI work and WPF, which is an excellent strength, but I might use C++ to write the core of my application, because that's it's strength. I could write the GUI in C++ but that's not a strong point of C++, and I could write my core algorithms in C# - if I was OK to have little to no control over the application and how it was written and how it executes and let it take much longer to execute.

Using both together means that I can have an application with a sweet-ass extensible GUI written in WPF and C#, and a powerful, performant core written in C++.

Puppy
  • 144,682
  • 38
  • 256
  • 465
  • 1
    And a painful interop layer ;) – R. Martinho Fernandes Jul 29 '11 at 21:32
  • Polyglots are *not* "source code" -- except in a case of source code that can run in *multiple* languages. See [Polyglot (disambiguate)](http://en.wikipedia.org/wiki/Polyglot) for references ;-) Anyway, I suspect that C#(or VB.NET)/JavaScript are much more common "mixture" (not polyglot code) with the abundance of web programming. –  Jul 29 '11 at 21:32