1. 22
  1.  

    1. 10

      Can we call it what it is: a compiler. The term “transpiler” has come into vogue lately, and has a history dating back to the 80s. The problem is that it offers no benefit in use over the word “compiler,” which of course means: “transforms source code written in a programming language into another computer language.”

      The amount of jargon in computing is already so numerous that the distinction of “at about the same abstraction level” that transpiler utilizes isn’t helpful to new programmers, and is actually a hinderance, in my opinion.

      Regarding this project, it seems really nice! I’ve seen many attempts to build systems programming languages (using close to the metal for the definition of sysprog) using s-expressions as the syntax, but don’t recall ever seeing a skin for C like this!

      1. 8

        if a compiler that goes from language A to language B is a transpiler, is a compiler that goes from a language back to itself (performing some transformation) a cispiler? enquiring minds wish to know

        1. 1

          If you really want to introduce the term “cispiler”, come up with something that takes language A as input and outputs language A.

          1. 3

            come up with something that takes language A as input and outputs language A.

            That’s exactly what she said:

            a compiler that goes from a language back to itself

            1. 2

              Like a pretty-printer for an IDE! These things exist.

              1. 1

                Formatting is not really a significant transformation. “Gofix” does some actual rewriting, but it can be argued that it takes an older version of the language and outputs the newer one.

          2. 2

            Can we call it what it is: a compiler. The term “transpiler” has come into vogue lately, and has a history dating back to the 80s. The problem is that it offers no benefit in use over the word “compiler,” which of course means: “transforms source code written in a programming language into another computer language.”

            We call “compiler” the software that outputs assembly and “transpiler” the one that outputs some other programming language (that may be compiled to assembly in another stage). Sometimes the distinction is important.

            1. 9

              I’m well aware of the distinction. I just don’t think it’s necessary.

              I’ll assume you know of Yacc. Did you know it’s actually an acronym for “Yet Another Compiler Compiler”? The history of “compiler compilers” is interesting, and tools that aren’t just parser generators exist and create full blown interpreters and other compilers form a descriptive language. These don’t, typically, generate assembly code, but are called compilers. Therefore, I reject your definition of compiler.

              1. 0

                My definition is relevant in other contexts. Take programming language implementations, for example. When we talk about “interpreted” vs. “compiled” we mean “compiled to Assembly”, not “compiled to Javascript” or “compiled to bytecode”.

                So if we want to use fewer words, we can say that TypeScript is transpiled and Rust is compiled and be sure that everybody understands the difference.

                1. 2

                  I don’t actually know of a compiler that produces an executable. In all cases I know of, the compiler generates some sort “object code” which needs to be “linked” to run. Python to bytecode, and TypeScript to JavaScript, then are really no different since you “interpret” JavaScript, just the same as Python interprets bytecode.

                  A typical compiler, by itself, does nothing but rerepresent some source code as something else, which some other tool can do something else with.

                  1. [Comment from banned user removed]

                    1. 2

                      I am not confused. “Some sort of object code” just wasn’t clear to you.

                      For all intents and purposes, the assembly code is the same as “object code,” since the assembler typically just translates human readable strings into a series of packed, fixed size numbers. It, of course, does a bit more than that.

                      If I had said that a C compiler generates “assembly”, my point would have actually been more obvious, because assembly language needs to be processed by something else, in the same way Python bytecode or output JavaScript does. In all cases there are multiple stages before a program is actually “run.”

                      Some LLVM based language compilers are even more fun. They don’t even produce assembly directly! Instead, they output a new intermediate representation, which is human readable, which the LLVM tooling can optimize and compile into assembly, which gets assembled, which can then get linked…

                      So, are LLVM based languages actually “transpilers” to you? And, are you starting to see why I think this word is superfluous?

                      1. 0

                        For all intents and purposes, the assembly code is the same as “object code,”

                        No, of course not. See the links I provided. For an overview of how an assembler is not simply replacing strings with opcodes, see https://sourceware.org/binutils/docs/as/

                        So, are LLVM based languages actually “transpilers” to you?

                        Let’s look at rustc. It does transpilation to LLVM IR in phase_4_translate_to_llvm() and it invokes LLVM to compile it to Assembly, then LLVM’s assembler to assemble the output into machine code - all that in phase_5_run_llvm_passes().

                        So rustc is mostly a transpiler that relies on LLVM for the actual compilation (and assembly). Rust is first transpiled to IR, then the IR compiled. Since the transpilation is just an internal intermediary phase, we can consider Rust a compiled language in the reference implementation.

                        And, are you starting to see why I think this word is superfluous?

                        No, the distinction between interpreting Python’s bytecode and running Go’s machine code is very important in practice.

                        1. 1

                          No, of course not. See the links I provided. For an overview of how an assembler is not simply replacing strings with opcodes, see https://sourceware.org/binutils/docs/as/

                          You seem to think I’m some kind of idiot, and I don’t appreciate it. So, rather than me becoming enraged, and resulting to name calling, we’ll just have to agree to disagree.

                          It does transpilation to LLVM IR in phase4translatetollvm() and it invokes LLVM to compile it to Assembly …

                          And, if we rewrite that as “It does compilation to LLVM IR in phase4translatetollvm…” it’s still just as easy to understand. But, I digress, and will not continue to comment on this thread. (Agreeing to disagree and all)

                      2. 1

                        (Also, I am your downvote.)

                        C compiler produces Assembly.

                        This isn’t definitively true, and IIRC the Microsoft compilers can generate assembly, but produce already “assembled”, e.g. object, code by default.

                2. 4

                  Then a transpiler can be a subset of compiler where either term is correct but transpiler is used when distinction is really important. Most people just want to input X to get Y out the other end.

                  1. 1

                    Then a transpiler can be a subset of compiler

                    It might make more sense the other way around: a compiler is a particular type of transpiler.

                    1. 3

                      It could go either way. Compiler is the oldest term. Might factor in.

                      1. 1

                        Transpilation is often considered a compilation strategy, like ahead of time or just-in-time compilation.

                        1. [Comment from banned user removed]

                          1. 1

                            LOL. You’ve obviously never read Reynolds, Jones, and Blowhard’s amazing work.

                  2. 1

                    I agree with you. Called mime a source-to-source compiler on Hacker News with a compiler dev correcting me that what I described was a “transpiler” but admitting they do “essentially the same thing” in same comment. Begs the obvious question about why he’d bother to correct me…

                    1. 9

                      He did it because like a lot of people (myself included) in this industry, he’s a blowhard.

                  3. 4

                    This is exactly the kind of thing I had in mind in the Scheme/LISP section of my counterpoint to C++’s complexity:

                    https://lobste.rs/s/g0xw08/c_complexity_its_feature/comments/gkjoud#c_gkjoud

                    It’s also similar to what I did for a BASIC-like 4GL. Creating constructs that allow for easy program analysis or transformation makes many features in high-level languages much easier to do than trying to fit them in C’s own syntax or semantics. Better to use something easier to work with that extracts to C. “Right tool for the job” and so on.

                    1. 3

                      reminds me of this classic story [link to postscript file, couldn’t find it on a webpage]