Search for a hot-swappable programming platform

I am currently brainstorming on how to update a program while it is running. (Not during debugging, the "production" system.)

But one thing that is required for this is to actually send the modified source code or compiled byte code to the running process.

Pseudo code

var method = typeof(MyClass).GetMethod("Method1"); var content = //get it from a database (bytecode or source code) SELECT content FROM methods WHERE id=? AND version=? method.SetContent(content); 

First, I want the system to work without the complexity of object orientation. This leads to the following requirements:

  • change the source code or byte code of a function
  • drop function
  • add new features
  • change function signature

With .NET (and others), I could inject a class through IoC and thus modify the source code. But loading would be cumbersome because everything has to be in the assembly or created through Emit. Maybe with Java it would be easier? I think the whole Loader class is interchangeable.

With JavaScript, I could achieve many goals. Just evaluate the new function (MyMethod_V25) and assign it to MyClass.prototype.MyMethod. I think you can somehow drop functions with "del"

Which general purpose platform can handle such things?

+4
source share
8 answers

In Java, you have an OSGi project that makes it easy to update and change the modules of your application without touching other modules.

If you don't mind learning something else, the Erlang programming language has been designed from the ground up with this type of application in mind.

+3
source

I think any image-based language will support this. I know what Common Lisp does, as it is probably one of the most common ways to deploy Lisp web applications, but I suspect it will work in much the same way, for example, in Smalltalk.

+3
source

Most dynamic languages ​​have this feature. Take a look at Ruby: you can modify existing methods, etc. At runtime. When IronRuby is off, you can do this on the .NET platform.

+2
source

I got the impression that Erlang is now very noticeable as a language that has this feature. However, my father-in-law (chief programmer, in my opinion) told me that he implemented the hot-swappable code on a slightly older platform - assembler for what they now call z / OS (OS / 390 before )

Personally, I was looking for ways to do this in the Java space, where most of my professional work is currently being done. In Javaland, the most encouraging efforts to ensure hot unloading (as far as I know) is the work done by the OSGi Alliance . However, this solution necessarily includes some class loader magic due to the way some common Java libraries are archived (for example: JDBC DriverManager ). If you decide to go the OSGI route, your code is likely to require extensive auditing and testing to ensure that it will be used with the OSGi architecture.

As an alternative to implementing hot-swappable code, perhaps you can implement a system that appears to have this capability using a potentially simpler query queue mechanism. For example, if you need a "hot" replacement for the part of your system that processes large backend requests, why not send these requests through an intermediary who can send them to the backend component if it works, and accumulate them in the queue if the component does not works? This can allow you to update the backend component independently of the rest of your system without redistributing it, as we say in the whole shebang industry.

+2
source

With JavaScript, this can be done. Surprisingly, the Google V8 engine is open source and easily implemented in any C ++ program.

http://code.google.com/p/v8/

Of course, you will have to write a little library to have the functionality open and loading the script from within JavaScript. It will depend on what you want to do.

+1
source

But one thing that is required for this is to actually transfer the modified source code or compiled bytecode to the current process. Which general purpose platform can handle such things?

Erlang has already been mentioned, and it uses explicit "synchronization points" where the current routine can explicitly update itself by making a "self" call using "? MODULE: procedure ()".

This is another important thing to keep in mind: you just don’t need to use the capabilities of a virtual machine to replace executable code, but executable code also needs a way to respond to such updates and configure it accordingly.

You can also watch UpgradeJ , which is a language specifically designed to meet this requirement (with the ability to hot-swap code).

+1
source

Erlang can do whatever you are looking for, and it does not rely on any bolted libraries (unless you count OTP in this category) or work with encodings. It can maintain state (that is, “variable values” in mandatory language mode) for reloading and does not require transactions to be buffered or resubmitted. If you write your OTP-style code, you can get your application programmers to write simple sequential code that will have some degree of ability to execute in parallel, as well as support a hot reboot, all without having to worry about how it was done. It just works.

0
source

With .NET, this is perfectly implemented using the Managed Extensibility Framework. This structure is introduced in .NET 4. You can create extensible applications. It does what the IoC container can do, although it can do more. It can detect functionality that does not know a priori. In addition, you can update functionality; you do not know what will be updated a priori. In other words, it is a platform for modular applications, regardless of whether you want hot-swap pieces of code and want to provide various functions or update existing ones.

0
source

All Articles