top | item 45912924

(no title)

ssrc | 3 months ago

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.

discuss

order

gampleman|3 months ago

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.

ethmarks|3 months ago

Would it still count as a transpiler if it minifies the code at the end?

For example, most SCSS workflows I've worked with converert SCSS source code into minified CSS, which is pretty difficult for a human to read. But I think that SCSS => CSS still counts as transpiling.

aleph_minus_one|3 months ago

> Would it still count as a transpiler if it minifies the code at the end?

I would say "yes, but the minimization is an additional step that is not actually a direct part of the transpiling process." :-)

So, a program that does this would not a transpiler by itself, but a program that

- executes a pipeline of which the transpiling is the most important step,

- can also be used as a transpiler by making transpiling the only step in the executed pipeline.