Like Tree4Likes
  • 3 Post By laserlight
  • 1 Post By phantomotap

What language is C written in?

This is a discussion on What language is C written in? within the C Programming forums, part of the General Programming Boards category; I've done a search for this, and the answer is typically just some smug person telling that C is written ...

  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    19

    What language is C written in?

    I've done a search for this, and the answer is typically just some smug person telling that C is written in C. I don't get why people refuse to give the type of answer that they know is sought. Sorry for the rant, but it wastes people's time, confuses them, and results in ignorance and the spread of misinformation. What language is C written in, as in before C ever exists to be able to continue developing the language in C, what language is C written into existence in?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,660
    Quote Originally Posted by Delicieuxz
    What language is C written in, as in before C ever exists to be able to continue developing the language in C, what language is C written into existence in?
    Assembly language, but that's not the whole story. For example, a compiler that can compile a minimal subset of C (and thus is not actually C) may be written in assembly language. A compiler can be written in this minimal subset of C to compile a compiler for a more full featured subset of C. Thus, in its final incarnation, the C compiler is not actually written in assembly language, but in C. Also, with the help of a cross compiler, it may be feasible to skip writing the initial compiler in assembly, perhaps even compiling the final C compiler directly for the new system.

    As a side note, this makes for interesting related reading: Reflections on Trusting Trust by Ken Thompson.
    nonpuz, Sebastiani and YocR like this.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Apr 2013
    Posts
    1,282
    As a similar example to a cross-compiler for C, Altair Basic was developed using an 8008 (subset of 8088 instruction set) emulator on a PDP 10. Wiki article:

    Altair BASIC - Wikipedia, the free encyclopedia

    In this case, the Altair Basic interpreter remained to be an assembly language program.

    I don't know if anyone ever did this, but it would be possible to create a C compiler or cross-compiler using another language like Fortran. (Then the chicken and egg issue is how was the Fortran compiler developed?).

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,506
    There's another history to be written, one about how people still can't use the web to search for answers.

    This is the second hit from "history of c language", and written by DMR
    Chistory
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    650
    It was originally "bootstrapped" in BCPL I believe. But nowadays a C compiler is written in either C or I think more and more commonly C++ (or a subset thereof).

  6. #6
    Registered User
    Join Date
    Aug 2012
    Posts
    19
    Quote Originally Posted by Salem View Post
    There's another history to be written, one about how people still can't use the web to search for answers.

    This is the second hit from "history of c language", and written by DMR
    Chistory
    Hey, thanks for being a jerk, and also thanks for not reading the OP. Why doesn't someone write history about not being able to properly consider OPs? I expect that nobody is going to instinctively search "history of the C language", and what I searched, probably similar to what most would (which is corroborated by the many similar askings of the same question, with many confusing and inaccurate answers), is "what language is C written in?", and there was no clear, solid answer, but there was some notable smug arrogance, perhaps similar to your post. It was only after an internet search failed to provide a dependable answer that I posted this here, and I explained this explicitly, I thought, in the OP. Out of many results searched, the most satisfying answer I read was "it used to be written in Assembly", and I think the full sentence might actually have been "I think it used to be written in Assembly".

    Otherwise, thanks for the helpful infos, people.

    Would it ever be possible, practical, or worthwhile, to re-write C going straight from machine code to a cross-compiler and then to C? Would this make C and everything that is coded in C run significantly more efficiently?
    Last edited by Delicieuxz; 11-15-2013 at 12:12 AM.

  7. #7
    Stoned Witch Barney McGrew's Avatar
    Join Date
    Oct 2012
    Location
    astaylea
    Posts
    420
    C's written in English, though compilers and interpreters for it are written in a variety of languages. You even see C implementations that use multiple programming languages, for instance, a compiler might be written with assembly (for the boot strapping process), C (for the compiler's core), yacc (to generate a C parser based on a grammar), shell/make (to execute programs that will build the compiler), and various mark-up languages for the documentation. Some C libraries use assembly language(s) to implement procedures like memcpy in a manner that's most efficient for the host environment(s).
    Would it ever be possible, or worthwhile, to re-write C going straight from machine code to a cross-compiler and then to C? Would this make C and everything that is coded in C run significantly more efficiently?
    What you're considering will optimise the compilation process, not the speed of the resulting code. It's important to note that a compiler simply translates a program from one language to another, so the performance of your program depends on how well the compiler can optimise its output.
    i dont believe in competition in da field of cboard posts, u see, i believe in a collection of posts each 2 be admired for der own personal statement. when in doubt, ask Willy!

  8. #8
    Registered User
    Join Date
    Nov 2012
    Posts
    1,067
    Quote Originally Posted by Delicieuxz View Post
    Hey, thanks for being a jerk
    ...
    Would it ever be possible, practical, or worthwhile, to re-write C going straight from machine code to a cross-compiler and then to C? Would this make C and everything that is coded in C run significantly more efficiently?
    Why do you come on the forums and then say people are jerks for giving you helpful information, that's not likely to improve your answers.

    I think its helpful to think of two different things here. There is the language itself "The C Language" which is defined today by a specification but originally it was defined by the language creators, and then there's the implementation "Implementation of C". As a metaphor its similar how we have the English language as a concept but then several English-language speakers, no two of which speak exactly the same.

    The efficiency of programs built on a particular implementation of C is not likely to be affected by how efficient the implementation is. Even if a very slow implementation can build a blazing-fast program as long as the implementation knows about the hardware it is targeting enough to make smart translation decisions.

  9. #9
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,660
    Quote Originally Posted by Delicieuxz
    Would it ever be possible, practical, or worthwhile, to re-write C going straight from machine code to a cross-compiler and then to C? Would this make C and everything that is coded in C run significantly more efficiently?
    If you want to have an efficient program written in C, then use efficient data structures and algorithms, write canonical and efficient C code, and then have a good optimising C compiler to compile it with optimisations turned on at a sufficiently high level. The optimising compiler itself could be written in any suitable programming language, but that in itself wouldn't affect your compiled C program.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  10. #10
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,231
    Would this make C and everything that is coded in C run significantly more efficiently?
    O_o

    Your statements show a fundamental misunderstanding of compilers, interpreters, and programming in general.

    But then, I wouldn't expect much from a person who can't "google". (Hint: The third page for "what language is C written in" has multiple explanations.)

    Soma
    nonpuz likes this.
    “Often out of periods of losing come the greatest strivings toward a new winning streak.” -- Fred Rogers
    “Salem Was Wrong!” -- Pedant Necromancer

  11. #11
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,506
    OP's keyboard is probably too soaked in ........ by now to type in anything useful.

    I bet they haven't even bothered to read the wise words of DMR before ranting about how unfair the universe is.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Is C++ or C language is a high Level language?
    By uthmankhale in forum C++ Programming
    Replies: 5
    Last Post: 08-25-2011, 06:00 PM
  2. Finding out which language a program is written in.
    By billstarks in forum Tech Board
    Replies: 9
    Last Post: 06-07-2007, 06:13 PM
  3. What's the Difference Between a Programming Language and a Scripting Language?
    By Krak in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 07-15-2005, 04:46 PM
  4. Lets make our own verbal/written language (non-programming)!!!
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 03-07-2002, 04:04 PM
  5. Computer Language VS Spoken Language
    By Isometric in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 02-04-2002, 02:47 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21