Thread: a universal compiler....!!!

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    3

    a universal compiler....!!!

    I am just speculating my imagination that whether at all, is it possible to build a universal compiler....??

    For example, if i am programming in c( I use turbo c++ 4.5), is it possible to embed java code and some other language so that when the program gets executed....the java code gets executed simultaneously as the remaining c code...!!


    Or, if i figure it in this way...If we have one environment in which compilers of java, c, perl, pyhton are linked together...and when a program is written containing multiple codes of different languages....it gets executed accordingly.....!!!


    Sorry for my ignorance, i am a newbie...and quite new to programming....!!!

    looking for a reply,

    bablu1988

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Is it possible? Absolutely. Would it be trivial to design such a system? Hardly. The complexity of such a project would be incredible, and probably require the skills of many talented developers to come up with a good solution to the problem.

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    You can embed perl in C, and C in perl, altho I've never tried to do either one. Apparently all that's involved in the former case is linking in the perl library, which is of course written in C:

    perlembed - how to embed perl in your C program

    And then you can call functions to call perl subroutines from another file. So that is on this road.

    I will get around to trying it at some point; depending on what you are doing it might even be incredibly efficient, is my hunch, since the "overhead" of the perl interpreter would be sorted out at compile time, and perl itself would not be required at runtime.
    Last edited by MK27; 08-13-2009 at 12:36 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    Microsoft's programming tools, the ".net" buzzwords are claiming to do just that. Several language - compiled modules to link together. I find the task too daunting... several books and online references just left me with gigantic headaches.

    I don't know why one can't enclose source code units with standardized keywords to identify the languages... and let a conglomerate compiler deal with it.

  5. #5
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Insofar as existing compilers produce OBJect files as output, and given that it is possible to link those object files and the functions in those object files follow standard (cdecl or stdcal) calling conventions, yes it is currently possible to do so, but not mixed code within the same source file.

    So the only real issue is getting the compiler to recognize what code it is compiling, the most suitable method of course is to use the filename extension

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Another issue would probably be that it wouldn't work with Turbo C! The compiler is old and outdated. Get a newer one: SourceForge.net: Integrated Development Environment - cpwiki
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    is it possible to embed java code and some other language so that when the program gets executed....the java code gets executed simultaneously as the remaining c code...!!
    You also need to remember the difference in platforms here. Java gets compiled into bytecodes, C gets converted into machine code. A processor runs the compiled C, natively, bytecodes have to be interpreted by a virtual machine. So it's possible to combine different platforms, but it's not trivial (except for some languages, perhaps). It also doesn't always make sense to do. Combining C and Java? Kinda defeats the purposes of each language.

  8. #8
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Here's an example of two languages that do make sense to integrate:

    C-Fortran Interface

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  2. Compiler Paths...
    By Cobra in forum C++ Programming
    Replies: 5
    Last Post: 09-26-2006, 04:04 AM
  3. C Compiler and stuff
    By pal1ndr0me in forum C Programming
    Replies: 10
    Last Post: 07-21-2006, 11:07 AM
  4. I can't get this new compiler to work.
    By Loduwijk in forum C++ Programming
    Replies: 7
    Last Post: 03-29-2006, 06:42 AM
  5. how to call a compiler?
    By castlelight in forum C Programming
    Replies: 3
    Last Post: 11-22-2005, 11:28 AM