ArticleslgStudy

science

Cfront

Cfront is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Cfront rather than just read about it. In short: Cfront was the original compiler for C++ (then known as "C with Classes") from around 1983, which converted C++ to C; developed by Bjarne Stroustrup at AT&T Bell Labs. The preprocessor did not understand all of the language and much of the code was written via translations.

Key takeaways

  • Cfront belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Cfront to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Cfront from memory before moving on to harder problems.

Reference excerpt

Cfront was the original compiler for C++ (then known as "C with Classes") from around 1983, which converted C++ to C; developed by Bjarne Stroustrup at AT&T Bell Labs. The preprocessor did not understand all of the language and much of the code was written via translations. Cfront had a complete parser, built symbol tables, and built a tree for each class, function, etc. Cfront was based on CPre, a C compiler started in 1979. As Cfront was written in C++, it was a challenge to bootstrap on a machine without a C++ compiler/translator. Along with the Cfront C++ sources, a special "half-preprocessed" version of the C code resulting from compiling Cfront with itself was also provided. This C code was to be compiled with the native C compiler, and the resulting executable could then be used to compile the Cfront C++ sources. Most of the porting effort in getting Cfront running on a new machine was related to standard I/O. Cfront's C++ streams were closely tied in with the C library's buffered I/O streams, but there was little interaction with the rest of the C environment. The compiler could be ported to most System V derivatives without many changes, but BSD-based systems usually had many more variations in their C libraries and associated stdio structures. Cfront defined the language until circa 1990, and many of the more obscure corner cases in C++ were related to its C++-to-C translation approach. A few remnants of Cfront's translation method are still found in today's C++ compilers; name mangling was originated by Cfront, as the relatively primitive linkers at the time did not support type information in symbols, and some template instantiation models are derived from Cfront's early efforts. C++ (and Cfront) was directly responsible for many improvements in Unix linkers and object file formats, as it was the first widely used language which required link-time type checking, weak symbols, and other similar features. Cfront 4.0 was abandoned in 1993 after a failed attempt to add exception support. The C++ language had grown beyond its capabilities; however a compiler with a similar approach became available later, namely Comeau C/C++. Analogous to the way Cfront can process C++ source code into something that can be compiled by previously available C compilers, Herb Sutter's "cppfront" transpiles "Cpp2" (an experimental alternative C++ syntax) into standard C++ syntax. cppfront is different in scope in that it doesn't perform many validity checks on the code, instead relying on the C++ compiler for any checks that would require non-local understanding of the code such as establishing correct use of symbols. Cfront on the other hand was a complete compiler that just happened to target the C language instead of an assembler.

See also cppfront, a similar transpiler from an alternative C++ syntax to standard C++

References

Notes Bjarne Stroustrup. "Evolving a language in and for the real world: C++ 1991-2006" (PDF). Archived from the original (PDF) on 2007-11-20. Bjarne Stroustrup. "Bjarne Stroustrup's FAQ". Bjarne Stroustrup. "The Design and Evolution of C++".

External links Cfront Releases at C++ Historical Sources Archive cfront v3, the cfront re-port for the 4th edition of Plan 9 from Bell Labs Cfront 3.0.3, "AT&T/Bell Labs C++ to C translator from 1994, modified to build on modern hardware"

Worked examples

Example 1 — a first encounter with Cfront

Start with the simplest possible case. Write down what Cfront claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Cfront before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Cfront ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Cfront

In research
Cfront appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Cfront in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Cfront is common in secondary-school and first-year university syllabi. It links to neighbouring topics C++ compilers, Unix programming tools, so understanding it makes those chapters shorter.
In everyday life
Look for Cfront outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Cfront” →

How to study Cfront in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Cfront means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Cfront out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Cfront in simple terms?

Cfront was the original compiler for C++ (then known as "C with Classes") from around 1983, which converted C++ to C; developed by Bjarne Stroustrup at AT&T Bell Labs. The preprocessor did not understand all of the language and much of the code was written via translations.

Why does Cfront matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Cfront?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Cfront.

Tags

  • C++ compilers
  • Unix programming tools

Keep exploring