Language with direct RAM<->HDD communication

Why nobody invented language with built-in direct RAM<->HDD communication so far? I think this would have many pros (if used right), even in modern times where RAM is getting cheaper and cheaper.

Some examples (in Java code):

Example class:


import java.util.ArrayList;

public class ExampleClass {

    //field for internal JVM use only, possibly by GC
    private boolean loaded = true;
    
    private ArrayList<String> list;
    
    public ExampleClass() {
        list = new ArrayList<>();
    }
    
    public ArrayList<String> getList() {
        return list;
    }
    
    public void setList(ArrayList<String> list) {
        this.list = list;
    }
    
    //this method should be directly in Object class
    public boolean isLoaded() {
        return loaded;
    }
    
    //this method should be directly in Object class
    public void setLoaded(boolean loaded) {
        this.loaded = loaded;
    }
    
    public void doSomething() {
        //do something here
    }
    
}

Example 1:


public static void main(String[] args) {
        //new object is created in memory
        ExampleClass obj = new ExampleClass();
        obj.getList().add("Hello World!");
        obj.doSomething(); //working as usual

        obj.setLoaded(false); //JVM receives hint that obj and everything inside should be unloaded from memory and moved to HDD on next GC cycle
        obj.doSomething(); //still working as usual, unless GC cycle happens between this and previous call
        
        System.gc();
        obj.doSomething(); //obj is loaded from HDD and is stored here until end of method and next GC cycle, if called method is using list inside obj, then this list is loaded as well
        
        obj.setLoaded(true); //the whole obj is loaded from HDD to memory and deleted on HDD
        obj.doSomething(); //working as usual
    }

Example 2:


public static void main(String[] args) {
        ExampleClass first = new ExampleClass();
        ExampleClass second = new ExampleClass();
        
        first.setList(second.getList());
        
        second.setLoaded(false); //only second will be unloaded to HDD on GC as list is used somewhere else
        System.gc();
        first.list.add("Hello World!"); //works as usual
        second.doSomething(); //second is loaded from HDD, but list inside is in memory all the time
        
        first.setList(new ArrayList<>()); //reference to list inside second object is erased
        System.gc(); //list inside second object is unloaded to HDD
        second.doSomething(); //obj is loaded from HDD and is stored here until end of method and next GC cycle, if called method is using list inside obj, then this list is loaded as well
    }

Because that is (rightfully) the OS’s job: http://en.wikipedia.org/wiki/Paging

Yes, but in case of paging you don’t have any control on what is in memory and what is stored on HDD - I am thinking mostly about something like database built directly in language which is deleted after program execution stopped.

I fail to see how thrashing things like that would be remotely useful.
It seems you want a free lunch: automatic handling of memory (GC) plus no active memory being wasted (offloading to HDD). This can be done, but at absolutely enormous time expense, well past the point of being worth it.

The virtual memory abstraction is abstract for a reason.
If you want to store things (temporarily or otherwise) outside of RAM you just use a File.
Java’s (rather mundane) type system is nowhere near powerful enough to automate the task for you effectively, people who don’t like GC already say it isn’t good enough already.
This is why I like ideas like linear types: any instance of a linear type must be “used” exactly once, i.e. “consumed,” thus you get automatic memory management for free (time wise), although at the cost of a more strict type system.

EDIT: fleshed out some thoughts

Memory handling like that is something that we leave to the OS because frankly its confusing , boring and a bit sexual all at the same time. They dont mix , its like that packet of cheese you had but left one slice in , you put it at the back of the fridge but dont want to touch it incase you die thats what memory programming is like , dont touch the cheese , just let it be and enjoy the rest of the fridge.