• Re: Naughty =?UTF-8?Q?C=E2=99=AF?=

    From Charlie Gibbs@cgibbs@kltpzyxm.invalid to comp.os.linux.misc,alt.folklore.computers on Wed Jan 7 06:33:47 2026
    From Newsgroup: alt.folklore.computers

    On 2026-01-06, Waldek Hebisch <antispam@fricas.org> wrote:

    In alt.folklore.computers c186282 <c186282@nnada.net> wrote:

    On 1/6/26 07:16, Waldek Hebisch wrote:

    In alt.folklore.computers c186282 <c186282@nnada.net> wrote:
    <snip>
    Hmm ... look at all the GNU 'compilers' -
    FORTRAN, COBOL, Ada, 'D', M2, Rust,C++,
    G++, even Algol-68. None are 'compilers'
    per-se, but to-'C' TRANSLATORS. So, 'C',
    pretty much All Are One And One Is All.

    No. Compiler as first stage translate given language to a
    common representation. This representatiton is different
    than C. Ada and GNU Pascal have parametrized types, there
    is nothing like that in C. C++ (and some other languages)
    have exceptions, C do not have them. There are several
    smaller things, for example Ada or Pascal modulo is different
    that C/Fortran modulo. During optimization passes gcc
    keeps such information, to allow better optimization and
    error reporting.

    There were/are compilers that work by translating to C. But
    this has limitations: generated code typically is worse because
    language specific information is lost in translation. Error
    reporting is worse because translator is not doing as many
    analyzes as gcc do. For those reasons compilers in gcc
    generate common representation which contains sum of features
    of all supported languages and not C.

    You give it a file in whatever lang, it produces
    a file in 'C' and compiles that.

    No, if you looked at what compilers in gcc are doing you
    will see that there are no intemediate C file. There
    is intermediate assembler, but between source file and
    assembler each compiler work independently

    Still, Bjarne Stroustrup's first implementation of C++
    was a program called cfront, which translated C++ to C.
    --
    /~\ Charlie Gibbs | Growth for the sake of
    \ / <cgibbs@kltpzyxm.invalid> | growth is the ideology
    X I'm really at ac.dekanfrus | of the cancer cell.
    / \ if you read it the right way. | -- Edward Abbey
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From cross@cross@spitfire.i.gajendra.net (Dan Cross) to comp.os.linux.misc,alt.folklore.computers on Wed Jan 7 13:37:52 2026
    From Newsgroup: alt.folklore.computers

    In article <fzf7R.805815$i%aa.272881@fx12.iad>,
    Scott Lurndal <slp53@pacbell.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <84c7R.819121$PGrb.160843@fx10.iad>,
    Scott Lurndal <slp53@pacbell.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <10jjc9s$3uhtk$1@dont-email.me>,
    Chris Ahlstrom <OFeem1987@teleworm.us> wrote:
    Waldek Hebisch wrote this post by blinking in Morse code:

    In alt.folklore.computers c186282 <c186282@nnada.net> wrote:
    <snip>
    Hmm ... look at all the GNU 'compilers' -
    FORTRAN, COBOL, Ada, 'D', M2, Rust,C++,
    G++, even Algol-68. None are 'compilers'
    per-se, but to-'C' TRANSLATORS. So, 'C',
    pretty much All Are One And One Is All.

    No. Compiler as first stage translate given language to a
    common representation. This representatiton is different
    than C. Ada and GNU Pascal have parametrized types, there
    is nothing like that in C.

    <interjection>

    C++ (and some other languages)
    have exceptions, C do not have them.

    What about setjmp()/longjmp() ?

    Not at all the same thing. `setjmp`/`longjmp` are about
    non-local flows of control; exceptions are about non-local
    passing of values.

    However, in many real world situations, [sig]setjump and
    [sig]longjmp can be used to emulate exceptions.

    Yes, I said just that. :-)

    I have a C++ application that models a computer (Burroughs V380
    et alia). The thread that models each processor (cpu) uses
    longjmp whenever a condition is encountered that would have
    been signaled as a fault on the real cpu. The processor code
    doesn't do dynamic memory allocation; and the fault code is
    stored in the processor class before the longjmp call.

    I once tried replacing setjmp/longjmp with C++ exceptions which
    led to a 20% reduction in simulated CPU performance (as measured
    by the time to compile a COBOL program).

    Huh. Interesting. I wonder why...possibly to run a bunch of
    nop destructors?

    A large component of the overhead was the code generated in every
    function to handle unwinding during exception processing.

    That makes sense; thanks.

    When
    using setjmp/longjmp, I compiled with the following options so
    it wouldn't generate the unwind code:

    GXXFLAGS = -mno-red-zone
    GXXFLAGS += -fno-strict-aliasing
    GXXFLAGS += -fno-stack-protector
    GXXFLAGS += -fno-exceptions
    GXXFLAGS += -Wall
    GXXFLAGS += -mtune=native

    Most of those seem irrelevant to generating extra code for stack
    unwinding. `setjmp`/`longjmp` are really just pushing and
    popping some register state (including the stack pointer) so
    presumably it simply skips all of that code by skipping over any
    intermediate stack frame frames?

    - Dan C.

    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.os.linux.misc,alt.folklore.computers on Wed Jan 7 15:27:28 2026
    From Newsgroup: alt.folklore.computers

    Charlie Gibbs <cgibbs@kltpzyxm.invalid> writes:
    On 2026-01-06, Waldek Hebisch <antispam@fricas.org> wrote:

    In alt.folklore.computers c186282 <c186282@nnada.net> wrote:

    On 1/6/26 07:16, Waldek Hebisch wrote:

    In alt.folklore.computers c186282 <c186282@nnada.net> wrote:
    <snip>
    Hmm ... look at all the GNU 'compilers' -
    FORTRAN, COBOL, Ada, 'D', M2, Rust,C++,
    G++, even Algol-68. None are 'compilers'
    per-se, but to-'C' TRANSLATORS. So, 'C',
    pretty much All Are One And One Is All.

    No. Compiler as first stage translate given language to a
    common representation. This representatiton is different
    than C. Ada and GNU Pascal have parametrized types, there
    is nothing like that in C. C++ (and some other languages)
    have exceptions, C do not have them. There are several
    smaller things, for example Ada or Pascal modulo is different
    that C/Fortran modulo. During optimization passes gcc
    keeps such information, to allow better optimization and
    error reporting.

    There were/are compilers that work by translating to C. But
    this has limitations: generated code typically is worse because
    language specific information is lost in translation. Error
    reporting is worse because translator is not doing as many
    analyzes as gcc do. For those reasons compilers in gcc
    generate common representation which contains sum of features
    of all supported languages and not C.

    You give it a file in whatever lang, it produces
    a file in 'C' and compiles that.

    No, if you looked at what compilers in gcc are doing you
    will see that there are no intemediate C file. There
    is intermediate assembler, but between source file and
    assembler each compiler work independently

    Still, Bjarne Stroustrup's first implementation of C++
    was a program called cfront, which translated C++ to C.

    Rather ugly C, at that. I had to fix a bug in PCC[*] caused
    by the excessive use of the comma operator in the cfront
    generated C code.

    [*] Exhausted the temp registers generating the expression. Had
    to add sethi-ullman temp register allocation algorithm to PCC
    (generating code for the Motorola 88100) to handle the spills.
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.os.linux.misc,alt.folklore.computers on Wed Jan 7 15:30:20 2026
    From Newsgroup: alt.folklore.computers

    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <fzf7R.805815$i%aa.272881@fx12.iad>,
    Scott Lurndal <slp53@pacbell.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <84c7R.819121$PGrb.160843@fx10.iad>,
    Scott Lurndal <slp53@pacbell.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <10jjc9s$3uhtk$1@dont-email.me>,
    Chris Ahlstrom <OFeem1987@teleworm.us> wrote:
    Waldek Hebisch wrote this post by blinking in Morse code:

    In alt.folklore.computers c186282 <c186282@nnada.net> wrote:
    <snip>
    Hmm ... look at all the GNU 'compilers' -
    FORTRAN, COBOL, Ada, 'D', M2, Rust,C++,
    G++, even Algol-68. None are 'compilers'
    per-se, but to-'C' TRANSLATORS. So, 'C',
    pretty much All Are One And One Is All.

    No. Compiler as first stage translate given language to a
    common representation. This representatiton is different
    than C. Ada and GNU Pascal have parametrized types, there
    is nothing like that in C.

    <interjection>

    C++ (and some other languages)
    have exceptions, C do not have them.

    What about setjmp()/longjmp() ?

    Not at all the same thing. `setjmp`/`longjmp` are about
    non-local flows of control; exceptions are about non-local
    passing of values.

    However, in many real world situations, [sig]setjump and
    [sig]longjmp can be used to emulate exceptions.

    Yes, I said just that. :-)

    I have a C++ application that models a computer (Burroughs V380
    et alia). The thread that models each processor (cpu) uses
    longjmp whenever a condition is encountered that would have
    been signaled as a fault on the real cpu. The processor code
    doesn't do dynamic memory allocation; and the fault code is
    stored in the processor class before the longjmp call.

    I once tried replacing setjmp/longjmp with C++ exceptions which
    led to a 20% reduction in simulated CPU performance (as measured
    by the time to compile a COBOL program).

    Huh. Interesting. I wonder why...possibly to run a bunch of
    nop destructors?

    A large component of the overhead was the code generated in every
    function to handle unwinding during exception processing.

    That makes sense; thanks.

    When
    using setjmp/longjmp, I compiled with the following options so
    it wouldn't generate the unwind code:

    GXXFLAGS = -mno-red-zone
    GXXFLAGS += -fno-strict-aliasing
    GXXFLAGS += -fno-stack-protector
    GXXFLAGS += -fno-exceptions
    GXXFLAGS += -Wall
    GXXFLAGS += -mtune=native

    Most of those seem irrelevant to generating extra code for stack
    unwinding.

    For that, only -fno-exceptions is necessary. The others were
    left over - I had adapted the make files from a hypervisor project
    (where the first three flags were necessary).
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From John Ames@commodorejohn@gmail.com to comp.os.linux.misc,alt.folklore.computers on Wed Jan 7 11:40:23 2026
    From Newsgroup: alt.folklore.computers

    On Wed, 7 Jan 2026 12:20:54 -0700
    Peter Flass <Peter@Iron-Spring.com> wrote:

    On the other hand, a compiler that uses another compiled language
    as intermediate code is a strange beast, probably better called a translator.

    It's historically a pretty common thing to do when getting a new
    language off the ground, whilst getting the kinks out and before one
    has the time to write a dedicated compiler. In addition to C++, IIRC Objective-C also started out with a translator-compiler.

    It also allows the same language to be deployed in multiple different environments with minimal effort - Nim, f'rexample, compiles to Java-
    script as well as C-family and LLVM intermediate backends, so it can be
    used for web development.

    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From antispam@antispam@fricas.org (Waldek Hebisch) to comp.os.linux.misc,alt.folklore.computers on Thu Jan 8 01:00:02 2026
    From Newsgroup: alt.folklore.computers

    In alt.folklore.computers rbowman <bowman@montana.com> wrote:
    On Tue, 6 Jan 2026 21:00:25 -0500, c186282 wrote:

    Clearly the GCC collection is More Complicated than I thought.

    Back when dinosaurs roamed the earth it was the GNU C Compiler. Then it learned new tricks.

    https://en.wikipedia.org/wiki/Register_transfer_language

    <snip>

    But I'm still not sure I'll call them 'compilers'
    in the older sense of the word. Some intermediate term is required.

    That would be RTL. Microsoft's CIL is similar but depends on a runtime. CLang//LLVM is another approach which overlaps GCC. fwiw I have both on
    this box.

    IRs have been used for a long, long time.

    https://dl.acm.org/doi/epdf/10.1145/2480741.2480743

    Some light reading:

    https://archive.org/details/principlesofcomp0000ahoa/mode/2up

    RTL is old thing. It is still used in gcc, but about 20 years
    ago gcc introduced GIMPLE and IIUC it is now used for main
    processing. Front ends do what they want, then this is
    conveted to GIMPLE, optimizers work on GIMPLE, and finally
    GIMPLE is converted to RTL which is used to generate assebly.
    The point here is that most of work is in optimizers, they
    are language independent and mostly target independent
    (there is a buch of target macros that affects work of
    optimizers).
    --
    Waldek Hebisch
    --- Synchronet 3.21b-Linux NewsLink 1.2