GennTa
GennTa

Reputation: 1

Language with extensive support for self-modifying code?

Which programming languages provide the best support for self-modifying code? In particular, since the program will need to make extensive use of self-modifying code, I am looking forward at the ability to remove from memory some parts of code, after they are no longer needed, thus freeing that memory. Also, it would be a plus if there was the ability to identify and index the routines (procedures, functions, etc) with some sort of serial number, so that they could be easily managed in the memory (deleted, cloned etc) at runtime.

Upvotes: 0

Views: 514

Answers (1)

David Cary
David Cary

Reputation: 5490

Operating systems need to have some more-or-less "self-modifying code" in order to load programs and dynamic link libraries from storage into RAM and later free up that RAM for other things, do relocation fix-ups, etc. My understanding is that currently the C programming language is by far the most popular language for writing an operating systems. The OSDev.org wiki has many tips of writing a new custom operating system, including a brief discussion of languages suitable for writing an operating system -- C, Assembly language, Lisp, Forth, C++, C#, PL/1, etc.

Just-in-time (JIT) compilers also need to have some more-or-less "self-modifying code" to compile source text into native instructions and run them, then later free up that memory for the next hot-spot.

Perhaps you could find some OS project or JIT project and use their code with relatively little modification.

A few people, when they say they want "self-modifying code", really want a language that supports homoiconicity such Scheme or some other dialect of Lisp, Prolog, TCL, Curl, etc.

Upvotes: 1

Related Questions