Jump to content

Recommended Posts

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.

Link to post
Share on other sites

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)

Link to post
Share on other sites
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.

Link to post
Share on other sites

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.

Link to post
Share on other sites
  • 2 months later...

anyone know a cheap free c++ compiler? non-.Net as i think C++.net is dif from standard C++

Link to post
Share on other sites
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)

Link to post
Share on other sites

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();

Link to post
Share on other sites

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

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...