Thread: What exactly is a compiler

  1. #1
    Registered User
    Join Date
    Jul 2012
    Posts
    9

    What exactly is a compiler

    Hello,

    I am probably out of programming for like 6 years ago. I am trying to make a comeback. Sorry if my questions are rudimentary


    C Compiler :- I read that it is an "executable" file. I want to know how this executable is like a .exe file in Windows 7. I want to know how a compiler interfaces the code and the OS.

    I may be jumping the gun , but i heard the Windows was written in C with 300,000 lines of code. So does the windows have a compiler in the back ground running and executing all the files , to make the operating system functional.

    This time around i want to understand before i go further, i think logic is a skill that is developed, but developing a good concept is equally important

    Thanks
    Bharat

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    A computer cannot execute program source code. It first must be turned into an executable file containing the machine-language instructions and data that the computer can understand. That's what the compiler (an executable file itself) does.

    So although Windows is written in C, it is compiled into exe's (and dll's) in order to run. This only needs to be done once, so no compiler is necessary to run Windows.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  3. #3
    Registered User
    Join Date
    Jul 2012
    Posts
    9
    Quote Originally Posted by oogabooga View Post
    A computer cannot execute program source code. It first must be turned into an executable file containing the machine-language instructions and data that the computer can understand. That's what the compiler (an executable file itself) does.

    So although Windows is written in C, it is compiled into exe's (and dll's) in order to run. This only needs to be done once, so no compiler is necessary to run Windows.
    Thank you for you swift response

    So the programmers , will run the code is converted into .exe or .dll file and then they are like the interface between the code and the machine right.

    I mean let us say, i click on the Start Menu button in Windows 7, the process is written in code , but it is already "compiled" to open up , with some .exe or .dll file running in the background.

    I want to understand how the S/W interfaces with H/W etc.

    But thanks for this comment

    "It first must be turned into an executable file containing the machine-language instructions and data that the computer can understand."

    Thanks
    Bharat

  4. #4
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    A compiler is a tool to translate one computer language into another. In particular most compilers translate to machine code. Machine code is the only language that computer hardware can actually read. Machine code varies between computer architectures, like pcs and mobile devices, but different generations of the same device tend to have the same machine code. Your typical PC uses the x86 architecture.

    It's also possible to have an interpreter, which instead of translating blocks of language text, reads the language one instruction at a time, and then does the associated action. In modern practice, the difference is somewhat blurred, except that interpreters can be interactive, compilers cannot.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  5. #5
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    Quote Originally Posted by BharatNT2IE View Post
    I mean let us say, i click on the Start Menu button in Windows 7, the process is written in code , but it is already "compiled" to open up , with some .exe or .dll file running in the background.
    No, a process doesn't inherently need any background process running, or even windows itself. Windows itself is a collection of processes. Now most processes do in fact have some dependency on the operating system. One reason for this is because it saves them from having to reinvent tasks that are already provided by the OS. The other reason is because the OS will run most processes in a restricted context such that doing anything useful is impossible without asking some OS library to do it for you.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  6. #6
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    What did your previous programming experience consist of, 6 years ago?
    If we know what that was then we should be able to relate that to what we're explaining.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  7. #7
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    "a miserable pile of secrets"

    Soma

  8. #8
    Registered User
    Join Date
    Jul 2012
    Posts
    9
    I am humbled, by your responses. My knowledge in C is rudimentary. I had to take this calls in my Undergrad, and i visited C for the sole purpose of passing the exam. So i never, practiced, or had any fun with code. Nothing else. I did not like s/w that much , but i liked Networking. But soon i realised, if i had the C knowledge (or more better the programming logic) i can really complement my Network Engineering skills well. So i am trying to be good at the things i do.

    Thanks
    Bharat Chandra Penumutchu

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by BharatNT2IE View Post
    ...I may be jumping the gun , but i heard the Windows was written in C with 300,000 lines of code. So does the windows have a compiler in the back ground running and executing all the files , to make the operating system functional.
    Just 300 000 lines of code? Mate, even the kernel is far bigger than that. We're talking about millions of lines of code here.
    I don't know how reliable these numbers are, but I believe the kernel is around 2 million lines of code and the OS in total around 50 million. This is for Windows 7.
    Actually, Windows is a mix of assembly, C, possibly C++ and who knows what else. Especially the Metro API in Windows 8.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 04-23-2012, 07:54 AM
  2. Replies: 7
    Last Post: 12-13-2010, 10:02 PM
  3. Replies: 4
    Last Post: 09-12-2009, 01:10 PM
  4. Replies: 2
    Last Post: 02-04-2008, 02:34 AM
  5. hp iPAQ 6300 && C compiler || C# compiler
    By xddxogm3 in forum Tech Board
    Replies: 2
    Last Post: 12-07-2004, 07:28 AM