Live data from Hacker News

Transpiler, a Meaningless Word (2023)

people.csail.mit.edu

31–40 of 117 posts

Re: Transpiler, a Meaningless Word (2023)

#31
I think the distinction is meaningful - for example many compilers used to have C backends (GCC for example did) - so you code went through almost the entire compiler pipeline - from frontend to IR to backend where the backend did almost everything a compiler does, it only skipped target machine specific stuff like register allocation (possibly even that was done), arch specific optimizations and assembly generation.

A transpiler to me focuses on having to change or understand the code as little as possible - perhaps it can operate on the syntax level without having to understand scopes, variable types, the workings of the language. It does AST->AST transforms (or something even less sophisticated, like string manipulation).

In my mind, you could have a C++ to C transpiler (which removes C++ constructs and turns them into C ones, although C++ is impossible to compile without a rich understanding of the code), and you could have a C++ to C compiler, which would be a fully featured compiler, architected in the way I described in the start of the post, and these would be two entirely different pieces of software.

So I'd say the term is meaningful, even if not strictly well defined.

Re: Transpiler, a Meaningless Word (2023)

#32
post #16

Whenever someone argues the uselessness or redundancy of a particular word, a helpful framework to understand their perspective is "Lumpers vs Splitters" : https://en.wikipedia.org/wiki/Lumpers_and_splitters An extreme caricature example of a "lumper" would just use the word "computer" to label all Turing Complete devices with logic gates. In that mindset, having a bunch of different words like "mainframe" , "pc" , "…

That's very interesting!

Splitters make more sense to me since different things should be categorized differently.

However, I believe a major problem in modern computing is when the splitter becomes an "abstraction-splitter."

For example, take the mouse. The mouse is used to control the mouse cursor, and that's very easy to understand. But we also have other devices that can control the mouse cursor, such as the stylus and touchscreen devices.

A lumper would just say that all these types of devices are "mouses" since they behave the same way mouses do, while a splitter would come up with some stupid term like "pointing devices" and then further split it into "precise pointing devices" and "coarse pointing devices" ensuring that nobody has absolutely no idea what they are talking about.

As modern hardware and software keeps getting built on piles and piles of abstractions, I feel this problem keeps getting worse.

Re: Transpiler, a Meaningless Word (2023)

#33
The link to Lindsey Kuper's post https://decomposition.al/blog/2017/07/30/what-do-people-mean... is great!

I think the note about generators may be a good definition for when one language is "more powerful" than another; at least it's a good heuristic:

> The input and output languages have the syntax of JavaScript but the fact that compiling one feature [generators] requires a whole program transformation gives away the fact that these are not the same language. If we’re to get beyond the vagaries of syntax and actually talk about what the expressive power of languages is, we need to talk about semantics.

If a given program change is local in language X but global in language Y, that is a way in which language X has more expressive power.

This is kind of fuzzy because you can virtually always avoid this by implementing an interpreter, or its moral equivalent, for language X in language Y, and writing your system in that DSL (embedded or otherwise), rather than directly in language Y. Then, that anything that would be a local change in language X is still a local change. But this sort of requires knowing ahead of time that you're going to want to make that kind of change.

Sadly https://people.csail.mit.edu/files/pubs/stopify-pldi18.pdf is 403. But possibly https://people.csail.mit.edu/rachit/files/pubs/stopify-pldi1... is the right link.

Re: Transpiler, a Meaningless Word (2023)

#34
post #29

Earlier quoted context omitted.

'computer' is an ambiguous word. In a mathematical sense a computational process is just any which can be described as a function from the naturals to naturals. Ie., any discrete function. This includes a vast array of processes. A programmable computer is a physical device which has input states which can be deterministicaly set, and reliably produce output states. A digital computer is one whose state transition is…

Most functions from the naturals to naturals are uncomputable, which I would think calls into question your first definition. It's unfortunate that "computer" is the word we ended up with for these things.

Ah well, that's true -- so we can be more specific: discrete, discrete computable, and so on.

But to the overall point, this kind of reply is exactly why I don't think this is a case of L vs. S -- your reply just forces a concession to my definition, because I am just wrong about the property I was purporting to capture.

With all the right joint-carving properties to hand, there is a very clear matrix and hierarchy of definitions:

abstract mathematical hierarchy vs., physical hierarchy

With the physical serving as implementations of partial elements of the mathematical.

Re: Transpiler, a Meaningless Word (2023)

#35
post #29

Earlier quoted context omitted.

Most functions from the naturals to naturals are uncomputable, which I would think calls into question your first definition. It's unfortunate that "computer" is the word we ended up with for these things.

Ah well, that's true -- so we can be more specific: discrete, discrete computable, and so on. But to the overall point, this kind of reply is exactly why I don't think this is a case of L vs. S -- your reply just forces a concession to my definition, because I am just wrong about the property I was purporting to capture. With all the right joint-carving properties to hand, there is a very clear matrix and hierarchy o…

