Live data from Hacker News

TruffleC: A C implementation on top of JVM (2014)

dl.acm.org

11–20 of 93 posts

Re: TruffleC: A C implementation on top of JVM (2014)

#11
post #2

Only 7% slower seems amazing. To me at least.

The JVM runtinme is not easy to beat performance-wise for what it does, wonder how many man-hours have been put by Sun, Oracle et al into the platform itself.

The JVM is an absolutely beautiful constructed software and protocol. I hope it stands for millennia, just like the colosseum, even if not in active use.

Re: TruffleC: A C implementation on top of JVM (2014)

#14

Earlier quoted context omitted.

The JVM runtinme is not easy to beat performance-wise for what it does, wonder how many man-hours have been put by Sun, Oracle et al into the platform itself.

The JVM is an absolutely beautiful constructed software and protocol. I hope it stands for millennia, just like the colosseum, even if not in active use.

I think it will do better than just stand. In recent years there's been remarkable progress in low-pause garbage collectors, and ahead-of-time compilation. I'm not sure about the status of the RISC-V port, but that is (or will be) another nice addition.

Re: TruffleC: A C implementation on top of JVM (2014)

#15

Earlier quoted context omitted.

The JVM runtinme is not easy to beat performance-wise for what it does, wonder how many man-hours have been put by Sun, Oracle et al into the platform itself.

The JVM is an absolutely beautiful constructed software and protocol. I hope it stands for millennia, just like the colosseum, even if not in active use.

Absolutely correct. And frankly I don't understand the hate people have against Java. Especially the new generation developers. Maybe the language part only. But have seen much hate towards JVM too.

With projects like loom, valhalla, graalVM, JVM/Java is everything a modern language/runtime needs, plus a lot lot more.

I frankly believe the only other commercially viable language that has similar philosophy to JVM development, is Rust.

Opinions?

Re: TruffleC: A C implementation on top of JVM (2014)

#16

How are pointers implemented in a language that doesn't support them?

A class wrapping a long value with the pointer address in it.

How is the C memory modelled? One big Java array, or are there multiple data-structures?

For instance, what happens when you call a function-pointer?

Re: TruffleC: A C implementation on top of JVM (2014)

#17

How are pointers implemented in a language that doesn't support them?

I guess a really brute force way would be to have a huge dictionary mapping from "memory address" (really just an arbitrary number) to JVM object. malloc() would add to the dictionary and free() would remove an entry. Pointer dereference would look up in it but would need to be able to find the nearest lower entry (for when you have an array and dereference an entry in it, or use a pointer to a field in a struct).

I would hope that there's a much more efficient way to do it, this idea is just evidence that it could be done in principle. But I don't see what that more efficient way would be. You certainly need to keep a secret reference to each JVM object somehow because C doesn't require you to keep any pointer to an object e.g.

    intptr_t x = (intptr_t)malloc(sizeof(int));
    *(int*)x = 99;
    bool did_subtract_50 = false;
    if (x > 50) {
        did_subtract_50 = true;
        x -= 50;
    }
    // Now there is no pointer or even integer that contains the address
    
    // ... later ...
    // Retrieve the address and use and free it
    int* y = (int*)(x + 50 * did_subtract_50);
    printf("value: %d\n", *y);
    free(y);

Re: TruffleC: A C implementation on top of JVM (2014)

#18

Earlier quoted context omitted.

The JVM runtinme is not easy to beat performance-wise for what it does, wonder how many man-hours have been put by Sun, Oracle et al into the platform itself.

The JVM is an absolutely beautiful constructed software and protocol. I hope it stands for millennia, just like the colosseum, even if not in active use.

What's the protocol part you are referring to? The proper bytecode?

Re: TruffleC: A C implementation on top of JVM (2014)

#19

How are pointers implemented in a language that doesn't support them?

A class wrapping a long value with the pointer address in it.

Ha! Your paper is a "highly influential citation"

https://www.semanticscholar.org/paper/TruffleC%3A-dynamic-ex...

Post reply on HN