8 ms·
Back in the mid-80s, I frequented BIX (the BYTE Information eXchange). There was a discussion group for the C programming language, and someone mentioned this n
by Stratoscope 9y ago
Back in the mid-80s, I frequented BIX (the BYTE Information eXchange). There was a discussion group for the C programming language, and someone mentioned this new C++ language. I naively asked, "C++? That's a preprocessor, isn't it?" I was thinking of the original Cfront, of course, which translated C++ to C.
Bjarne Stroustrup jumped in and gently chewed me out: "The Cfront compiler is not a preprocessor! It is a full-fledged compiler just like any other. Sure, it uses C as the compilation target right now, but it won't always be that way. It could generate native code, but compiling to C let us get up and running more quickly and on more hardware architectures than we could if we targeted machine code right away."
(Those weren't his exact words, but definitely the gist of it. Some things like this stick in your mind.)
If "compiler" was good enough for Bjarne, it's definitely good enough for me.
Now jumping ahead to the present, consider Kotlin. Its compiler can target JVM bytecode and JavaScript, and they're working on native support using LLVM for the final code generation pass.
Is Kotlin a transpiler when it targets JavaScript, and only a true compiler when it targets the JVM or native code?
It just seems like a silly distinction. Why bother having a separate name? A compiler is a compiler.
- icebraining 9y agoI'd say a transpiler is a specific type of compiler. But yeah, it's not clear if the extra name is really useful.
- tom_mellior 9y agoMany other people in this thread are saying this too, but they all define the "specific" characteristics of a "transpiler" differently :-)
- astrodust 9y agoA "compiler" translates code from one form to another, and while historically that other form is machine code, ther's no requirement that this is the case: Java translates to JVM bytecode. People get upset when told Ruby is a "compiled" language, as technically the code is compiled into bytecode, because overall this is in the context of an interpreted language. Things do get blurry when it boils down to JVM bytecode in JRuby, which then goes on to have a JIT pass done on it... Even the CPU itself "compiles" the incoming instructions into internal ops. It's translating code into code. It's compilers all the way down.
- snarfy 9y agoIt is silly. I think part of it is simply a cultural divide between old school C programmers and young front end web developers. There used to be two spaces after a period, oxford commas, and 'literally' meant 'as it was written'. Languages change (for better or worse). Kids these days.
- Stratoscope 9y agoHey, you're welcome on my lawn any time. Some years ago I went on an editing binge on Wikipedia, finding a bunch of templates that "misused" the phrase "due to" and changed them to "because of". As we all know, you must get this right: "The flight delay was due to bad weather." vs. "The flight was delayed because of bad weather." but never: "The flight was delayed due to bad weather." The next day, someone reverted all my changes and asked, "Mike, have you looked at a dictionary lately?" Oops. In that moment I was enlightened: I realized I could care less. I even leave out the Oxford comma as often as I use it. In fact I leave out a lot of commas I used to put in. But there is one case where the Oxford comma is still necessary. If you leave it out of this joke it ruins it: "There are two hard problems in computer science: naming things, cache expiration, and off by one errors."
- gumoro 9y ago> I realized I could care less. I see what you did there. Well done.
- rz2k 9y agoThough it could simply mean the realization that one can choose to care less about prescriptive language rules
- gumoro 9y agoYes I think that's exactly what Stratoscope meant, and it was funny because that expression is a classic language peeve, as it is an illogical deformation (of the phrase "I couldn't care less") that is becoming the norm... but in that situation it made perfect sense. So I was showing appreciation for that nice touch.
- owebmaster 9y ago> Is Kotlin a transpiler when it targets JavaScript, and only a true compiler when it targets the JVM or native code? I'd say Kotlin is a language with different implementations, like clojure, ruby and others.
- thedonkeycometh 9y agoYeah, its a language that has a transpiler to javascript. Nothing stop it having another transpiler written for it, to webassembly, for example.
- mannykannot 9y agoDoes Kotlin have an abstract specification, or is it defined by a reference implementation?
- moo360 9y agoI don't know if I'm right or not but I tend to use the word "transpiler" to talk about something that transforms into the same language as before. So for example Babel is a transpiler since it turns JavaScript into JavaScript - it just allows you to use certain features (usually of a later version, or a draft) in earlier versions. So I write es8 and use babel to turn it into es5 compatible javascript, I'd call that transpiling. However, sticking with JavaScript, I'd say that coffeescript -> javascript is compilation since coffeescript is not the same language and very syntactically different. So I guess converting one language into another syntactically different language is a compiler. While converting a language into the same language but transforming specific parts for whatever reason (such as interop or backwards compat) is a transpiler. That's how I tend to think of it anyway. But I agree, probably could just use compiler for all of them, especially if not using it means added ambiguity.
- abdulhaq 9y agoRIP Byte