Word definitions are arbitrary social constructs, so they can't really be correct or incorrect, just popular or unpopular. Your suggested definitions do not reflect current popular usage of the word "computer" anywhere I'm familiar with, which is roughly "Turing-complete digital device that isn't a cellphone, tablet, video game console, or pocket calculator". This is a definition with major ontological problems, including things such as automotive engine control units, UNIVAC 1, the Cray-1, a Commodore PET, and my laptop, which have nothing in common that they don't also share with my cellphone or an Xbox. Nevertheless, that seems to be the common usage.

Re: Transpiler, a Meaningless Word (2023)

#37
post #16

Whenever someone argues the uselessness or redundancy of a particular word, a helpful framework to understand their perspective is "Lumpers vs Splitters" : https://en.wikipedia.org/wiki/Lumpers_and_splitters An extreme caricature example of a "lumper" would just use the word "computer" to label all Turing Complete devices with logic gates. In that mindset, having a bunch of different words like "mainframe" , "pc" , "…

I'm not convinced your L/S dichotomy applies. The concern there is that the natural world (or some objective target domain) has natural joints, and the job of the scientist (, philosopher, et al.) is to uncover those joints. You want to keep 'hair splitting' until the finest bones of reality are clear, then grouping hairs up into lumps, so their joints and connections are clear. The debate is whether the present cate…

> I'm not convinced your L/S dichotomy applies.

Proceeds to urm actually split.

Re: Transpiler, a Meaningless Word (2023)

#38
post #24

Earlier quoted context omitted.

> An extreme caricature example of a "lumper" would just use the word "computer" to label all Turing Complete devices with logic gates. I don't think that's a caricature at all; I've often seen people argue that it should include things like Vannevar Bush's differential analyzer, basically because historically it did, even though such devices are neither Turing-complete nor contain logic gates.

'computer' is an ambiguous word. In a mathematical sense a computational process is just any which can be described as a function from the naturals to naturals. Ie., any discrete function. This includes a vast array of processes. A programmable computer is a physical device which has input states which can be deterministicaly set, and reliably produce output states. A digital computer is one whose state transition is…

In fact ‘computer’ used to be a job description: a person who computes.

Re: Transpiler, a Meaningless Word (2023)

#39
post #22

IMO: Transpilers are compilers, but not all compilers are transpilers. In my book, transpilers are compilers that consume a programming language and target human-readable code, to be consumed by another compiler or interpreter (either by itself, or to be integrated in other projects). i.e. the TypeScript compiler is a transpiler from TS to JS, the Nim compiler is a transpiler from Nim to C, and so on. I guess if you…

For me, the "human-readable" part is key. It's not just that the output is e.g. javascript, but that it is more or less human-readable with about the same organization as the original code. If you implement SKI combinators, or three-address instructions, as functions in javascript, and that's the output of your compiler, I would not call that a transpiler.

Exactly. For a web dev oriented example, I would call coffeescript a transpiler, since it would transform

    # some comment
    myFun = -> 
       alert 'Hello CoffeeScript!'
into

     // some comment
     var myFun;

     myFun = function() {
         return alert('Hello CoffeeScript!');
     };
clearly intending the output code to be quite readable (even preserving comments).

Whereas Elm is a compiler since it transforms

  module Main exposing (main)

  import Html

  main =
  Html.text "Hello Elm!"
into

  (function(scope){
  'use strict';

  function F(arity, fun, wrapper) {
  wrapper.a = arity;
  wrapper.f = fun;
  return wrapper;
  }

  // about 4000 lines ommitted

  var $author$project$Main$main = $elm$html$Html$text('Hello Elm!');
  _Platform_export({'Main':{'init':_VirtualDom_init($author$project$Main$main)(0)(0)}});}(this));
Clearly not intended for (easy) human consumption.

Re: Transpiler, a Meaningless Word (2023)

#40

IMO: Transpilers are compilers, but not all compilers are transpilers. In my book, transpilers are compilers that consume a programming language and target human-readable code, to be consumed by another compiler or interpreter (either by itself, or to be integrated in other projects). i.e. the TypeScript compiler is a transpiler from TS to JS, the Nim compiler is a transpiler from Nim to C, and so on. I guess if you…

I can usually read JS generated by TS, but calling the C Nim outputs "human-readable" is very generous considering it flattens most structured control flow to goto. (It's hard to do it otherwise, Nim has to deal with exceptions and destructors but C has neither.)

Classifying Nim as a transpiler also results in weird cases like NLVM[1] which most would consider a compiler even though it is a back-end on the same "level" as Nim's C generator.

[1]: https://github.com/arnetheduck/nlvm

Post reply on HN