On Tuesday, April 12, 2016 at 3:22:50 PM UTC, Aaron R. M. wrote: > > Hey I'm looking for a solution to some problems that i have using Julia as > a general purpose language. > Given that there are no access modifiers i cannot restrict people calling > functions i don't want them to call. > Use case is a game (yeah that's somewhat new territory) that has its > codebase (provided by me) but allows scripting the environment (within some > borders also outlined by me). Examples would be spawning some > plants/animals etc. manipulating what happens on clicking and so on. All > stuff that changes your experience in the game. > > But i clearly don't want people do be able to accidentally harm their > computers by downloading/removing/creating anything in their file system. > The other obvious reason is that i don't want people to be able to open a > file stream download a virus and execute it (what theoretically would be > possible). This is no problem in a singleplayer game but imagine it being > multiplayer. >
I hope I didn't scare you off, but you wouldn't normally send code from one client to another. As I said previously, Java is an environment made, designed to handle arbitrary code from the internet (still the implementations have had bugs..). Maybe in the future Julia will have something like: https://docs.python.org/2/library/restricted.html "Restricted execution is the basic framework in Python that allows for the segregation of trusted and untrusted code." I imagine e.g. Blender uses such. I know at CCP Games, they use [Stackless] Python for EVE Online. I still think they do not use, such an environment, as the clients should only get code from their servers. And The servers do not trust the clients. That isn't really appropriate in a multiplayer game. What I was describing (safe environment), is probably an overkill for your or any game. And one more thing I remember, you would want to restrict file-system access and/or at least the run-function.. This case could also be handled by just not sharing stuff or having no > multiplayer but i think you get my problem. > > The next problem that also results from the very same game idea was the > following: > Mind you've got some automation tool that does anything on its own (like > protecting you like a shield) now say this shield does something scheduled > as well. Since this is all coded by the player there are no real hooks in > his code. So what can i do to preserve the current state of the execution > of this script in case he leaves the game or pauses it. (Means i need > something to make the current execution state persistent aswell as being > able to stop it at any given point and of course resume it later) > This problem leads to something similar to an interpreter or even debugger > (or even more abstract a VM, but i think that'd be overkill) but for the > current existing ones they clearly don't focus on persistence and the > ability to yield after like 10 execution steps. A perfect solution to this > problem would be some sort of scheduler for the interpreter/debugger that > can save the state of it's scheduled program. But sadly something like that > doesn't exist (at least i didn't find it). > > So are there any tips/workarounds to come nearer to my dream of game? > Partial solutions/solutions/ideas etc even for "only" one of the problems > are highly appreciated. > > Of course i know these problems are very special but I'm sure that having > more people reading it might result in some very nice ideas. >
