Comments (7)
The StackOverflow thread talks about sandboxing, so I'm guessing you are concerned about security. First, security is not a primary goal of what we want to achieve here. Nonetheless, GraalVM can sandbox languages and thus the polyglot API can be considered "secure". By default, however, I think sandboxing is disabled. Will look into this for you...
So ultimately, we could move all modifications (e.g. magic parsing) to nel and leave everything else almost as they were, right?
from ipolyglot.
Why
return vm.runInThisContext(Polyglot.eval(magic, actualCode));
and not just
return Polyglot.eval(magic, actualCode);
?
from ipolyglot.
Basically works with ea2a0ef
The only things left which would be nice to have for the next meeting are execution of multiline code and supporting "
for strings in code cells, not just '
:D
We might be able to solve both issues using some kind of Regex escape for strings maybe. @jonashering @tomkellog
from ipolyglot.
@jak-ing have you found the LOC where your "transpiled" code is executed (probably by calling eval()
). Maybe it'd be better to extract magic and language selection where that eval
call is and replace it with a direct Polyglot.eval()
call? Example:
Somewhere in jp-kernel
or probably in nel
:
eval(request.code);
turns into:
magic = polyglotExtract(request.code);
Polyglot.eval(magic.language, magic.code);
This way, you can easily support multiline code and avoid the use of regexs :)
from ipolyglot.
Looks like nel
also has some sort of transpiler support. And this is how nel
executes JS code.
from ipolyglot.
@tomkellog wanted to take over from here but here's what I found out already yesterday:
Replacing the eval()
call with Polyglot.eval()
I'm in favor of this too! vm.runInThisContext
replaces eval
as can be seen in the example from the vm
docs. So eval()
is actually not used in neither jp-kernel
nor nel
. But I'm not sure whether it's a good idea to swap out vm.runInThisContext
with Polyglot.eval()
:O Is there a GraalVM equivalent to vm
@fniephaus? Or maybe we can somehow call the GraalVM node
binary itself instead of runInThisContext()
?
Transpiler support in nel
The transpile
in nel
just takes the transpile
defined in e.g. IJavaScript's kernel.js through the passed config (--> Kernel(config)
--> Session(...)
) and doesn't do much anything else as far as I can see. Also since we don't actually transpile stuff but manipulate the code execution itself I think changing the eval()
mechanism as proposed by you above is a better idea.
from ipolyglot.
multi-line, choice of quotation marks and support for all Graal language works. Code is uncommited because changes affect node modules, in main.js
):
function run(code) {
let magic = '';
if(code.startsWith('%polyglot ')){
magic = code.split('\n')[0].replace('%polyglot ', '')
} else {
return vm.runInThisContext(code);
}
const actualCode = code.split('\n').slice(1).join('\n');
return vm.runInThisContext(Polyglot.eval(magic, actualCode));
}
from ipolyglot.
Related Issues (20)
- Create own bin/node HOT 1
- Add inspector view element for bindings object. HOT 4
- Use language specific comments in juypter notebook.
- Handle cell ouput across languages. HOT 2
- Investigate whether JuypterLab is suitable and needed. HOT 1
- Implement automatic variable exporting for more languages. HOT 8
- Improve variable inspector. HOT 2
- Rename ijsinstall script / clean up project. HOT 1
- Make polyglot inspector a tree view. HOT 2
- (Re-)deploy to Vm
- Error parsing Jupyter version HOT 3
- Add automatic language detection.
- error from docker: npm ERR! Failed at the [email protected] postinstall script. HOT 2
- Can not connect to ipolyglot kernel HOT 2
- Add syntax highlighting to notebook cells for different languages. HOT 1
- Use IJavaScript kernel inside GraalVM with Jupyter frontend. HOT 4
- Abstract from polyglot API for importing and exporting variables. HOT 5
- Set up jupyter notebook server in VM HOT 6
- Get paper demo notebook running HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipolyglot.