Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Did Truffle run on bck2brwsr? #55

Open
shafqatevo opened this issue Oct 5, 2022 · 3 comments
Open

Did Truffle run on bck2brwsr? #55

shafqatevo opened this issue Oct 5, 2022 · 3 comments

Comments

@shafqatevo
Copy link

Hi @jtulach @JaroslavTulach

While browsing the codebase, it seems there are good bit of Truffle code or test code. Was Truffle ever run on bck2brwsr or in browser?

If yes, is it possible in theory to run or port Truffle on either bck2brwsr or other such technologies like TeaVM?

Thanks!

@jtulach
Copy link
Owner

jtulach commented Oct 11, 2022 via email

@shafqatevo
Copy link
Author

Dne středa 5. října 2022 13:27:33 CEST, Shafqat Ullah napsal(a):
Hi @jtulach @JaroslavTulach While browsing the codebase, it seems there are good bit of Truffle code or test code. Was Truffle ever run on bck2brwsr or in browser? If yes, is it possible in theory to run or port Truffle on either bck2brwsr or other such technologies like TeaVM?
Hi. I tried to generate JavaScript files by Bck2Brwsr VM and then run them with Graal.js powered by Truffle. That worked, but nowdays it has a little reason to exist when there is Espresso. However you are asking the opposite question: can Bck2Brwsr execute a Truffle language? And do it quickly? Bck2Brwsr can do none of that. However that doesn't mean it cannot work. I saw a prototype of "Native Image JavaScript backend" (while working in OracleLabs) that could execute SimpleLanguage in the browser. It wasn't running at full speed, but it did run. Moreover there is no reason why it could run even fast - it is just a lot of work. Whether or not OracleLabs decide to donate that work remains to be seen. Best regards and thanks in you interest in Bck2Brwsr VM! -jt

Thanks a lot for your reply! I have watched most of your YouTube talks and will watch the remaining ones soon. Really appreciate the work you've been doing over the years.

Yes, my main question was whether Truffle can run on top of Bck2Brwsr. The goal is to run the Truffle langs and Espresso in browser.

It appears to me that in theory, if we do a source-to-source transpilation or port of Truffle to JS, it might run on V8 itself. Essentially the same Truffle API but for V8 instead of JVM, which can then run all Truffle langs and even bytecode via Espresso. In this approach you don't need to use any limited JVM in the browser. Or if needed, Bck2Brwsr itself can be used as that limited JVM.

Is that a potential approach? What is a better approach?

@jtulach
Copy link
Owner

jtulach commented Oct 12, 2022

Yes, my main question was whether Truffle can run on top of Bck2Brwsr. The goal is to run the Truffle langs and Espresso in browser.

There is a reimplementation of DEW with OracleLabs transpiler. Take a look at https://www.graalvm.org/22.2/reference-manual/embed-languages/ and press the "Fiddle" button:
image
that runs javac in the browser using OracleLabs "aot.js" technology. The goal of the team is to run not only javac, but also Truffle languages. I have seen simple language running.

It appears to me that in theory, if we do a source-to-source transpilation or port of Truffle to JS, it might run on V8 itself.

You can use Bck2Brwsr and transpile Truffle into JavaScript (including some language) and run on V8. No problem with that. It is going to run.

Is that a potential approach? What is a better approach?

The transpiled JavaScript is going to run, but it is not going to be partially evaluated - e.g. it is not going to be fast. Future versions of aot.js technology might do some partial evaluation, but certainly not Bck2Brwsr - that's too much work for a single man project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants