Question

I was wondering between the transpiler and compiler.

For example, I have a language('let's call it foo') and it will be transpiled to javascript.

foo -----transpiled-----> javascript

However, is foo limited under javascript?

Such as: "JavaScript cannot write to files on the server without the help of a server side script"

foo ----x----> write to files on the server without the help of a server side script

If so, is it possible to exit from the limit of javascript?

Such as making foo able to write to file itself.

foo ---------> write to files on the server

Note: What i am asking for is explanation and why and so on, NOT THE CODES!

Note again: Is it possible for it to exit the limits with additional libraries?

Edit: So, if i added another library from another language like python, will it help to exit the limits?

Was it helpful?

Solution

You CAN'T exit the limits of the destination language. You could, however, create a compatibility layer that emulates the missing features and provide the functionality somehow.

In your example, if the foo internal function writefile() is the one that writes files, you could make a library that provides a writefile function that uses ajax to store the files to the server (or a cookie or localstore, etc). The original foo script wouldn't have to be changed for it to work.

And this is precisely one of the main parts about writing a transpiler: You not only have to translate the language, but you also have to emulate the missing features.

(you can also opt to disable the missing features)

OTHER TIPS

Transpiler is a type of compiler that takes the source code of a programming language as its input and outputs the source code into another programming language.

So in output you have file with source on destinationa language, for your sample its javascript, and this file will be executed, so if you create it manualy on javascript it was same result.

so answer on your question: no its not possible exit the limits destinations language, because in the end you can execute program on this language

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top