Search code examples
programming-languageslanguage-features

Which programming language allows to update any class on-the-fly?


I am wondering, are there any languages allows you to add/delete/update any class on the fly without reloading whole application? (Provided that I can accept some inconveniences like making sure that there is no methods running at the moment + some extra effort to 'migrate' class data members).

Web applications where you replace 1 file and it is used on the next client request is not what I need (like Perl, PHP). Application must be continuously running, and it have some internal state.

Other requirements are

  1. No GIL or similar issues preventing from utilizing SMP
  2. Preferably - existence of JIT-like VM (i.e. where performance is close to native code). Ideal solution would be to be able to reload module in CLang or any other LLVM-based language. It would be just perfect.

About the answers already made:

  • .NET/Java is not suitable - they both have too bulky VM's, and significant part of app will be running on Linux.
  • Erlang - looks like it's possible, but it's terrible for my naked eye, I just cannot look calm at it's if's, case's and strings. Also, I would prefer to avoid transfering bare sources to clients, compiled bytecode would be much better.

Solution

  • Objective-C might fit the bill. You can use the functions documented here to add new classes and swap method implementations at runtime, and you can load new NSBundles with additional classes or categories on existing classes if additional implementations are required. GNUStep, while not implementing all of the recent Apple additions to the language, does claim to implement these features (see [1] and [2]).