Making an .exe that executes source file inside itself.

IntegratedDimensions IntegratedDimensions at gmail.com
Wed Apr 25 21:05:07 UTC 2018


On Wednesday, 25 April 2018 at 19:19:58 UTC, BoQsc wrote:
> So there has been idea I've got for around few months now: 
> making a software which executable would contain a source file.
> A software that anyone could modify by opening an executable 
> and quickly change a few lines of it, rerun an executable, see 
> the changes.
>
> Could this be easily possible with D language, considering that 
> sources files can be ran without long slow compilation process?

I had a similar idea a few months ago too, coincidence?

The idea is that all apps have the source code embedded so that 
they can be debugged and modified by the user at will. Each app 
has a built in IDE and debugger(or can trigger an external one 
for space).

When an error occurs it will jump to the debugger for debugging 
purposes. If some functionality is to be modified(e.g., change 
the size of a button or add some new feature) the user can 
trigger the IDE(hot key) to proceed.

The point of having it all self contained is to allow future 
revision and debugging without having to worry about version 
issues. The point of the debugging is so the user can fix bugs 
that plague software. While on the whole most software may work 
for most users, it is very annoying when some minor bug prevents 
a program from working for a specific user. Many more people know 
how to program than ever and it will only become more and more 
common.

Also, with such capabilities, the user can add additional 
functionality. It is very annoying when programs don't support 
simple stuff. A few lines of code could make the program much 
more effective for a user that wants to do something that was not 
thought of if they could just add it. e.g., even just display 
something, change the location of a widget, or modify how a text 
file is read so it can support a new format.

One can argue that platforms such as Linux make this easy... but 
only marginally. If one get actually get the code to compile 
without having to waste many hours, one must also generally sift 
through the code to find the relevant parts then try and 
understand them. Usually because of the trial and error process 
is long this generally is a deterrent for "normal" people with 
"normal" lives.

If apps are properly structured with such goals in mind then it 
would be of great benefit, although only a few of us like you and 
me have the wherewithal to extrapolate out.

It would not be difficult to do(it is more about organization 
than about technological problem solving). With proper ide 
design, debugger, and such, one could make app writing self 
contained, so to speak. That is, the IDE and debugger are used 
directly to write the program instead of using the traditional 
methods such as vim, emacs, visual studio, coedit, etc.

What is packaged in an binary are the

IDE
Debugger
Profiling
Source Code(with history, VCS included)
Compiled Code(possibly optimized version)
Debugging Data
Scripting

Generally, without debugging, the executable just runs the 
compiled code as if it were a normal app. When triggered, the 
ide/debugger can be brought up that takes over and displays the 
desired source code(triggers can be used).

I believe the main issues for proper development would be the 
ability for quick code replacement(hot swapping, injection, etc) 
which is tricky since some code would require a full restart 
which will slow things down. Most of the other programs are just 
gluing everything together and providing certain mechanisms that 
allow for robustness such as being able to replace the IDE or 
debugger, extract the source code for repackaging.

While it would be time consuming to implement well it would be 
very useful. There are many many times I have used programs that 
simply do not function correctly or are missing simple 
functionality that would take me a just a few minutes to write a 
few lines of code to fix.  Having the above would make it 
possible to do. One could also then "upload" 
patches/fixes/enhancements to the cloud or download others. This 
way people can tailor applications to their own use rather than 
being stuck with what the developers(which generally are somewhat 
clueless as their main goal is to ship the product rather than 
provide all the functionality their users want).

















More information about the Digitalmars-d-learn mailing list