Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am building a Virtual Machine and I think I have a perfect program design but I am worried as I don't have too much experience on this field there might be flaws.

Before I'll tell you how it'll work, I'm first going to list some stuff this programming language and virtual machine is all about.

  • Being Loaded as an extension (Like JNI)
  • Dynamically Loading Extensions / Plugins
  • Better Performance than common scripts like Javascript / PHP
  • Object Oriented
  • Easy to setup all requirements
  • Machine Security (You cannot use any native machine functions, security manager for extended permissions like managing files, connecting to network)
  • Code Security (People'll have a hard time to recover the code)

The total package will consist out of different parts:

  • Compiler to Bytecode
  • Virtual Machine (Read & Execute Bytecode)
  • Program using the scripts (Contains VM to run them)
  • Bytecode Program (Compiled program to be ran by the VM)

A program will be stored inside a basic .zip archive. The .zip archive will contain all bytecode files as well the file containing an interface. When source code is compiled, all variable and function names will be gone. They will be replaced / obfuscated with regular integers. While compiling, an interface, as mentioned before, will be added to the .zip archive.

The interface will basically be a library of function that can be called from outside the program, by the VM. This interface could for example include the main method. When the VM is being used as a plugin loader, it could for example also contain a getName() or a getIcon function.

When loading in the VM it'll ask for an interface to use. When later on loading in a .zip to this VM it'll check if the interfaces match. If they don't the VM will refuse to load the program.

When it's loaded in the main program will be able to ask the VM to run a certain function defined in the interface.

Also the program being executed will be able to run functions of the VM. Also these functions will be a part of the interface.

A program being executed can request to load in new programs. They will also be loaded with an interface and the program will be able to use it's method. (A plugin loading plugins basically)

The idea seems flawless to me but just to be sure I wanted to ask everyone here if any problems or blockers might occur while developing it.

Just to be clear, I'm not aiming to compete with Java/CLR or anything.

share|improve this question

closed as unclear what you're asking by MichaelT, gnat, Giorgio, Bart van Ingen Schenau, GlenH7 Mar 8 at 21:21

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

4  
What's the purpose of this VM/setup? It's hard to judge something as "good" when we don't know a use case. For example, where would I use this over the JVM or .NET or Parrot? –  jozefg Aug 30 '13 at 16:37
1  
Is this interface you're describing a list of functions in the VM or in the program? Or both? –  jozefg Aug 30 '13 at 16:43
    
@jozefg It's main use will be working together with other programs dynamically. (Like plugins) –  Jeroen Bollen Aug 30 '13 at 16:44
1  
A pure bytecode VM won't be faster than or even comparable to major JavaScript implementations from the last five years, simply because those have mature JIT compilers. For PHP, decent JIT compilers start to pop up as well, though they're not yet standard. And one important issue that I didn't see mentioned at all is backwards and binary compatibility, both for the bytecode files and the "interfaces". –  delnan Aug 30 '13 at 16:46
    
@jozefg It basically is a tunnel for the VM and the program to communicate. So it contains both. It doesn't contain ALL functions though, just the ones needed (like the main method of the program, and getSecuirtySettings() from the VM. (Like what in a class would be private won't be in there) –  Jeroen Bollen Aug 30 '13 at 16:46
show 5 more comments

1 Answer

When source code is compiled, all variable and function names will be gone.

The interface will basically be a library of function that can be called from outside the program, by the VM.

How exactly are you going to specify what function to run when it no longer has a name? Some random integer that you hope happens to line up?

I imagine these integers collide between modules, so references will need some strong name for the module and an integer?

Frankly, this isn't a design. It's a very high level set of requirements with some vague handwaving about how it will work. Programming Language design flaws tend to be very subtle and will be expressed in the details.

In general, there will be flaws in your design - just like any other non-trivial piece of software.

share|improve this answer
    
To quote the zen of python Namespaces are one honking great idea –  jozefg Aug 30 '13 at 17:18
    
A .zip will basically be a namespace so that'll ban all conflicts. Also the interface is will tell the VM what IDs match what functions. I know there will be flaws and limitations, but I'm talking globally here. –  Jeroen Bollen Aug 30 '13 at 17:25
    
@Binero - so you're encoding filenames into your variable references? That seems stinky. –  Telastyn Aug 30 '13 at 17:31
    
@Telastyn I never said I was. I am just putting every .zip in a namespace, VM level. –  Jeroen Bollen Aug 30 '13 at 17:46
    
@binero - then how are you resolving references at runtime for your extensions/plug-ins? –  Telastyn Aug 30 '13 at 17:47
show 1 more comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.