32bites Posted April 7, 2008 Posted April 7, 2008 I have only written PHP and basic perl on web servers. I wanted to got in to C but I don't understand exactly what a complier does. And what the advantage of compiling code over giving source code to be interpreted. Quote
Sparda Posted April 7, 2008 Posted April 7, 2008 Uninterpreted compiled languages are able to run much more efficiently than any interpreted language. C is compilable in to machine language that the hardware of a computer can understand and run, this is what is used to create the majority of OS's, or at least the kernel, Including, but not limited to, Windows, Linux and OS X. A compiler takes the instructions you wrote, links them with any libraries you required (in C these would be header files) and converts them (compiles) in to machine code, the language of the computer. This can then be run on a computer. Unless you specifically write your code to be so, C code is not necessarily cross platform. While Compiled C code is able to run on the hardware of a computer, if you compile a program that is specifically for windows (meaning, you probably included a windows specific library), it probably wont run on Linux or OS X with out either modifying the code to implement the Linux/OS X equivalent of the windows library. Another option may also be to use a windows like environment (WINE). Advantages: Runs more efficiently than interpreted language Hides source code Computer hardware is able to run C Disadvantages: Harder to code (relatively speaking to php) Quote
32bites Posted April 7, 2008 Author Posted April 7, 2008 Uninterpreted compiled languages are able to run much more efficiently than any interpreted language. C is compilable in to machine language that the hardware of a computer can understand and run, this is what is used to create the majority of OS's, or at least the kernel, Including, but not limited to, Windows, Linux and OS X. A compiler takes the instructions you wrote, links them with any libraries you required (in C these would be header files) and converts them (compiles) in to machine code, the language of the computer. This can then be run on a computer. Unless you specifically write your code to be so, C code is not necessarily cross platform. While Compiled C code is able to run on the hardware of a computer, if you compile a program that is specifically for windows (meaning, you probably included a windows specific library), it probably wont run on Linux or OS X with out either modifying the code to implement the Linux/OS X equivalent of the windows library. Another option may also be to use a windows like environment (WINE). Advantages: Runs more efficiently than interpreted language Hides source code Computer hardware is able to run C Disadvantages: Harder to code (relatively speaking to php) Thanks of the help, that answers my question. Quote
jollyrancher82 Posted April 7, 2008 Posted April 7, 2008 compilers compile source files into object files, which the linker then links into an executable targetting the specific operating sytem, e.g ELF for Linux, Mach-O for OSX, and PE for Windows. Quote
Erroneous Posted April 10, 2008 Posted April 10, 2008 A layman's way of looking at it: A compiled program is like a person directly talking to a person operating a crane. You tell them to move, they move fairly quickly, but you might not always speak the same language as the operator. An interpreted program is like talking to a translator and the translator talking to the crane operator. The extra level of interpretation makes it so that if you have a good enough translator, you can talk to any crane operator, but it will take a little longer to get the job done. Luckily there are compilers for certain cross-platform and interpreted languages (python and Java through gcj for instance) that "pre-translate" everything ahead of time making your code run quite a bit faster. Quote
SomeoneE1se Posted April 10, 2008 Posted April 10, 2008 I was asked this question already... I'll have to use this, thanks. Quote
Rampant Posted June 29, 2008 Posted June 29, 2008 anyone know a cheap free c++ compiler? non-.Net as i think C++.net is dif from standard C++ Quote
sablefoxx Posted June 29, 2008 Posted June 29, 2008 anyone know a cheap free c++ compiler? non-.Net as i think C++.net is dif from standard C++ Best compilers out there are free g++/gcc (open soure) Quote
dejai Posted June 29, 2008 Posted June 29, 2008 If your trying to write cross platform take note that windows loves to fuck around standards so if you learn windows C or C++ its probably not the actual language. E.g if you use anything like system("cls"); or system("pause"); you have already done something that will not work on unix - like machines. Try using : getchar(); Quote
digip Posted June 29, 2008 Posted June 29, 2008 I'm using MinGW for windows which includes the GNU g++/gcc compiler http://www.mingw.org/ Download installer for Windows: http://downloads.sourceforge.net/mingw/Min...mp;big_mirror=1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.