digitalmars.D - Easy User code injection
- Patience (32/32) Apr 03 2016 One problem with many applications is they are static once
- cym13 (8/40) Apr 03 2016 That sounds complicated... couldn't you just separate the parts
- Laeeth Isharc (6/9) Apr 03 2016 Lua is pretty easy to embed, either via C or LuaD. Great for
- Kagamin (4/7) Apr 04 2016 Some games are scripted: they provide an engine and high-level
One problem with many applications is they are static once compiled in the following sense: There are apps that have certain behaviors that may be incomplete are undesirable. Usually it could be that the designers used a hard coded value for something when it would be better to have made that variable a "setting". The problem is, the only way to change this is to re-compile the code. It would be extremely beneficial if the user themselves could modify the code. Since they obviously can't recompile without the source, i.e. all commercial apps, they have to ask the developers for the enhancement or fix. The developers could write a complex object oriented design and allow the user create objects that modify existing objects and so forth(a plugin like system) but that creates way more complexity than required for usually simple modifications(a few lines of code). Does anyone see how it could be possible to make an efficient way in D applications to allow for "user modifications" almost as equivalent to having the source? Code injection/Hooks is probably the way to go about this but one has to worry about performance in some cases, the implementation details in D, and how to present this to the user in the best possible way. A "scripting" like interface would probably be required but not necessary as we could allow the user to create the code somewhere else. Another idea: Suppose the source code is internally encrypted and when the user wants to modify a part of it, the application can recompile that part of the code and replace the original. Doesn't seem like a great idea but probably only slightly worse than reverse engineering the binary itself.
Apr 03 2016
On Sunday, 3 April 2016 at 20:51:47 UTC, Patience wrote:One problem with many applications is they are static once compiled in the following sense: There are apps that have certain behaviors that may be incomplete are undesirable. Usually it could be that the designers used a hard coded value for something when it would be better to have made that variable a "setting". The problem is, the only way to change this is to re-compile the code. It would be extremely beneficial if the user themselves could modify the code. Since they obviously can't recompile without the source, i.e. all commercial apps, they have to ask the developers for the enhancement or fix. The developers could write a complex object oriented design and allow the user create objects that modify existing objects and so forth(a plugin like system) but that creates way more complexity than required for usually simple modifications(a few lines of code). Does anyone see how it could be possible to make an efficient way in D applications to allow for "user modifications" almost as equivalent to having the source? Code injection/Hooks is probably the way to go about this but one has to worry about performance in some cases, the implementation details in D, and how to present this to the user in the best possible way. A "scripting" like interface would probably be required but not necessary as we could allow the user to create the code somewhere else. Another idea: Suppose the source code is internally encrypted and when the user wants to modify a part of it, the application can recompile that part of the code and replace the original. Doesn't seem like a great idea but probably only slightly worse than reverse engineering the binary itself.That sounds complicated... couldn't you just separate the parts you want the user to be able to change to be in a dynamic library? That way you can ship a working product and if someone wants to change it they recompile and replace the library by the new one. If you don't want to give the sources of that one part you can give a "dumb" interface file to lay down a skeleton for the user to change. Seems easier on both ends than encryption.
Apr 03 2016
On Sunday, 3 April 2016 at 20:51:47 UTC, Patience wrote:One problem with many applications is they are static once compiled in the following sense: [...]Lua is pretty easy to embed, either via C or LuaD. Great for config files or more complex modification of behaviour, and LuaJIT is fast enough for most things (just try to write interface do you don't call from inner loop). LuaD has some rough edges but is very usable.
Apr 03 2016
On Sunday, 3 April 2016 at 20:51:47 UTC, Patience wrote:A "scripting" like interface would probably be required but not necessary as we could allow the user to create the code somewhere else.Some games are scripted: they provide an engine and high-level logic is written in a script. Firefox is written this way too. This is usually enough for most things.
Apr 04 2016