Combining different languages

This is a discussion on Combining different languages within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Ive never heard anyone mention this, so I dont even know if its possible. Is there anyway you can combine ...

  1. #1
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198

    Combining different languages

    Ive never heard anyone mention this, so I dont even know if its possible. Is there anyway you can combine different programming languages such as C, C++, Java, assmebler to work together at all?

    I can see assembler being useful with C or C++.

    If so, can you provide an example to why, or how it would be done.

    Thanks
    -MethodMan-

    Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.

    Homepage: http://www.freewebs.com/andy_moog/home.html

  2. #2
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    Yes, you can use assembly with c/c++. I think you type in some special command then you put your assembly code there. I'm not really sure how you do it, except that it's not that difficult to include it and that you can actually include it. Try doing a search for it on the board; I'm sure you'll find info about it.

  3. #3
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Code:
    #include <iostream>
    
    int main(int argc char *argv[])
    {
    	asm
    	{
    		xor eax, eax
    	};
    	std::cout << "Wasn't that fun!" << std::endl;
    	return 0;
    }

  4. #4
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    that didn't work

  5. #5
    Christian
    Join Date
    Mar 2002
    Posts
    618
    What compiler are you useing?
    I shall call egypt the harmless dragon

    -Isaiah 30.7

  6. #6
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    MSVC++ 6.0

  7. #7
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    Code:
    using namespace std;
    If you didn't include that, that might be your reason why it didn't compile.

    Btw, I've heard some where that it may vary on different compilers for what you use for your declaration of using asm.

    EDIT: n/m That doesn't completely solve the problem, but that still should have been included.
    Last edited by TechWins; 10-05-2002 at 12:56 AM.

  8. #8
    Registered User
    Join Date
    Dec 2001
    Posts
    88
    the syntax for asm isn't always the same (I think the C++ standard includes a keyword asm, but every compiler has its own syntax)

    for VC++

    __asm {
    xor eax, eax
    }

    or
    __asm xor eax,eax

    Look in the MSDN


    But there are more possibilities to combine different languages!

    For example with COM.
    Or very simple: with DLLs - because you can write a DLL in nearly every language...

    It is common to use a Visual Basic frontend, and a C DLL as backend

    It is important, that you have an interface which combines the languages. For example DLLs, COM or even .NET!
    Hope you don't mind my bad english, I'm Austrian!

  9. #9
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    I frequently write libraries and .DLL's in Object Pascal using Borlands Delphi product - their database stuff is so much easier to use than MS's.

    As long as you are careful with calling standards, etc. most languages compile to object files which can be linked together by a suitable linker to form an executable.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  10. #10
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    Yes it is possible to combine languages. A very important thing is understanding of the linker you are using. A lot of compilers, for whatever language, support a standard object-file format to which they can compile. With a linker which understands this format, you can combine it all.

    Combing languages is done a lot, since most languages have something they are better in than others. So to make efficient software, you could consider to use the advantages the individual languages offer.

    Java is a nice language, it is not very useful in real-time systems, but is is nice for creating for example a GUI. So for a real-time system with a GUI you could consider to use Java for the GUI and C++ for the real-time parts and if necessary use assembly to do the real low level stuff. If your application also has a lot of math to do, you could consider also program some parts in a functional language like Haskell.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Combining Languages?
    By alexnb185 in forum C Programming
    Replies: 4
    Last Post: 03-17-2008, 08:47 AM
  2. Why C Matters
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 136
    Last Post: 01-16-2008, 09:09 AM
  3. Strange loop
    By D@rk_force in forum C++ Programming
    Replies: 22
    Last Post: 12-18-2004, 02:40 PM
  4. Languages dying
    By Zewu in forum A Brief History of Cprogramming.com
    Replies: 31
    Last Post: 07-29-2003, 11:08 AM
  5. Programming Languages
    By DarkViper in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 12-12-2002, 02:28 PM

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