|
|
|
|
|
by norir
1034 days ago
|
|
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 val greet = (whom: String) => print(s"Hello, $whom!")
to lua local greet = function(whom) print("Hello, " .. whom .. "!") end
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'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.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. |
|