School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,404 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,611 people online right now. Registration is fast and FREE... Join Now!




Using multiple languages for one program

 

Using multiple languages for one program

chris772

9 Jun, 2009 - 04:38 PM
Post #1

D.I.C Head
**

Joined: 13 Mar, 2009
Posts: 166



Thanked: 2 times
My Contributions
I have googled this topic before, but I haven't come up with many answers on if using multiple languages will slow a program or have any effect. My question is simply if a single program could utilize different languages.

For example (odd, but someone could have a need to), use assembly to test hardware, C# for sockets, and C++ for GUI.

Would you have to make a smaller program as a launcher for the satellite programs, or could they just be linked together somehow?

User is offlineProfile CardPM
+Quote Post


AdaHacker

RE: Using Multiple Languages For One Program

9 Jun, 2009 - 05:45 PM
Post #2

D.I.C Regular
***

Joined: 17 Jun, 2008
Posts: 378



Thanked: 83 times
My Contributions
QUOTE(chris772 @ 9 Jun, 2009 - 06:38 PM) *
For example (odd, but someone could have a need to), use assembly to test hardware, C# for sockets, and C++ for GUI.

You could do that, but why would you want to?

It depends on what you mean, but in general, yes, it's possible to mix languages within a single program. In fact, if you count using a library written in one language from another, then the vast majority of programs actually do this. It's also possible to embed interpreters for other languages, run separate executables written in another language, and various other things. It all depends on the languages and environment you're talking about.
User is offlineProfile CardPM
+Quote Post

chris772

RE: Using Multiple Languages For One Program

9 Jun, 2009 - 07:25 PM
Post #3

D.I.C Head
**

Joined: 13 Mar, 2009
Posts: 166



Thanked: 2 times
My Contributions
Because I can work with sockets in C#, but I am still getting the hang of them in C at the moment. How would I bring those C# libraries into C++?

For example, System.Text and System.Net.Sockets are not in C++.

I am using VC++ 2008 Express by the way (on Windows of course).
User is offlineProfile CardPM
+Quote Post

no2pencil

RE: Using Multiple Languages For One Program

9 Jun, 2009 - 07:27 PM
Post #4

i R L33t Skiddie, k?
Group Icon

Joined: 10 May, 2007
Posts: 13,228



Thanked: 289 times
Dream Kudos: 2875
Expert In: Goofing Off

My Contributions
My experience with multiple languages would be to write a function or functionality in the language that you know best, compile it as a DLL, & it is now distributable & able to be used with whatever language you want to write the Front End in.

This was usually the case when a buddy of mine, & me would collaborate on projects. I would write functionality in C or ASM & compile it as a DLL, & then he would work on the front end in VB6 (it was years ago) & we'd be up & running in half the time.
User is online!Profile CardPM
+Quote Post

Core

RE: Using Multiple Languages For One Program

9 Jun, 2009 - 07:35 PM
Post #5

Den The Developer
Group Icon

Joined: 8 Dec, 2008
Posts: 2,944



Thanked: 214 times
Dream Kudos: 900
Expert In: C#, VB.NET, .NET Framework

My Contributions
QUOTE
For example, System.Text and System.Net.Sockets are not in C++.


Those are available in Visual C++, as it uses the same .NET classes. Make sure you declare them this way:

CODE

    using namespace System::Text;
    using namespace System::Net::Sockets;


Also, make sure you have the needed references. Just right click the project and select References.

And by the way, language interoperability is one of the core concepts of the .NET platform.
User is offlineProfile CardPM
+Quote Post

RudiVisser

RE: Using Multiple Languages For One Program

10 Jun, 2009 - 05:28 AM
Post #6

.. does not guess solutions
Group Icon

Joined: 5 Jun, 2009
Posts: 1,872



Thanked: 137 times
Dream Kudos: 125
Expert In: PHP, MySQL, HTML, CSS, C#

My Contributions
I've developed several applications that use multiple languages.

A good example would be my DLL injector, it had a native injection DLL written in C++ that my C# GUI would utilise. Worked great and really simple to use, saves having to find a way to inject DLLs with C# smile.gif
User is offlineProfile CardPM
+Quote Post

sbromley

RE: Using Multiple Languages For One Program

10 Jun, 2009 - 06:40 AM
Post #7

New D.I.C Head
*

Joined: 20 May, 2009
Posts: 42



Thanked: 7 times
My Contributions
I remember as a project for school we had to put java swing gui's on our C routines. I can't for the life of me remember what the java library was called that linked the C routines to the Java code though.
User is offlineProfile CardPM
+Quote Post

chris772

RE: Using Multiple Languages For One Program

10 Jun, 2009 - 02:30 PM
Post #8

D.I.C Head
**

Joined: 13 Mar, 2009
Posts: 166



Thanked: 2 times
My Contributions
Well it seems very feasible to me now, but how did all of you link the libraries together? I know now that C# just uses .NET, but what about other languages?
User is offlineProfile CardPM
+Quote Post

RudiVisser

RE: Using Multiple Languages For One Program

10 Jun, 2009 - 02:57 PM
Post #9

.. does not guess solutions
Group Icon

Joined: 5 Jun, 2009
Posts: 1,872



Thanked: 137 times
Dream Kudos: 125
Expert In: PHP, MySQL, HTML, CSS, C#

My Contributions
QUOTE(chris772 @ 10 Jun, 2009 - 02:30 PM) *

Well it seems very feasible to me now, but how did all of you link the libraries together? I know now that C# just uses .NET, but what about other languages?

If you're writing something native such as C/C++ then you can just "extern" the methods and import them like any other native call from C#, DllImport.
User is offlineProfile CardPM
+Quote Post

NickDMax

RE: Using Multiple Languages For One Program

10 Jun, 2009 - 06:16 PM
Post #10

Can grep dead trees!
Group Icon

Joined: 18 Feb, 2007
Posts: 5,216



Thanked: 285 times
Dream Kudos: 1175
Expert In: Java/C++

My Contributions
Using functionality written in different languages is quite common and happens all the time. When I was a kid I programmed in QBasic and then used assembly to extend -- later I used C to help build a graphics library for it.

I have written several Java extension in C++ and just for fun I have called java functions from C (IMO that is a strange way to go... but it works).

Generally one builds up to an application so writing assembly, and C/C++ routines for C# is a natural progression.

You CAN use C# functions form C++ (esp. VC++) but like calling java functions from C its just a little odd...

Point is -- Yes you can write heterogeneous applications and in point of fact it is done very often.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 10:34PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month