View Full Version : How can you combine several programming languages?

05-18-2002, 04:01 PM
I asked a guy about it and he said it's possible. Is this what DLL-files are for?

05-18-2002, 05:20 PM
In theory, it could possible to compile all source files (which are of different languages) into object code and then use a linker to link them into an executable.

An example of doing this is writing C code with GCC, assembly with NASM, and then using LD to link the files together.

05-18-2002, 05:29 PM
Look up .net or, if you want a more awkward example, COM.

05-18-2002, 07:10 PM
Ive never used it, but I heard you could combine all the languages included in visual studio .NET and incorporarte them into onve program...I could be wrong though.

05-19-2002, 02:56 AM
It is not necessary to use DLL's or .NET for that. It was also done on for example MS-DOS or UNIX. Mixing Pascal, C, C++, assembly etc. is possible when the compiled or assembled binaries are of such a format which the linker supports.

05-19-2002, 10:15 PM
I've only mixed code on the DOS side of things. I've mixed code between asm (TASM/MASM/NASM) and QBasic, Turbo C/C++, Borland C++, and DJGPP. I have not mixed and high level languages together. Easiest to mix is C and asm. QuickBasic and asm are a bit different when it comes to how they communicate. But since I code mostly in C/C++ and just use QB to tinker around with small stuff I'm not too interested in mixing the two.

I was going to try to mix C with VB6 some time back, but gave up on it. My uncle's company tried the same thing with their code and dumped C altogether. W/o third part libraries and helper utils it was very hard to get them to communicate correctly. But with .NET all that should be resolved.

If you want to mix asm with C you will need to know the memory model you are using and the order in which things are pushed onto the stack. Otherwise, none of the parameters will be what you expect them to be because your data alignment will be way off (or pointing at the wrong parameter). You must also be careful when using C structs with assembly. You must know how the compiler aligns the struct (usually in your options menu on your compiler) or your data will be way off and you will most likely bring the whole thing crashing down.

You can also use asm with the Win32 API. I'm currently looking into some of that. Does not look overly complicated. Now using an ActiveX or COM object in asm, well that might be very hard. But its probably just a matter of getting a pointer to the interface and calling via that pointer.

Anyways, you can mix any language with assembly since that is what everything eventually turns into. As far as mixing two higher level languages, it can be done - I've just never attempted it.