TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Transpiler, a Meaningless Word

6 点作者 samps超过 1 年前

8 条评论

tedunangst超过 1 年前
&quot;The word transpiler is often used by people when they want to say that built a tool that transforms programs between languages of roughly the same level of abstraction.&quot;<p>Right off the bat, that sounds like a word with a commonly understood meaning.
评论 #37154089 未加载
MrJohz超过 1 年前
There was some discussion of this on the PL subreddit. I get where the author is coming from (in the sense that all transpilers are really just compilers, and trying to make too much of a distinction results in arbitrary and useless boundary setting), but I think this is too far in the other extreme.<p>The term transpiler is useful if we can use it to define meaningful groups of tools that share some attribute that we want to discuss and explore. For example, transpilers typically target much higher level languages than a lot of other compilers, this brings its own challenges that are worth discussing. Or many transpilers need to produce reasonably human-readable output, which is seldom a concern for a lot of traditional compilers.<p>These aspects are fairly nebulous and it&#x27;s rarely useful to litigate the details (for example: Js_of_ocaml and Reason both turn OCaml code into JS, but only one of them has readability as an explicit design goal - does this mean only one of them is a &quot;true&quot; transpiler?) but it&#x27;s still useful to recognise that there exists a subset of compilers that exhibit reasonably unique behaviours that present their own challenges.
jrm4超过 1 年前
I always took it to mean<p>&quot;Something that converts source code in a language humans commonly write code in, into another language that humans also commonly (if perhaps less frequently) write code in?&quot;<p>As opposed to compilation, which is, conversion to something that humans rarely, if ever, write raw?<p>Anything wrong with this definition?
norir超过 1 年前
I personally think of a transpiler as a transliteration compiler. Say my favorite language is scala but I want to write a neovim plugin which must be written in lua. I can write a compiler that transliterates scala<p><pre><code> val greet = (whom: String) =&gt; print(s&quot;Hello, $whom!&quot;) </code></pre> to lua<p><pre><code> local greet = function(whom) print(&quot;Hello, &quot; .. whom .. &quot;!&quot;) end </code></pre> I think this is a perfectly reasonable thing to do and it is very straightforward to implement for cases like this in which one truly is just doing syntactic rewrites with no analysis. If I had such a transpiler, I could write new code using my preferred syntax but transpiling to the host language. My project collaborators don&#x27;t even have to know that this is my process. Writing a transpiler is also a great way to learn a new language since you are forced to learn the language constructs from the bottom up.<p>I do agree with the author though that usually you want to do more than just direct syntactic rewrites. But if you first write a transpiler, then you can extend it to do additional analysis but reuse the code generation components.
adsharma超过 1 年前
&gt; Another problem is that there are hundreds of built-in library functions that need to be compiled from Python from C<p>An approach I&#x27;ve advocated as one of the main authors of py2many is that all of the python builtin functions be written in a subset of python[1] and then compiled into native code. This has the benefit of avoiding GIL, problems with C-API among other things.<p>Do checkout the examples here[2] which work out of the box for many of the 8-9 supported backends.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;py2many&#x2F;py2many&#x2F;blob&#x2F;main&#x2F;doc&#x2F;langspec.md">https:&#x2F;&#x2F;github.com&#x2F;py2many&#x2F;py2many&#x2F;blob&#x2F;main&#x2F;doc&#x2F;langspec.md</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;py2many&#x2F;py2many&#x2F;tree&#x2F;main&#x2F;tests&#x2F;cases">https:&#x2F;&#x2F;github.com&#x2F;py2many&#x2F;py2many&#x2F;tree&#x2F;main&#x2F;tests&#x2F;cases</a>
vaughan超过 1 年前
I thought about building a transpiler from TypeScript to other languages as a learning tool.<p>It would also scaffold out the project structure for each language.<p>The idea would be not to allow all code, but focus on high-level intent as simply as possible using primarily builtin language and platform primitives.<p>Could even use the name of a function and some comments to express the intent, which then gets transpiled in the other language, without even looking at the implementation in TypeScript. Could probably lean on AI a lot.<p>I’d love to have “one obvious way” to do certain things in each language. This Pythonic rule is violated so often in every language. A lot of programming is the same thing but we all do it slightly differently. Just take a look at some stack overflow answers for really simple stuff.
bell-cot超过 1 年前
Reaction: &quot;Transpiler&quot; is a Marketing Word, hence meaningless by definition.
kthejoker2超过 1 年前
Where&#x27;s Douglas Hofstadter when you need him?