How can you combine several programming languages?

This is a discussion on How can you combine several programming languages? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I asked a guy about it and he said it's possible. Is this what DLL-files are for?...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    367

    How can you combine several programming languages?

    I asked a guy about it and he said it's possible. Is this what DLL-files are for?

  2. #2
    Disagreeably Disagreeable
    Join Date
    Aug 2001
    Posts
    711
    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.

  3. #3
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    Look up .net or, if you want a more awkward example, COM.

  4. #4
    Registered User dirkduck's Avatar
    Join Date
    Aug 2001
    Posts
    428
    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.

  5. #5
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    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.

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange loop
    By D@rk_force in forum C++ Programming
    Replies: 22
    Last Post: 12-18-2004, 01:40 PM
  2. Languages dying
    By Zewu in forum A Brief History of Cprogramming.com
    Replies: 31
    Last Post: 07-29-2003, 10:08 AM
  3. Languages
    By KrAzY CrAb in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 02-18-2003, 11:23 AM
  4. Programming Languages
    By DarkViper in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 12-12-2002, 01:28 PM
  5. combine C with other languages?
    By drharv in forum C Programming
    Replies: 1
    Last Post: 06-17-2002, 10:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21