32bites Posted April 7, 2008 Share 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 Link to comment Share on other sites More sharing options...
Sparda Posted April 7, 2008 Share 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 Link to comment Share on other sites More sharing options...
32bites Posted April 7, 2008 Author Share 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 Link to comment Share on other sites More sharing options...
jollyrancher82 Posted April 7, 2008 Share 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 Link to comment Share on other sites More sharing options...
Erroneous Posted April 10, 2008 Share 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 Link to comment Share on other sites More sharing options...
SomeoneE1se Posted April 10, 2008 Share Posted April 10, 2008 I was asked this question already... I'll have to use this, thanks. Quote Link to comment Share on other sites More sharing options...
Rampant Posted June 29, 2008 Share Posted June 29, 2008 anyone know a cheap free c++ compiler? non-.Net as i think C++.net is dif from standard C++ Quote Link to comment Share on other sites More sharing options...
sablefoxx Posted June 29, 2008 Share 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 Link to comment Share on other sites More sharing options...
dejai Posted June 29, 2008 Share 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 Link to comment Share on other sites More sharing options...
digip Posted June 29, 2008 Share 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 Link to comment Share on other sites More sharing options...
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.